Debian Codegraph @

third_party/spirv-cross/reference/shaders-ue4/asm/frag/texture-atomics.asm.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 constant float3 _70 = {};
60
61 struct main0_out
62 {
63 float4 out_var_SV_Target0 [[color(0)]];
64 };
65
66 struct main0_in
67 {
68 uint in_var_TEXCOORD0 [[user(locn0)]];
69 };
70
71 fragment main0_out main0(main0_in in [[stage_in]], const device type_StructuredBuffer_v4float& CulledObjectBoxBounds [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], texture2d<uint> RWShadowTileNumCulledObjects [[texture(0)]], device atomic_uint* RWShadowTileNumCulledObjects_atomic [[buffer(2)]], float4 gl_FragCoord [[position]])
72 {
73 main0_out out = {};
74 uint2 _77 = uint2(gl_FragCoord.xy);
75 uint _78 = _77.y;
76 uint _83 = _77.x;
77 float2 _91 = float2(float(_83), float((_Globals.ShadowTileListGroupSize.y - 1u) - _78));
78 float2 _93 = float2(_Globals.ShadowTileListGroupSize);
79 float2 _96 = ((_91 / _93) * float2(2.0)) - float2(1.0);
80 float2 _100 = (((_91 + float2(1.0)) / _93) * float2(2.0)) - float2(1.0);
81 float3 _102 = float3(_100.x, _100.y, _70.z);
82 _102.z = 1.0;
83 uint _103 = in.in_var_TEXCOORD0 * 5u;
84 uint _107 = _103 + 1u;
85 if (all(CulledObjectBoxBounds._m0[_107].xy > _96.xy) && all(CulledObjectBoxBounds._m0[_103].xyz < _102))
86 {
87 float3 _121 = float3(0.5) * (CulledObjectBoxBounds._m0[_103].xyz + CulledObjectBoxBounds._m0[_107].xyz);
88 float _122 = _96.x;
89 float _123 = _96.y;
90 spvUnsafeArray<float3, 8> _73;
91 _73[0] = float3(_122, _123, -1000.0);
92 float _126 = _100.x;
93 _73[1] = float3(_126, _123, -1000.0);
94 float _129 = _100.y;
95 _73[2] = float3(_122, _129, -1000.0);
96 _73[3] = float3(_126, _129, -1000.0);
97 _73[4] = float3(_122, _123, 1.0);
98 _73[5] = float3(_126, _123, 1.0);
99 _73[6] = float3(_122, _129, 1.0);
100 _73[7] = float3(_126, _129, 1.0);
101 float3 _155;
102 float3 _158;
103 _155 = float3(-500000.0);
104 _158 = float3(500000.0);
105 for (int _160 = 0; _160 < 8; )
106 {
107 float3 _166 = _73[_160] - _121;
108 float3 _170 = float3(dot(_166, CulledObjectBoxBounds._m0[_103 + 2u].xyz), dot(_166, CulledObjectBoxBounds._m0[_103 + 3u].xyz), dot(_166, CulledObjectBoxBounds._m0[_103 + 4u].xyz));
109 _155 = fast::max(_155, _170);
110 _158 = fast::min(_158, _170);
111 _160++;
112 continue;
113 }
114 if (all(_158 < float3(1.0)) && all(_155 > float3(-1.0)))
115 {
116 uint _179 = atomic_fetch_add_explicit((device atomic_uint*)&RWShadowTileNumCulledObjects_atomic[(_78 * _Globals.ShadowTileListGroupSize.x) + _83], 1u, memory_order_relaxed);
117 }
118 }
119 out.out_var_SV_Target0 = float4(0.0);
120 return out;
121 }
122