Debian Codegraph @

third_party/spirv-cross/reference/shaders-msl/frag/fragment-component-padding.pad-fragment.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 main0_out
48 {
49 float4 FragColors_0 [[color(0)]];
50 float4 FragColors_1 [[color(1)]];
51 float4 FragColor2 [[color(2)]];
52 float4 FragColor3 [[color(3)]];
53 };
54
55 struct main0_in
56 {
57 float3 vColor [[user(locn0)]];
58 };
59
60 static inline __attribute__((always_inline))
61 void set_globals(thread spvUnsafeArray<float, 2> (&FragColors), thread float3& vColor, thread float2& FragColor2, thread float3& FragColor3)
62 {
63 FragColors[0] = vColor.x;
64 FragColors[1] = vColor.y;
65 FragColor2 = vColor.xz;
66 FragColor3 = vColor.zzz;
67 }
68
69 fragment main0_out main0(main0_in in [[stage_in]])
70 {
71 main0_out out = {};
72 spvUnsafeArray<float, 2> FragColors = {};
73 float2 FragColor2 = {};
74 float3 FragColor3 = {};
75 set_globals(FragColors, in.vColor, FragColor2, FragColor3);
76 out.FragColors_0 = float4(FragColors[0]);
77 out.FragColors_1 = float4(FragColors[1]);
78 out.FragColor2.xy = FragColor2;
79 out.FragColor3.xyz = FragColor3;
80 return out;
81 }
82