| 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 type_Globals |
| 48 |
{ |
| 49 |
float4 ViewportSize; |
| 50 |
float ScatteringScaling; |
| 51 |
float CocRadiusToCircumscribedRadius; |
| 52 |
}; |
| 53 |
|
| 54 |
struct type_StructuredBuffer_v4float |
| 55 |
{ |
| 56 |
float4 _m0[1]; |
| 57 |
}; |
| 58 |
|
| 59 |
struct main0_out |
| 60 |
{ |
| 61 |
float2 out_var_TEXCOORD0 [[user(locn0)]]; |
| 62 |
float4 out_var_TEXCOORD1 [[user(locn1)]]; |
| 63 |
float4 out_var_TEXCOORD2 [[user(locn2)]]; |
| 64 |
float4 out_var_TEXCOORD3 [[user(locn3)]]; |
| 65 |
float4 out_var_TEXCOORD4 [[user(locn4)]]; |
| 66 |
float4 out_var_TEXCOORD5 [[user(locn5)]]; |
| 67 |
float4 out_var_TEXCOORD6 [[user(locn6)]]; |
| 68 |
float4 gl_Position [[position]]; |
| 69 |
}; |
| 70 |
|
| 71 |
vertex main0_out main0(constant type_Globals& _Globals [[buffer(0)]], const device type_StructuredBuffer_v4float& ScatterDrawList [[buffer(1)]], uint gl_VertexIndex [[vertex_id]], uint gl_InstanceIndex [[instance_id]]) |
| 72 |
{ |
| 73 |
main0_out out = {}; |
| 74 |
uint _66 = gl_VertexIndex / 4u; |
| 75 |
uint _68 = gl_VertexIndex - (_66 * 4u); |
| 76 |
uint _70 = (16u * gl_InstanceIndex) + _66; |
| 77 |
float _72; |
| 78 |
_72 = 0.0; |
| 79 |
spvUnsafeArray<float4, 4> _61; |
| 80 |
spvUnsafeArray<float, 4> _62; |
| 81 |
spvUnsafeArray<float2, 4> _63; |
| 82 |
float _73; |
| 83 |
uint _75 = 0u; |
| 84 |
for (;;) |
| 85 |
{ |
| 86 |
if (_75 < 4u) |
| 87 |
{ |
| 88 |
uint _82 = ((5u * _70) + _75) + 1u; |
| 89 |
_61[_75] = float4(ScatterDrawList._m0[_82].xyz, 0.0); |
| 90 |
_62[_75] = ScatterDrawList._m0[_82].w; |
| 91 |
if (_75 == 0u) |
| 92 |
{ |
| 93 |
_73 = _62[_75]; |
| 94 |
} |
| 95 |
else |
| 96 |
{ |
| 97 |
_73 = fast::max(_72, _62[_75]); |
| 98 |
} |
| 99 |
_63[_75].x = (-0.5) / _62[_75]; |
| 100 |
_63[_75].y = (0.5 * _62[_75]) + 0.5; |
| 101 |
_72 = _73; |
| 102 |
_75++; |
| 103 |
continue; |
| 104 |
} |
| 105 |
else |
| 106 |
{ |
| 107 |
break; |
| 108 |
} |
| 109 |
} |
| 110 |
float2 _144 = float2(_Globals.ScatteringScaling) * ScatterDrawList._m0[5u * _70].xy; |
| 111 |
float2 _173 = (((float2((_72 * _Globals.CocRadiusToCircumscribedRadius) + 1.0) * ((float2(float(_68 % 2u), float(_68 / 2u)) * float2(2.0)) - float2(1.0))) + _144) + float2(0.5)) * _Globals.ViewportSize.zw; |
| 112 |
out.out_var_TEXCOORD0 = _144; |
| 113 |
out.out_var_TEXCOORD1 = float4(_61[0].xyz, _62[0]); |
| 114 |
out.out_var_TEXCOORD2 = float4(_61[1].xyz, _62[1]); |
| 115 |
out.out_var_TEXCOORD3 = float4(_61[2].xyz, _62[2]); |
| 116 |
out.out_var_TEXCOORD4 = float4(_61[3].xyz, _62[3]); |
| 117 |
out.out_var_TEXCOORD5 = float4(_63[0].x, _63[0].y, _63[1].x, _63[1].y); |
| 118 |
out.out_var_TEXCOORD6 = float4(_63[2].x, _63[2].y, _63[3].x, _63[3].y); |
| 119 |
out.gl_Position = float4((_173.x * 2.0) - 1.0, 1.0 - (_173.y * 2.0), 0.0, 1.0); |
| 120 |
return out; |
| 121 |
} |
| 122 |
|