authorgravatar for alichraghi@proton.meAli Chraghi <alichraghi@proton.me> 2025-08-15 19:36:15+03:30
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-08-18 11:24:57-07:00
log2f422372b588789a5ce208bb85c9bfeee84dd980
treed9845ab3cb8b59ecd05cf7c75aa44b9b2b5c4cde
parentcf90a5e451fc170738966a0a1a06c2dd5cddc066

spirv: do not decorate nav alignment

they seem to be always `null` even when accessed through extern key so we have no way to tell whether they have natural alignment or not to decorate. And the reason we don't always decorate them is because some environments might be too dumb and crash for this.

1 files changed, 1 insertions(+), 14 deletions(-)

src/codegen/spirv/CodeGen.zig+1-14
......@@ -254,13 +254,7 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
254254 try cg.module.debugName(func_result_id, nav.fqn.toSlice(ip));
255255 },
256256 .global => {
257 const maybe_init_val: ?Value = switch (ip.indexToKey(val.toIntern())) {
258 .func => unreachable,
259 .variable => |variable| .fromInterned(variable.init),
260 .@"extern" => null,
261 else => val,
262 };
263 assert(maybe_init_val == null); // TODO
257 assert(ip.indexToKey(val.toIntern()) == .@"extern");
264258
265259 const storage_class = cg.module.storageClass(nav.getAddrspace());
266260 assert(storage_class != .generic); // These should be instance globals
......@@ -274,13 +268,6 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
274268 .storage_class = storage_class,
275269 });
276270
277 if (nav.getAlignment() != ty.abiAlignment(zcu)) {
278 if (target.os.tag != .opencl) return cg.fail("cannot apply alignment to variables", .{});
279 try cg.module.decorate(result_id, .{
280 .alignment = .{ .alignment = @intCast(nav.getAlignment().toByteUnits().?) },
281 });
282 }
283
284271 switch (target.os.tag) {
285272 .vulkan, .opengl => {
286273 if (ty.zigTypeTag(zcu) == .@"struct") {