• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
7using namespace metal;
8
9template<typename T, size_t Num>
10struct 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
47constant spvUnsafeArray<float, 16> _16 = spvUnsafeArray<float, 16>({ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0 });
48constant spvUnsafeArray<float4, 4> _60 = spvUnsafeArray<float4, 4>({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) });
49constant spvUnsafeArray<float4, 4> _104 = spvUnsafeArray<float4, 4>({ float4(20.0), float4(30.0), float4(50.0), float4(60.0) });
50
51struct main0_out
52{
53    float FragColor [[color(0)]];
54};
55
56struct main0_in
57{
58    int index [[user(locn0)]];
59};
60
61fragment main0_out main0(main0_in in [[stage_in]])
62{
63    main0_out out = {};
64    out.FragColor = _16[in.index];
65    if (in.index < 10)
66    {
67        out.FragColor += _16[in.index ^ 1];
68    }
69    else
70    {
71        out.FragColor += _16[in.index & 1];
72    }
73    bool _63 = in.index > 30;
74    if (_63)
75    {
76        out.FragColor += _60[in.index & 3].y;
77    }
78    else
79    {
80        out.FragColor += _60[in.index & 1].x;
81    }
82    spvUnsafeArray<float4, 4> foobar = spvUnsafeArray<float4, 4>({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) });
83    if (_63)
84    {
85        foobar[1].z = 20.0;
86    }
87    int _91 = in.index & 3;
88    out.FragColor += foobar[_91].z;
89    out.FragColor += _104[_91].z;
90    return out;
91}
92
93