SPIRV-Cross/reference/shaders-msl/comp/spec-constant-work-group-size.comp

92 lines
2.4 KiB
Plaintext

#pragma clang diagnostic ignored "-Wmissing-braces"
#pragma clang diagnostic ignored "-Wunused-variable"
#include <metal_stdlib>
#include <simd/simd.h>
template <typename T, size_t Num>
struct unsafe_array
{
T __Elements[Num ? Num : 1];
constexpr size_t size() const thread { return Num; }
constexpr size_t max_size() const thread { return Num; }
constexpr bool empty() const thread { return Num == 0; }
constexpr size_t size() const device { return Num; }
constexpr size_t max_size() const device { return Num; }
constexpr bool empty() const device { return Num == 0; }
constexpr size_t size() const constant { return Num; }
constexpr size_t max_size() const constant { return Num; }
constexpr bool empty() const constant { return Num == 0; }
constexpr size_t size() const threadgroup { return Num; }
constexpr size_t max_size() const threadgroup { return Num; }
constexpr bool empty() const threadgroup { return Num == 0; }
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];
}
};
using namespace metal;
#ifndef SPIRV_CROSS_CONSTANT_ID_1
#define SPIRV_CROSS_CONSTANT_ID_1 2
#endif
constant int b = SPIRV_CROSS_CONSTANT_ID_1;
constant int a_tmp [[function_constant(0)]];
constant int a = is_function_constant_defined(a_tmp) ? a_tmp : 1;
struct SSBO
{
unsafe_array<int,1> v;
};
constant uint _21 = (uint(a) + 0u);
constant uint _22_tmp [[function_constant(10)]];
constant uint _22 = is_function_constant_defined(_22_tmp) ? _22_tmp : 1u;
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(_22, 20u, 1u);
constant uint _27 = gl_WorkGroupSize.x;
constant uint _28 = (_21 + _27);
constant uint _29 = gl_WorkGroupSize.y;
constant uint _30 = (_28 + _29);
constant int _32 = (1 - a);
kernel void main0(device SSBO& _17 [[buffer(0)]])
{
unsafe_array<int,b> spec_const_array_size;
spec_const_array_size[a] = a;
_17.v[_30] = b + spec_const_array_size[_32];
}