SPIRV-Cross/reference/opt/shaders-msl/comp/shared-struct-bool-cast.comp
Chip Davis faea931de3 MSL: Also replace bool with short in structures.
Since `bool` is a logical type, it cannot be used in uniform or storage
buffers. Therefore, replacing it in structures should not change the
shader interface.

We leave it alone for builtins. (FIXME: Should we also leave it for
I/O varyings?)

Fixes 24 CTS tests under `dEQP-VK.memory_model.shared`.
2022-08-05 11:43:21 -07:00

64 lines
1.0 KiB
Plaintext

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct S1
{
int3 a;
uint2 b;
short4 c;
uint d;
};
struct block
{
uint passed;
};
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);
kernel void main0(device block& _132 [[buffer(0)]])
{
threadgroup S1 s1;
s1.a = int3(6, 8, 8);
s1.b = uint2(4u);
s1.c = short4(bool4(false, false, false, true));
s1.d = 6u;
threadgroup_barrier(mem_flags::mem_threadgroup);
threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
bool _144 = all(int3(6, 8, 8) == s1.a);
bool _108;
if (_144)
{
_108 = all(uint2(4u) == s1.b);
}
else
{
_108 = _144;
}
bool _117;
if (_108)
{
_117 = all(bool4(false, false, false, true) == bool4(s1.c));
}
else
{
_117 = _108;
}
bool _126;
if (_117)
{
_126 = 6u == s1.d;
}
else
{
_126 = _117;
}
if (_126)
{
_132.passed++;
}
}