132 lines
5.2 KiB
Plaintext
132 lines
5.2 KiB
Plaintext
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
|
#pragma clang diagnostic ignored "-Wmissing-braces"
|
|
|
|
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
using namespace metal;
|
|
|
|
template<typename T, size_t Num>
|
|
struct spvUnsafeArray
|
|
{
|
|
T elements[Num ? Num : 1];
|
|
|
|
thread T& operator [] (size_t pos) thread
|
|
{
|
|
return elements[pos];
|
|
}
|
|
constexpr const thread T& operator [] (size_t pos) const thread
|
|
{
|
|
return elements[pos];
|
|
}
|
|
|
|
device T& operator [] (size_t pos) device
|
|
{
|
|
return elements[pos];
|
|
}
|
|
constexpr const device T& operator [] (size_t pos) const device
|
|
{
|
|
return elements[pos];
|
|
}
|
|
|
|
constexpr const constant T& operator [] (size_t pos) const constant
|
|
{
|
|
return elements[pos];
|
|
}
|
|
|
|
threadgroup T& operator [] (size_t pos) threadgroup
|
|
{
|
|
return elements[pos];
|
|
}
|
|
constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
|
|
{
|
|
return elements[pos];
|
|
}
|
|
};
|
|
|
|
struct Baz
|
|
{
|
|
int e;
|
|
int f;
|
|
};
|
|
|
|
struct Foo
|
|
{
|
|
int a;
|
|
int b;
|
|
};
|
|
|
|
struct Bar
|
|
{
|
|
int c;
|
|
int d;
|
|
};
|
|
|
|
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(3u, 3u, 2u);
|
|
|
|
struct spvDescriptorSetBuffer0
|
|
{
|
|
constant Foo* m_34 [[id(0)]];
|
|
constant Bar* m_40 [[id(1)]];
|
|
};
|
|
|
|
struct spvDescriptorSetBuffer1
|
|
{
|
|
spvUnsafeArray<device thread spvUnsafeArray<spvUnsafeArray<Baz, 3>, 2>*, 3>, 3>, 2> baz [[id(0)]];
|
|
};
|
|
|
|
kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], constant uint* spvDynamicOffsets [[buffer(23)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
|
|
{
|
|
constant auto& _34 = *(constant Foo* )((constant char* )spvDescriptorSet0.m_34 + spvDynamicOffsets[0]);
|
|
device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* baz =
|
|
{
|
|
{
|
|
{
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[0][0][0] + spvDynamicOffsets[1]),
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[0][0][1] + spvDynamicOffsets[2]),
|
|
},
|
|
{
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[0][1][0] + spvDynamicOffsets[3]),
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[0][1][1] + spvDynamicOffsets[4]),
|
|
},
|
|
{
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[0][2][0] + spvDynamicOffsets[5]),
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[0][2][1] + spvDynamicOffsets[6]),
|
|
},
|
|
},
|
|
{
|
|
{
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[1][0][0] + spvDynamicOffsets[7]),
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[1][0][1] + spvDynamicOffsets[8]),
|
|
},
|
|
{
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[1][1][0] + spvDynamicOffsets[9]),
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[1][1][1] + spvDynamicOffsets[10]),
|
|
},
|
|
{
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[1][2][0] + spvDynamicOffsets[11]),
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[1][2][1] + spvDynamicOffsets[12]),
|
|
},
|
|
},
|
|
{
|
|
{
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[2][0][0] + spvDynamicOffsets[13]),
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[2][0][1] + spvDynamicOffsets[14]),
|
|
},
|
|
{
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[2][1][0] + spvDynamicOffsets[15]),
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[2][1][1] + spvDynamicOffsets[16]),
|
|
},
|
|
{
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[2][2][0] + spvDynamicOffsets[17]),
|
|
(device spvUnsafeArray<spvUnsafeArray<spvUnsafeArray<Baz, 3>, 3>, 2>* )((device char* )spvDescriptorSet1.baz[2][2][1] + spvDynamicOffsets[18]),
|
|
},
|
|
},
|
|
};
|
|
|
|
uint3 coords = gl_GlobalInvocationID;
|
|
baz[coords.x][coords.y][coords.z]->e = _34.a + (*spvDescriptorSet0.m_40).c;
|
|
baz[coords.x][coords.y][coords.z]->f = _34.b * (*spvDescriptorSet0.m_40).d;
|
|
}
|
|
|