diff options
| author | Ali Cheraghi <alichraghi@proton.me> | 2025-08-03 17:02:51 +0330 |
|---|---|---|
| committer | Ali Cheraghi <alichraghi@proton.me> | 2025-08-04 07:05:00 +0330 |
| commit | cd4b03c5ed1bc5b48ad9c353679b309ead75551d (patch) | |
| tree | d1da1bcfac91d5ed55f977c7fae37dd947f92d49 /src/codegen/spirv/Module.zig | |
| parent | 246e1de55485b0b4e9392529778b8f50275e204a (diff) | |
| download | zig-cd4b03c5ed1bc5b48ad9c353679b309ead75551d.tar.gz zig-cd4b03c5ed1bc5b48ad9c353679b309ead75551d.zip | |
spirv: define and use extended instruction set opcodes
Diffstat (limited to 'src/codegen/spirv/Module.zig')
| -rw-r--r-- | src/codegen/spirv/Module.zig | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/codegen/spirv/Module.zig b/src/codegen/spirv/Module.zig index acdbf376da..8daac06222 100644 --- a/src/codegen/spirv/Module.zig +++ b/src/codegen/spirv/Module.zig @@ -125,9 +125,9 @@ pub const Decl = struct { /// - For `invocation_global`, this is the result-id of the associated InvocationGlobal instruction. result_id: Id, /// The offset of the first dependency of this decl in the `decl_deps` array. - begin_dep: u32, + begin_dep: usize = 0, /// The past-end offset of the dependencies of this decl in the `decl_deps` array. - end_dep: u32, + end_dep: usize = 0, }; /// This models a kernel entry point. @@ -258,7 +258,6 @@ pub fn resolveNav(module: *Module, ip: *InternPool, nav_index: InternPool.Nav.In .generic => .invocation_global, else => .global, }; - entry.value_ptr.* = try module.allocDecl(kind); } @@ -782,15 +781,15 @@ pub fn builtin( const gop = try module.cache.builtins.getOrPut(module.gpa, .{ spirv_builtin, storage_class }); if (!gop.found_existing) { const decl_index = try module.allocDecl(.global); - const result_id = module.declPtr(decl_index).result_id; + const decl = module.declPtr(decl_index); + gop.value_ptr.* = decl_index; try module.sections.globals.emit(module.gpa, .OpVariable, .{ .id_result_type = result_ty_id, - .id_result = result_id, + .id_result = decl.result_id, .storage_class = storage_class, }); - try module.decorate(result_id, .{ .built_in = .{ .built_in = spirv_builtin } }); - try module.declareDeclDeps(decl_index, &.{}); + try module.decorate(decl.result_id, .{ .built_in = .{ .built_in = spirv_builtin } }); } return gop.value_ptr.*; } @@ -847,8 +846,6 @@ pub fn allocDecl(module: *Module, kind: Decl.Kind) !Decl.Index { try module.decls.append(module.gpa, .{ .kind = kind, .result_id = module.allocId(), - .begin_dep = undefined, - .end_dep = undefined, }); return @as(Decl.Index, @enumFromInt(@as(u32, @intCast(module.decls.items.len - 1)))); @@ -858,17 +855,6 @@ pub fn declPtr(module: *Module, index: Decl.Index) *Decl { return &module.decls.items[@intFromEnum(index)]; } -/// Declare ALL dependencies for a decl. -pub fn declareDeclDeps(module: *Module, decl_index: Decl.Index, deps: []const Decl.Index) !void { - const begin_dep: u32 = @intCast(module.decl_deps.items.len); - try module.decl_deps.appendSlice(module.gpa, deps); - const end_dep: u32 = @intCast(module.decl_deps.items.len); - - const decl = module.declPtr(decl_index); - decl.begin_dep = begin_dep; - decl.end_dep = end_dep; -} - /// Declare a SPIR-V function as an entry point. This causes an extra wrapper /// function to be generated, which is then exported as the real entry point. The purpose of this /// wrapper is to allocate and initialize the structure holding the instance globals. |
