zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 89bd987f1c5f9aed8c7d0f851eae93c7cbf1d70b (tree)
parent b16252b17eced52f73007a1b28dafb2857054ca4
Author: Robin Voetter <robin@voetter.nl>
Date:   Sat,  2 Nov 2024 18:58:21 +0100

spirv: emit ArrayStride for many-item pointers

Diffstat:
Msrc/codegen/spirv.zig | 15+++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig @@ -1639,7 +1639,11 @@ const NavGen = struct { return try self.arrayType(1, elem_ty_id); } else { const result_id = try self.arrayType(total_len, elem_ty_id); - try self.spv.decorate(result_id, .{ .ArrayStride = .{ .array_stride = @intCast(elem_ty.abiSize(zcu)) } }); + if (target.os.tag == .vulkan) { + try self.spv.decorate(result_id, .{ .ArrayStride = .{ + .array_stride = @intCast(elem_ty.abiSize(zcu)), + } }); + } return result_id; } }, @@ -1694,8 +1698,15 @@ const NavGen = struct { .pointer => { const ptr_info = ty.ptrInfo(zcu); + const child_ty = Type.fromInterned(ptr_info.child); const storage_class = self.spvStorageClass(ptr_info.flags.address_space); - const ptr_ty_id = try self.ptrType(Type.fromInterned(ptr_info.child), storage_class); + const ptr_ty_id = try self.ptrType(child_ty, storage_class); + + if (target.os.tag == .vulkan and ptr_info.flags.size == .Many) { + try self.spv.decorate(ptr_ty_id, .{ .ArrayStride = .{ + .array_stride = @intCast(child_ty.abiSize(zcu)), + } }); + } if (ptr_info.flags.size != .Slice) { return ptr_ty_id;