From 89bd987f1c5f9aed8c7d0f851eae93c7cbf1d70b Mon Sep 17 00:00:00 2001 From: Robin Voetter Date: Sat, 2 Nov 2024 18:58:21 +0100 Subject: [PATCH] spirv: emit ArrayStride for many-item pointers --- src/codegen/spirv.zig | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index 3c4037abc7..e305b7ec92 100644 --- 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;