authorgravatar for alichraghi@proton.meAli Chraghi <alichraghi@proton.me> 2026-06-28 14:04:56+03:30
committergravatar for alichraghi@noreply.codeberg.orgAli Cheraghi <alichraghi@noreply.codeberg.org> 2026-06-28 18:25:43+02:00
logce07ba754c877ae376b002e5bd6aad238d9f3d3d
tree1ec919f480293266fc55f145c5a6e03af625ff6f
parent56827cf78f37b6d2ec0a95d385fd4b7bed4866ea

spirv: fix vector pointer access


1 files changed, 2 insertions(+), 11 deletions(-)

src/codegen/spirv/CodeGen.zig+2-11
...@@ -1881,17 +1881,8 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id {...@@ -1881,17 +1881,8 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id {
1881 const parent_ptr_ty = try oac.parent.ptrType(pt);1881 const parent_ptr_ty = try oac.parent.ptrType(pt);
1882 const result_ty_id = try cg.resolveType(oac.new_ptr_ty, .direct);1882 const result_ty_id = try cg.resolveType(oac.new_ptr_ty, .direct);
18831883
1884 if (parent_ptr_ty.childType(zcu).isVector(zcu)) {1884 if (oac.new_ptr_ty.ptrInfo(zcu).flags.vector_index != .none) {
1885 // Vector element ptr accesses are derived as offset_and_cast.1885 return parent_ptr_id;
1886 // We can just use OpAccessChain.
1887 const child_size = oac.new_ptr_ty.childType(zcu).abiSize(zcu);
1888 if (oac.byte_offset % child_size == 0) {
1889 return cg.accessChain(
1890 result_ty_id,
1891 parent_ptr_id,
1892 &.{@intCast(@divExact(oac.byte_offset, child_size))},
1893 );
1894 }
1895 }1886 }
18961887
1897 if (oac.byte_offset == 0) {1888 if (oac.byte_offset == 0) {