Debian Codegraph @

third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-fixed-input-array-builtin-array.invalid.multi-patch.asm.tesc

raw
1 #pragma clang diagnostic ignored "-Wmissing-prototypes"
2 #pragma clang diagnostic ignored "-Wmissing-braces"
3
4 #include <metal_stdlib>
5 #include <simd/simd.h>
6
7 using namespace metal;
8
9 template<typename T, size_t Num>
10 struct spvUnsafeArray
11 {
12 T elements[Num ? Num : 1];
13
14 thread T& operator [] (size_t pos) thread
15 {
16 return elements[pos];
17 }
18 constexpr const thread T& operator [] (size_t pos) const thread
19 {
20 return elements[pos];
21 }
22
23 device T& operator [] (size_t pos) device
24 {
25 return elements[pos];
26 }
27 constexpr const device T& operator [] (size_t pos) const device
28 {
29 return elements[pos];
30 }
31
32 constexpr const constant T& operator [] (size_t pos) const constant
33 {
34 return elements[pos];
35 }
36
37 threadgroup T& operator [] (size_t pos) threadgroup
38 {
39 return elements[pos];
40 }
41 constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
42 {
43 return elements[pos];
44 }
45 };
46
47 struct VertexOutput
48 {
49 float4 pos;
50 float2 uv;
51 };
52
53 struct HSOut
54 {
55 float4 pos;
56 float2 uv;
57 };
58
59 struct HSConstantOut
60 {
61 spvUnsafeArray<float, 3> EdgeTess;
62 float InsideTess;
63 };
64
65 struct VertexOutput_1
66 {
67 float3 uv;
68 };
69
70 struct HSOut_1
71 {
72 float2 uv;
73 };
74
75 struct main0_out
76 {
77 HSOut_1 _entryPointOutput;
78 float4 gl_Position;
79 };
80
81 struct main0_in
82 {
83 float3 VertexOutput_uv;
84 ushort2 m_172;
85 float4 gl_Position;
86 };
87
88 static inline __attribute__((always_inline))
89 HSOut _hs_main(thread const spvUnsafeArray<VertexOutput, 3> (&p), thread const uint& i)
90 {
91 HSOut _output;
92 _output.pos = p[i].pos;
93 _output.uv = p[i].uv;
94 return _output;
95 }
96
97 static inline __attribute__((always_inline))
98 HSConstantOut PatchHS(thread const spvUnsafeArray<VertexOutput, 3> (&_patch))
99 {
100 HSConstantOut _output;
101 _output.EdgeTess[0] = (float2(1.0) + _patch[0].uv).x;
102 _output.EdgeTess[1] = (float2(1.0) + _patch[0].uv).x;
103 _output.EdgeTess[2] = (float2(1.0) + _patch[0].uv).x;
104 _output.InsideTess = (float2(1.0) + _patch[0].uv).x;
105 return _output;
106 }
107
108 kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]])
109 {
110 device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 3];
111 device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1] - 1) * spvIndirectParams[0]];
112 uint gl_InvocationID = gl_GlobalInvocationID.x % 3;
113 uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1]);
114 spvUnsafeArray<VertexOutput, 3> p;
115 p[0].pos = gl_in[0].gl_Position;
116 p[0].uv = gl_in[0].VertexOutput_uv.xy;
117 p[1].pos = gl_in[1].gl_Position;
118 p[1].uv = gl_in[1].VertexOutput_uv.xy;
119 p[2].pos = gl_in[2].gl_Position;
120 p[2].uv = gl_in[2].VertexOutput_uv.xy;
121 uint i = gl_InvocationID;
122 spvUnsafeArray<VertexOutput, 3> param;
123 param = p;
124 uint param_1 = i;
125 HSOut flattenTemp = _hs_main(param, param_1);
126 gl_out[gl_InvocationID].gl_Position = flattenTemp.pos;
127 gl_out[gl_InvocationID]._entryPointOutput.uv = flattenTemp.uv;
128 threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup);
129 if (int(gl_InvocationID) == 0)
130 {
131 spvUnsafeArray<VertexOutput, 3> param_2;
132 param_2 = p;
133 HSConstantOut _patchConstantResult = PatchHS(param_2);
134 spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(_patchConstantResult.EdgeTess[0]);
135 spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(_patchConstantResult.EdgeTess[1]);
136 spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(_patchConstantResult.EdgeTess[2]);
137 spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_patchConstantResult.InsideTess);
138 }
139 }
140