Debian Codegraph @

third_party/spirv-cross/reference/opt/shaders-msl/comp/image-atomic-automatic-bindings.argument.msl2.comp

raw
1 #pragma clang diagnostic ignored "-Wmissing-prototypes"
2 #pragma clang diagnostic ignored "-Wunused-variable"
3
4 #include <metal_stdlib>
5 #include <simd/simd.h>
6 #include <metal_atomic>
7
8 using namespace metal;
9
10 struct SSBO
11 {
12 float4 outdata;
13 };
14
15 constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);
16
17 struct spvDescriptorSetBuffer0
18 {
19 texture2d<uint> uImage [[id(0)]];
20 device atomic_uint* uImage_atomic [[id(1)]];
21 device SSBO* m_31 [[id(2)]];
22 texture2d<float> uTexture [[id(3)]];
23 sampler uTextureSmplr [[id(4)]];
24 };
25
26 // The required alignment of a linear texture of R32Uint format.
27 constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]];
28 constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4;
29 // Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics
30 #define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x)
31
32 kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
33 {
34 uint _26 = atomic_fetch_add_explicit((device atomic_uint*)&spvDescriptorSet0.uImage_atomic[spvImage2DAtomicCoord(int2(gl_GlobalInvocationID.xy), spvDescriptorSet0.uImage)], 10u, memory_order_relaxed);
35 (*spvDescriptorSet0.m_31).outdata = spvDescriptorSet0.uTexture.sample(spvDescriptorSet0.uTextureSmplr, float2(gl_GlobalInvocationID.xy), level(0.0)) + float4(float(_26));
36 }
37