SPIRV-Cross/reference/shaders-msl/comp/buffer_device_address-recursive-struct-pointers.msl2.comp
Bill Hollings 52c7c2dab6 MSL: Add support for SPV_KHR_physical_storage_buffer extension.
- Determine sizing and alignments of pointers to types as
  distinct from the size and alignment of the types themselves.
- Declare all buffer pointers in the MSL device address space.
- Support struct pointer recursion, where structs can
  contain pointers to themselves or to a parent struct.
- Add SPIRType::was_forward_referenced to track if a type was forward
  referenced, to help emit MSL structs in the correct dependency order.
- Handle pointers to pointers that are not just arrays of arrays.
2022-06-20 20:21:00 -04:00

66 lines
1.8 KiB
Plaintext

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct t21
{
int4 m0[2];
int m1;
device t21* m2[2];
device t21* m3;
float2x4 m4;
};
struct t24
{
int4 m0[2];
int m1;
device t21* m2[2];
device t21* m3;
float2x4 m4;
};
struct t35
{
int m0[32];
};
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);
kernel void main0(constant t24& u24 [[buffer(0)]], constant t35& u35 [[buffer(1)]], texture2d<uint, access::write> v295 [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
int v8 = 0;
v8 |= (u24.m0[0].x - 0);
v8 |= (u24.m0[u35.m0[1]].x - 1);
v8 |= (u24.m1 - 2);
v8 |= int(u24.m4[0u][0] - 3.0);
v8 |= int(u24.m4[1u][0] - 5.0);
v8 |= int(u24.m4[0u][1] - 4.0);
v8 |= int(u24.m4[1u][1] - 6.0);
v8 |= (u24.m2[0]->m0[0].x - 3);
v8 |= (u24.m2[0]->m0[u35.m0[1]].x - 4);
v8 |= (u24.m2[0]->m1 - 5);
v8 |= int(u24.m2[0]->m4[0u][0] - 6.0);
v8 |= int(u24.m2[0]->m4[1u][0] - 8.0);
v8 |= int(u24.m2[0]->m4[0u][1] - 7.0);
v8 |= int(u24.m2[0]->m4[1u][1] - 9.0);
v8 |= (u24.m2[u35.m0[1]]->m0[0].x - 6);
v8 |= (u24.m2[u35.m0[1]]->m0[u35.m0[1]].x - 7);
v8 |= (u24.m2[u35.m0[1]]->m1 - 8);
v8 |= int(u24.m2[u35.m0[1]]->m4[0u][0] - 9.0);
v8 |= int(u24.m2[u35.m0[1]]->m4[1u][0] - 11.0);
v8 |= int(u24.m2[u35.m0[1]]->m4[0u][1] - 10.0);
v8 |= int(u24.m2[u35.m0[1]]->m4[1u][1] - 12.0);
v8 |= (u24.m3->m0[0].x - 9);
v8 |= (u24.m3->m0[u35.m0[1]].x - 10);
v8 |= (u24.m3->m1 - 11);
v8 |= int(u24.m3->m4[0u][0] - 12.0);
v8 |= int(u24.m3->m4[1u][0] - 14.0);
v8 |= int(u24.m3->m4[0u][1] - 13.0);
v8 |= int(u24.m3->m4[1u][1] - 15.0);
uint4 v284 = select(uint4(1u, 0u, 0u, 1u), uint4(0u), bool4(v8 != 0));
v295.write(v284, uint2(int2(gl_GlobalInvocationID.xy)));
}