Debian Codegraph @

third_party/spirv-cross/reference/shaders-msl/frag/constant-composites.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 Foo
48 {
49 float a;
50 float b;
51 };
52
53 constant spvUnsafeArray<float, 4> _16 = spvUnsafeArray<float, 4>({ 1.0, 4.0, 3.0, 2.0 });
54
55 struct main0_out
56 {
57 float4 FragColor [[color(0)]];
58 };
59
60 struct main0_in
61 {
62 int line [[user(locn0)]];
63 };
64
65 fragment main0_out main0(main0_in in [[stage_in]])
66 {
67 spvUnsafeArray<Foo, 2> _28 = spvUnsafeArray<Foo, 2>({ Foo{ 10.0, 20.0 }, Foo{ 30.0, 40.0 } });
68
69 main0_out out = {};
70 out.FragColor = float4(_16[in.line]);
71 out.FragColor += float4(_28[in.line].a * _28[1 - in.line].a);
72 return out;
73 }
74