Debian Codegraph @

third_party/spirv-cross/reference/shaders-msl/asm/frag/single-function-private-lut.asm.frag

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 myType
48 {
49 float data;
50 };
51
52 struct main0_out
53 {
54 float4 o_color [[color(0)]];
55 };
56
57 // Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
58 template<typename Tx, typename Ty>
59 inline Tx mod(Tx x, Ty y)
60 {
61 return x - y * floor(x / y);
62 }
63
64 fragment main0_out main0(float4 gl_FragCoord [[position]])
65 {
66 spvUnsafeArray<myType, 5> _21 = spvUnsafeArray<myType, 5>({ myType{ 0.0 }, myType{ 1.0 }, myType{ 0.0 }, myType{ 1.0 }, myType{ 0.0 } });
67
68 main0_out out = {};
69 float2 uv = gl_FragCoord.xy;
70 int index = int(mod(uv.x, 4.0));
71 myType elt = _21[index];
72 if (elt.data > 0.0)
73 {
74 out.o_color = float4(0.0, 1.0, 0.0, 1.0);
75 }
76 else
77 {
78 out.o_color = float4(1.0, 0.0, 0.0, 1.0);
79 }
80 return out;
81 }
82