| 1 |
#pragma clang diagnostic ignored "-Wmissing-prototypes" |
| 2 |
#pragma clang diagnostic ignored "-Wmissing-braces" |
| 3 |
|
| 4 |
#include <metal_stdlib> |
| 5 |
#include <simd/simd.h> |
| 6 |
|
| 7 |
using namespace metal; |
| 8 |
|
| 9 |
template<typename T, size_t Num> |
| 10 |
struct spvUnsafeArray |
| 11 |
{ |
| 12 |
T elements[Num ? Num : 1]; |
| 13 |
|
| 14 |
thread T& operator [] (size_t pos) thread |
| 15 |
{ |
| 16 |
return elements[pos]; |
| 17 |
} |
| 18 |
constexpr const thread T& operator [] (size_t pos) const thread |
| 19 |
{ |
| 20 |
return elements[pos]; |
| 21 |
} |
| 22 |
|
| 23 |
device T& operator [] (size_t pos) device |
| 24 |
{ |
| 25 |
return elements[pos]; |
| 26 |
} |
| 27 |
constexpr const device T& operator [] (size_t pos) const device |
| 28 |
{ |
| 29 |
return elements[pos]; |
| 30 |
} |
| 31 |
|
| 32 |
constexpr const constant T& operator [] (size_t pos) const constant |
| 33 |
{ |
| 34 |
return elements[pos]; |
| 35 |
} |
| 36 |
|
| 37 |
threadgroup T& operator [] (size_t pos) threadgroup |
| 38 |
{ |
| 39 |
return elements[pos]; |
| 40 |
} |
| 41 |
constexpr const threadgroup T& operator [] (size_t pos) const threadgroup |
| 42 |
{ |
| 43 |
return elements[pos]; |
| 44 |
} |
| 45 |
}; |
| 46 |
|
| 47 |
struct M0 |
| 48 |
{ |
| 49 |
long v; |
| 50 |
spvUnsafeArray<long2, 2> b; |
| 51 |
ulong c; |
| 52 |
spvUnsafeArray<ulong, 5> d; |
| 53 |
}; |
| 54 |
|
| 55 |
struct SSBO0_Type |
| 56 |
{ |
| 57 |
long4 a; |
| 58 |
M0 m0; |
| 59 |
}; |
| 60 |
|
| 61 |
struct SSBO1_Type |
| 62 |
{ |
| 63 |
ulong4 b; |
| 64 |
M0 m0; |
| 65 |
}; |
| 66 |
|
| 67 |
struct SSBO2_Type |
| 68 |
{ |
| 69 |
spvUnsafeArray<long, 4> a; |
| 70 |
spvUnsafeArray<long2, 4> b; |
| 71 |
}; |
| 72 |
|
| 73 |
struct SSBO3_Type |
| 74 |
{ |
| 75 |
spvUnsafeArray<long, 4> a; |
| 76 |
spvUnsafeArray<long2, 4> b; |
| 77 |
}; |
| 78 |
|
| 79 |
struct SSBO |
| 80 |
{ |
| 81 |
int s32; |
| 82 |
uint u32; |
| 83 |
}; |
| 84 |
|
| 85 |
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); |
| 86 |
|
| 87 |
kernel void main0(device SSBO& _96 [[buffer(0)]]) |
| 88 |
{ |
| 89 |
SSBO0_Type ssbo_0; |
| 90 |
ssbo_0.a += long4(10l, 20l, 30l, 40l); |
| 91 |
SSBO1_Type ssbo_1; |
| 92 |
ssbo_1.b += ulong4(999999999999999999ul, 8888888888888888ul, 77777777777777777ul, 6666666666666666ul); |
| 93 |
ssbo_0.a += long4(20l); |
| 94 |
ssbo_0.a = abs(ssbo_0.a + long4(ssbo_1.b)); |
| 95 |
ssbo_0.a += long4(1l); |
| 96 |
ssbo_1.b += ulong4(long4(1l)); |
| 97 |
ssbo_0.a -= long4(1l); |
| 98 |
ssbo_1.b -= ulong4(long4(1l)); |
| 99 |
SSBO2_Type ssbo_2; |
| 100 |
ssbo_2.a[0] += 1l; |
| 101 |
SSBO3_Type ssbo_3; |
| 102 |
ssbo_3.a[0] += 2l; |
| 103 |
_96.s32 = int(uint(((ulong(ssbo_0.a.x) + ssbo_1.b.y) + ulong(ssbo_2.a[1])) + ulong(ssbo_3.a[2]))); |
| 104 |
_96.u32 = uint(((ulong(ssbo_0.a.y) + ssbo_1.b.z) + ulong(ssbo_2.a[0])) + ulong(ssbo_3.a[1])); |
| 105 |
} |
| 106 |
|