Debian Codegraph @

third_party/spirv-cross/reference/shaders-msl/tesc/reload-tess-level.tesc

raw
1 #include <metal_stdlib>
2 #include <simd/simd.h>
3
4 using namespace metal;
5
6 struct main0_out
7 {
8 float4 gl_Position;
9 };
10
11 struct main0_in
12 {
13 float4 gl_Position [[attribute(0)]];
14 };
15
16 kernel void main0(main0_in in [[stage_in]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]])
17 {
18 device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4];
19 if (gl_InvocationID < spvIndirectParams[0])
20 gl_in[gl_InvocationID] = in;
21 threadgroup_barrier(mem_flags::mem_threadgroup);
22 if (gl_InvocationID >= 4)
23 return;
24 if (gl_InvocationID == 0)
25 {
26 spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(2.0);
27 spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(3.0);
28 spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(4.0);
29 spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[3] = half(5.0);
30 spvTessLevel[gl_PrimitiveID].insideTessellationFactor[0] = half(mix(float(spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0]), float(spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[3]), 0.5));
31 spvTessLevel[gl_PrimitiveID].insideTessellationFactor[1] = half(mix(float(spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2]), float(spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1]), 0.5));
32 }
33 gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
34 }
35