summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/variable-pointers-2.asm.comp
blob: 7855c4c8256e192e736ff21eba7115fade4e0197 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma clang diagnostic ignored "-Wmissing-prototypes"

#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct foo
{
    int a[128];
    uint b;
    float2 c;
};

struct bar
{
    int d;
};

inline device foo* select_buffer(device foo& a, constant bar& cb)
{
    return (cb.d != 0) ? &a : nullptr;
}

inline thread uint3* select_input(thread uint3& gl_GlobalInvocationID, thread uint3& gl_LocalInvocationID, constant bar& cb)
{
    return (cb.d != 0) ? &gl_GlobalInvocationID : &gl_LocalInvocationID;
}

kernel void main0(device foo& buf [[buffer(0)]], constant bar& cb [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]])
{
    device foo* _46 = select_buffer(buf, cb);
    device foo* _45 = _46;
    device foo* _48 = _45;
    device int* _52;
    device int* _55;
    _52 = &_48->a[0u];
    _55 = &buf.a[0u];
    int _57;
    int _58;
    for (;;)
    {
        _57 = *_52;
        _58 = *_55;
        if (_57 != _58)
        {
            int _66 = (_57 + _58) + int((*select_input(gl_GlobalInvocationID, gl_LocalInvocationID, cb)).x);
            *_52 = _66;
            *_55 = _66;
            _52 = &_52[1u];
            _55 = &_55[1u];
            continue;
        }
        else
        {
            break;
        }
    }
}