authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2024-11-02 18:58:21+01:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2024-11-08 20:43:57+01:00
log89bd987f1c5f9aed8c7d0f851eae93c7cbf1d70b
tree6634a8320c3288b3e354280e86534da47d875c33
parentb16252b17eced52f73007a1b28dafb2857054ca4
signaturebadge-check Signed by SSH key SHA256:ZS52FNyUv2WUXvO4njmVaFVO46RHojFuOrxRc4LuKzg

spirv: emit ArrayStride for many-item pointers


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

src/codegen/spirv.zig+13-2
...@@ -1639,7 +1639,11 @@ const NavGen = struct {...@@ -1639,7 +1639,11 @@ const NavGen = struct {
1639 return try self.arrayType(1, elem_ty_id);1639 return try self.arrayType(1, elem_ty_id);
1640 } else {1640 } else {
1641 const result_id = try self.arrayType(total_len, elem_ty_id);1641 const result_id = try self.arrayType(total_len, elem_ty_id);
1642 try self.spv.decorate(result_id, .{ .ArrayStride = .{ .array_stride = @intCast(elem_ty.abiSize(zcu)) } });1642 if (target.os.tag == .vulkan) {
1643 try self.spv.decorate(result_id, .{ .ArrayStride = .{
1644 .array_stride = @intCast(elem_ty.abiSize(zcu)),
1645 } });
1646 }
1643 return result_id;1647 return result_id;
1644 }1648 }
1645 },1649 },
...@@ -1694,8 +1698,15 @@ const NavGen = struct {...@@ -1694,8 +1698,15 @@ const NavGen = struct {
1694 .pointer => {1698 .pointer => {
1695 const ptr_info = ty.ptrInfo(zcu);1699 const ptr_info = ty.ptrInfo(zcu);
16961700
1701 const child_ty = Type.fromInterned(ptr_info.child);
1697 const storage_class = self.spvStorageClass(ptr_info.flags.address_space);1702 const storage_class = self.spvStorageClass(ptr_info.flags.address_space);
1698 const ptr_ty_id = try self.ptrType(Type.fromInterned(ptr_info.child), storage_class);1703 const ptr_ty_id = try self.ptrType(child_ty, storage_class);
1704
1705 if (target.os.tag == .vulkan and ptr_info.flags.size == .Many) {
1706 try self.spv.decorate(ptr_ty_id, .{ .ArrayStride = .{
1707 .array_stride = @intCast(child_ty.abiSize(zcu)),
1708 } });
1709 }
16991710
1700 if (ptr_info.flags.size != .Slice) {1711 if (ptr_info.flags.size != .Slice) {
1701 return ptr_ty_id;1712 return ptr_ty_id;