SPIRV-Cross/reference/opt/shaders-msl/comp/threadgroup-boolean-workaround.comp
Hans-Kristian Arntzen edf247fb1c MSL: Workaround compiler crashes when using threadgroup bool.
Promote to short instead and do simple casts on load/store instead.

Not 100% complete fix since structs can contain booleans, but this is
getting into pretty ridiculously complicated territory.
2021-10-25 10:55:11 +02:00

21 lines
725 B
Plaintext

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct SSBO
{
float4 values[1];
};
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(4u, 1u, 1u);
kernel void main0(device SSBO& _23 [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
threadgroup short4 foo[4];
foo[gl_LocalInvocationIndex] = short4((isunordered(_23.values[gl_GlobalInvocationID.x], float4(10.0)) || _23.values[gl_GlobalInvocationID.x] != float4(10.0)));
threadgroup_barrier(mem_flags::mem_threadgroup);
_23.values[gl_GlobalInvocationID.x] = select(float4(40.0), float4(30.0), bool4(foo[gl_LocalInvocationIndex ^ 3u]));
}