Debian Codegraph @

third_party/spirv-cross/reference/shaders-ue4/asm/frag/texture-atomics.asm.argument.msl2.frag

raw
1 #pragma clang diagnostic ignored "-Wmissing-prototypes"
2 #pragma clang diagnostic ignored "-Wmissing-braces"
3 #pragma clang diagnostic ignored "-Wunused-variable"
4
5 #include <metal_stdlib>
6 #include <simd/simd.h>
7 #include <metal_atomic>
8
9 using namespace metal;
10
11 template<typename T, size_t Num>
12 struct spvUnsafeArray
13 {
14 T elements[Num ? Num : 1];
15
16 thread T& operator [] (size_t pos) thread
17 {
18 return elements[pos];
19 }
20 constexpr const thread T& operator [] (size_t pos) const thread
21 {
22 return elements[pos];
23 }
24
25 device T& operator [] (size_t pos) device
26 {
27 return elements[pos];
28 }
29 constexpr const device T& operator [] (size_t pos) const device
30 {
31 return elements[pos];
32 }
33
34 constexpr const constant T& operator [] (size_t pos) const constant
35 {
36 return elements[pos];
37 }
38
39 threadgroup T& operator [] (size_t pos) threadgroup
40 {
41 return elements[pos];
42 }
43 constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
44 {
45 return elements[pos];
46 }
47 };
48
49 struct type_StructuredBuffer_v4float
50 {
51 float4 _m0[1];
52 };
53
54 struct type_Globals
55 {
56 uint2 ShadowTileListGroupSize;
57 };
58
59 struct spvDescriptorSetBuffer0
60 {
61 const device type_StructuredBuffer_v4float* CulledObjectBoxBounds [[id(0)]];
62 constant type_Globals* _Globals [[id(1)]];
63 texture2d<uint> RWShadowTileNumCulledObjects [[id(2)]];
64 device atomic_uint* RWShadowTileNumCulledObjects_atomic [[id(3)]];
65 };
66
67 constant float3 _70 = {};
68
69 struct main0_out
70 {
71 float4 out_var_SV_Target0 [[color(0)]];
72 };
73
74 struct main0_in
75 {
76 uint in_var_TEXCOORD0 [[user(locn0)]];
77 };
78
79 fragment main0_out main0(main0_in in [[stage_in]], constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], float4 gl_FragCoord [[position]])
80 {
81 main0_out out = {};
82 uint2 _77 = uint2(gl_FragCoord.xy);
83 uint _78 = _77.y;
84 uint _83 = _77.x;
85 float2 _91 = float2(float(_83), float(((*spvDescriptorSet0._Globals).ShadowTileListGroupSize.y - 1u) - _78));
86 float2 _93 = float2((*spvDescriptorSet0._Globals).ShadowTileListGroupSize);
87 float2 _96 = ((_91 / _93) * float2(2.0)) - float2(1.0);
88 float2 _100 = (((_91 + float2(1.0)) / _93) * float2(2.0)) - float2(1.0);
89 float3 _102 = float3(_100.x, _100.y, _70.z);
90 _102.z = 1.0;
91 uint _103 = in.in_var_TEXCOORD0 * 5u;
92 uint _107 = _103 + 1u;
93 if (all((*spvDescriptorSet0.CulledObjectBoxBounds)._m0[_107].xy > _96.xy) && all((*spvDescriptorSet0.CulledObjectBoxBounds)._m0[_103].xyz < _102))
94 {
95 float3 _121 = float3(0.5) * ((*spvDescriptorSet0.CulledObjectBoxBounds)._m0[_103].xyz + (*spvDescriptorSet0.CulledObjectBoxBounds)._m0[_107].xyz);
96 float _122 = _96.x;
97 float _123 = _96.y;
98 spvUnsafeArray<float3, 8> _73;
99 _73[0] = float3(_122, _123, -1000.0);
100 float _126 = _100.x;
101 _73[1] = float3(_126, _123, -1000.0);
102 float _129 = _100.y;
103 _73[2] = float3(_122, _129, -1000.0);
104 _73[3] = float3(_126, _129, -1000.0);
105 _73[4] = float3(_122, _123, 1.0);
106 _73[5] = float3(_126, _123, 1.0);
107 _73[6] = float3(_122, _129, 1.0);
108 _73[7] = float3(_126, _129, 1.0);
109 float3 _155;
110 float3 _158;
111 _155 = float3(-500000.0);
112 _158 = float3(500000.0);
113 for (int _160 = 0; _160 < 8; )
114 {
115 float3 _166 = _73[_160] - _121;
116 float3 _170 = float3(dot(_166, (*spvDescriptorSet0.CulledObjectBoxBounds)._m0[_103 + 2u].xyz), dot(_166, (*spvDescriptorSet0.CulledObjectBoxBounds)._m0[_103 + 3u].xyz), dot(_166, (*spvDescriptorSet0.CulledObjectBoxBounds)._m0[_103 + 4u].xyz));
117 _155 = fast::max(_155, _170);
118 _158 = fast::min(_158, _170);
119 _160++;
120 continue;
121 }
122 if (all(_158 < float3(1.0)) && all(_155 > float3(-1.0)))
123 {
124 uint _179 = atomic_fetch_add_explicit((device atomic_uint*)&spvDescriptorSet0.RWShadowTileNumCulledObjects_atomic[(_78 * (*spvDescriptorSet0._Globals).ShadowTileListGroupSize.x) + _83], 1u, memory_order_relaxed);
125 }
126 }
127 out.out_var_SV_Target0 = float4(0.0);
128 return out;
129 }
130