| 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 |
#ifndef SPIRV_CROSS_CONSTANT_ID_1 |
| 48 |
#define SPIRV_CROSS_CONSTANT_ID_1 2 |
| 49 |
#endif |
| 50 |
constant int b = SPIRV_CROSS_CONSTANT_ID_1; |
| 51 |
constant int a_tmp [[function_constant(0)]]; |
| 52 |
constant int a = is_function_constant_defined(a_tmp) ? a_tmp : 1; |
| 53 |
|
| 54 |
struct SSBO |
| 55 |
{ |
| 56 |
int v[1]; |
| 57 |
}; |
| 58 |
|
| 59 |
constant uint _21 = (uint(a) + 0u); |
| 60 |
constant uint _22_tmp [[function_constant(10)]]; |
| 61 |
constant uint _22 = is_function_constant_defined(_22_tmp) ? _22_tmp : 1u; |
| 62 |
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(_22, 20u, 1u); |
| 63 |
constant uint _27 = gl_WorkGroupSize.x; |
| 64 |
constant uint _28 = (_21 + _27); |
| 65 |
constant uint _29 = gl_WorkGroupSize.y; |
| 66 |
constant uint _30 = (_28 + _29); |
| 67 |
constant int _32 = (1 - a); |
| 68 |
|
| 69 |
kernel void main0(device SSBO& _17 [[buffer(0)]]) |
| 70 |
{ |
| 71 |
spvUnsafeArray<int, b> spec_const_array_size; |
| 72 |
spec_const_array_size[a] = a; |
| 73 |
_17.v[_30] = b + spec_const_array_size[_32]; |
| 74 |
} |
| 75 |
|