John Kessenich | 2d0cc78 | 2016-07-07 13:20:00 -0600 | [diff] [blame] | 1 | #version 450
|
John Kessenich | 426394d | 2015-07-23 10:22:48 -0600 | [diff] [blame] | 2 |
|
John Kessenich | b901ade | 2016-06-16 20:59:42 -0600 | [diff] [blame] | 3 |
|
John Kessenich | 6c292d3 | 2016-02-15 20:58:50 -0700 | [diff] [blame] | 4 |
|
John Kessenich | 426394d | 2015-07-23 10:22:48 -0600 | [diff] [blame] | 5 | layout(binding = 0) uniform atomic_uint counter;
|
| 6 |
|
| 7 | layout(binding = 0, offset = 4) uniform atomic_uint countArr[4];
|
John Kessenich | 6c292d3 | 2016-02-15 20:58:50 -0700 | [diff] [blame] | 8 | shared uint value;
|
John Kessenich | 426394d | 2015-07-23 10:22:48 -0600 | [diff] [blame] | 9 |
|
| 10 | int arrX[gl_WorkGroupSize.x];
|
| 11 | int arrY[gl_WorkGroupSize.y];
|
| 12 | int arrZ[gl_WorkGroupSize.z];
|
| 13 |
|
| 14 | uint func(atomic_uint c)
|
| 15 | {
|
| 16 | return atomicCounterIncrement(c);
|
| 17 | }
|
| 18 |
|
| 19 | void main()
|
| 20 | {
|
| 21 | memoryBarrierAtomicCounter();
|
| 22 | func(counter);
|
| 23 | uint val = atomicCounter(countArr[2]);
|
| 24 | atomicCounterDecrement(counter);
|
John Kessenich | 2d0cc78 | 2016-07-07 13:20:00 -0600 | [diff] [blame] | 25 | atomicCounterIncrement(counter);
|
John Kessenich | 426394d | 2015-07-23 10:22:48 -0600 | [diff] [blame] | 26 | }
|
| 27 |
|
| 28 | shared int atomi;
|
| 29 | shared uint atomu;
|
| 30 |
|
John Kessenich | 55e7d11 | 2015-11-15 21:33:39 -0700 | [diff] [blame] | 31 | layout (std140, binding = 0) restrict buffer dataSSB
|
| 32 | {
|
| 33 | float f;
|
| 34 | ivec4 n_frames_rendered;
|
| 35 | } result;
|
| 36 |
|
John Kessenich | 426394d | 2015-07-23 10:22:48 -0600 | [diff] [blame] | 37 | void atoms()
|
| 38 | {
|
| 39 | int origi = atomicAdd(atomi, 3);
|
| 40 | uint origu = atomicAnd(atomu, value);
|
| 41 | origu = atomicOr(atomu, 7u);
|
| 42 | origu = atomicXor(atomu, 7u);
|
| 43 | origu = atomicMin(atomu, value);
|
| 44 | origi = atomicMax(atomi, 7);
|
| 45 | origi = atomicExchange(atomi, origi);
|
| 46 | origu = atomicCompSwap(atomu, 10u, value);
|
John Kessenich | 55e7d11 | 2015-11-15 21:33:39 -0700 | [diff] [blame] | 47 | atomicAdd(result.n_frames_rendered.z, 1);
|
John Kessenich | 426394d | 2015-07-23 10:22:48 -0600 | [diff] [blame] | 48 | }
|