aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv/Module.zig
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2022-11-28 18:12:03 +0100
committerRobin Voetter <robin@voetter.nl>2023-04-09 01:51:50 +0200
commit0c2526b18ec21d8155b070022d3b3b9069303744 (patch)
tree880e4e26bf2b703b6d6de83bcda64c8b3bba69ec /src/codegen/spirv/Module.zig
parente443b1bed7ccce45bf039a304fa8fa271f1faa0b (diff)
downloadzig-0c2526b18ec21d8155b070022d3b3b9069303744.tar.gz
zig-0c2526b18ec21d8155b070022d3b3b9069303744.zip
spirv: some fixes and improvements
- Adds the Int8. Int16, Int64 and GenericPointer capabilities. TODO: This should integrate with the feature system. - Default some struct fields of SPIR-V types so that we dont need to type them all the time. - Store struct field name's in SPIR-V types, and generate the OpMemberName decoration if they are non-null. - Also add the field names to the actual SPIR-V types. - Generate OpName for functions.
Diffstat (limited to 'src/codegen/spirv/Module.zig')
-rw-r--r--src/codegen/spirv/Module.zig27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/codegen/spirv/Module.zig b/src/codegen/spirv/Module.zig
index ab9d0588ca..b8dfd3fb96 100644
--- a/src/codegen/spirv/Module.zig
+++ b/src/codegen/spirv/Module.zig
@@ -437,8 +437,16 @@ pub fn emitType(self: *Module, ty: Type) error{OutOfMemory}!IdResultType {
}
fn decorateStruct(self: *Module, target: IdRef, info: *const Type.Payload.Struct) !void {
+ const debug_names = &self.sections.debug_names;
const annotations = &self.sections.annotations;
+ if (info.name.len != 0) {
+ try debug_names.emit(self.gpa, .OpName, .{
+ .target = target,
+ .name = info.name,
+ });
+ }
+
// Decorations for the struct type itself.
if (info.decorations.block)
try annotations.decorate(self.gpa, target, .Block);
@@ -457,6 +465,25 @@ fn decorateStruct(self: *Module, target: IdRef, info: *const Type.Payload.Struct
for (info.members, 0..) |member, i| {
const d = member.decorations;
const index = @intCast(Word, i);
+
+ if (member.name.len != 0) {
+ try debug_names.emit(self.gpa, .OpMemberName, .{
+ .type = target,
+ .member = index,
+ .name = member.name,
+ });
+ }
+
+ switch (member.offset) {
+ .none => {},
+ else => try annotations.decorateMember(
+ self.gpa,
+ target,
+ index,
+ .{ .Offset = .{ .byte_offset = @enumToInt(member.offset) } },
+ ),
+ }
+
switch (d.matrix_layout) {
.row_major => try annotations.decorateMember(self.gpa, target, index, .RowMajor),
.col_major => try annotations.decorateMember(self.gpa, target, index, .ColMajor),