authorgravatar for alichraghi@proton.meAli Chraghi <alichraghi@proton.me> 2026-06-21 21:46:32+03:30
committergravatar for alichraghi@noreply.codeberg.orgAli Cheraghi <alichraghi@noreply.codeberg.org> 2026-06-25 15:47:10+02:00
log3c857583fccf9e88ddad934b136d1283c1ea1dab
treeb367751c4cbcea0054c962f0f93636e9adfc4338
parentfcb9d475a1f1db7ac11038766fedc67c21949d8c

spirv: fix `@SpirvType` opaque externs lowered as `OpUndef`


1 files changed, 10 insertions(+), 3 deletions(-)

src/codegen/spirv/CodeGen.zig+10-3
......@@ -725,7 +725,10 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
725725 const val = zcu.navValue(cg.owner_nav);
726726 const ty = val.typeOf(zcu);
727727
728 if (!do_codegen and !ty.hasRuntimeBits(zcu)) return;
728 if (!do_codegen and !ty.hasRuntimeBits(zcu)) {
729 const child_ty = if (ty.zigTypeTag(zcu) == .pointer) ty.childType(zcu) else ty;
730 if (child_ty.zigTypeTag(zcu) != .spirv) return;
731 }
729732
730733 const spv_decl_index = try cg.resolveNav(ip, cg.owner_nav);
731734 const decl = cg.declPtr(spv_decl_index);
......@@ -1800,7 +1803,9 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id {
18001803 },
18011804 }
18021805
1803 if (!nav_ty.hasRuntimeBits(zcu)) return cg.constUndef(ty_id);
1806 if (!nav_ty.hasRuntimeBits(zcu) and nav_ty.zigTypeTag(zcu) != .spirv) {
1807 return cg.constUndef(ty_id);
1808 }
18041809
18051810 const spv_decl_index = try cg.resolveNav(ip, nav_index);
18061811 const spv_decl = cg.declPtr(spv_decl_index);
......@@ -1835,7 +1840,9 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id {
18351840 else => {},
18361841 }
18371842
1838 if (!uav_ty.hasRuntimeBits(zcu)) return cg.constUndef(ty_id);
1843 if (!uav_ty.hasRuntimeBits(zcu) and uav_ty.zigTypeTag(zcu) != .spirv) {
1844 return cg.constUndef(ty_id);
1845 }
18391846
18401847 // Uav refs are always generic.
18411848 assert(result_ptr_ty.ptrAddressSpace(zcu) == .generic);