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 {...@@ -725,7 +725,10 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
725 const val = zcu.navValue(cg.owner_nav);725 const val = zcu.navValue(cg.owner_nav);
726 const ty = val.typeOf(zcu);726 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
730 const spv_decl_index = try cg.resolveNav(ip, cg.owner_nav);733 const spv_decl_index = try cg.resolveNav(ip, cg.owner_nav);
731 const decl = cg.declPtr(spv_decl_index);734 const decl = cg.declPtr(spv_decl_index);
...@@ -1800,7 +1803,9 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id {...@@ -1800,7 +1803,9 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id {
1800 },1803 },
1801 }1804 }
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
1805 const spv_decl_index = try cg.resolveNav(ip, nav_index);1810 const spv_decl_index = try cg.resolveNav(ip, nav_index);
1806 const spv_decl = cg.declPtr(spv_decl_index);1811 const spv_decl = cg.declPtr(spv_decl_index);
...@@ -1835,7 +1840,9 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id {...@@ -1835,7 +1840,9 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id {
1835 else => {},1840 else => {},
1836 }1841 }
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
1840 // Uav refs are always generic.1847 // Uav refs are always generic.
1841 assert(result_ptr_ty.ptrAddressSpace(zcu) == .generic);1848 assert(result_ptr_ty.ptrAddressSpace(zcu) == .generic);