• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#version 450 core
2
3#extension GL_ARB_gpu_shader_int64: enable
4#extension GL_NV_shader_atomic_int64: enable
5
6layout(local_size_x = 16, local_size_y = 16) in;
7
8layout(binding = 0) buffer Buffer
9{
10    int64_t  i64;
11    uint64_t u64;
12} buf;
13
14struct Struct
15{
16    int64_t  i64;
17    uint64_t u64;
18};
19
20shared Struct s;
21
22void main()
23{
24    const int64_t  i64c = -24;
25    const uint64_t u64c = 0xF00000000Ful;
26
27    // Test shader storage block
28    int64_t  i64 = 0;
29    uint64_t u64 = 0;
30
31    i64 += atomicMin(buf.i64, i64c);
32    u64 += atomicMin(buf.u64, u64c);
33
34    i64 += atomicMax(buf.i64, i64c);
35    u64 += atomicMax(buf.u64, u64c);
36
37    i64 += atomicAnd(buf.i64, i64c);
38    u64 += atomicAnd(buf.u64, u64c);
39
40    i64 += atomicOr(buf.i64, i64c);
41    u64 += atomicOr(buf.u64, u64c);
42
43    i64 += atomicXor(buf.i64, i64c);
44    u64 += atomicXor(buf.u64, u64c);
45
46    i64 += atomicAdd(buf.i64, i64c);
47    i64 += atomicExchange(buf.i64, i64c);
48    i64 += atomicCompSwap(buf.i64, i64c, i64);
49
50    buf.i64 = i64;
51    buf.u64 = u64;
52
53    // Test shared variable
54    i64 = 0;
55    u64 = 0;
56
57    i64 += atomicMin(s.i64, i64c);
58    u64 += atomicMin(s.u64, u64c);
59
60    i64 += atomicMax(s.i64, i64c);
61    u64 += atomicMax(s.u64, u64c);
62
63    i64 += atomicAnd(s.i64, i64c);
64    u64 += atomicAnd(s.u64, u64c);
65
66    i64 += atomicOr(s.i64, i64c);
67    u64 += atomicOr(s.u64, u64c);
68
69    i64 += atomicXor(s.i64, i64c);
70    u64 += atomicXor(s.u64, u64c);
71
72    i64 += atomicAdd(s.i64, i64c);
73    i64 += atomicExchange(s.i64, i64c);
74    i64 += atomicCompSwap(s.i64, i64c, i64);
75
76    s.i64 = i64;
77    s.u64 = u64;
78}
79
80