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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
#version 450 core
#extension GL_KHR_memory_scope_semantics : enable
#pragma use_vulkan_memory_model
layout(local_size_x = 16, local_size_y = 16) in;
layout(binding = 0) buffer Buffer
{
int datai;
float dataf;
double datad;
} buf;
shared int atomi;
shared float atomf;
shared double atomd;
layout(binding = 0, r32f) volatile coherent uniform image1D fimage1D;
layout(binding = 1, r32f) volatile coherent uniform image2D fimage2D;
void undeclared_errors()
{
//atomicAdd
float resultf = 0;
resultf = atomicAdd(atomf, 3.0);
resultf = atomicAdd(atomf, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsAcquireRelease);
resultf = atomicAdd(buf.dataf, 3.0);
resultf = atomicAdd(buf.dataf, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsAcquireRelease);
double resultd = 0;
resultd = atomicAdd(atomd, 3.0);
resultd = atomicAdd(atomd, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsAcquireRelease);
resultd = atomicAdd(buf.datad, 3.0);
resultd = atomicAdd(buf.datad, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsAcquireRelease);
//atomicExchange
resultf = atomicExchange(buf.dataf, resultf);
resultf = atomicExchange(buf.dataf, resultf, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsAcquireRelease);
resultf = atomicExchange(atomf, resultf);
resultf = atomicExchange(atomf, resultf, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsAcquireRelease);
buf.dataf += resultf;
resultd = atomicExchange(buf.datad, resultd);
resultd = atomicExchange(buf.datad, resultd, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsAcquireRelease);
resultd = atomicExchange(atomd, resultd);
resultd = atomicExchange(atomd, resultd, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsAcquireRelease);
buf.datad += resultd;
//atomic load/store
resultf = atomicLoad(buf.dataf, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsAcquire);
atomicStore(buf.dataf, resultf, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelease);
resultf = atomicLoad(atomf, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsAcquire);
atomicStore(atomf, resultf, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelease);
buf.dataf += resultf;
resultd = atomicLoad(buf.datad, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsAcquire);
atomicStore(buf.datad, resultd, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelease);
resultd = atomicLoad(atomd, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsAcquire);
atomicStore(atomd, resultd, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelease);
buf.datad += resultd;
// image atomics:
atomf = imageAtomicAdd(fimage2D, ivec2(0,0), 2.0);
atomf = imageAtomicAdd(fimage2D, ivec2(1,1), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsAcquireRelease);
atomf = imageAtomicExchange(fimage2D, ivec2(1,0), 4.0, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsAcquireRelease);
atomf = imageAtomicLoad(fimage2D, ivec2(1,1), gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsAcquire);
imageAtomicStore(fimage2D, ivec2(2,2), atomf, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelease);
buf.dataf += atomf;
}
#extension GL_EXT_shader_atomic_float: enable
void main()
{
float resultf = 0;
double resultd = 0;
int resulti = 0;
//atomicAdd
resultf = atomicAdd(atomi);
resultf = atomicAdd(atomi, 3.0);
resultf = atomicAdd(atomi, resultf, gl_StorageSemanticsBuffer, gl_SemanticsAcquireRelease);
resultf = atomicAdd(atomi, resultf, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsAcquireRelease);
//atomicExchange
resultf = atomicExchange(buf.datai);
resultf = atomicExchange(buf.datai, resultf);
resultf = atomicExchange(buf.datai, resultf, gl_StorageSemanticsShared, gl_SemanticsAcquireRelease);
resultf = atomicExchange(buf.datai, resultf, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsAcquireRelease);
resultf = atomicExchange(atomi, resultf);
resultf = atomicExchange(atomi, resultf, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsAcquireRelease);
buf.dataf += resultf;
//atomic load/store
resultf = atomicLoad(buf.datai, gl_StorageSemanticsShared, gl_SemanticsAcquire);
atomicStore(buf.datai, resulti, gl_StorageSemanticsShared, gl_SemanticsRelease);
// image atomics:
atomf = imageAtomicAdd(fimage1D, ivec2(0,0), 2.0);
atomf = imageAtomicAdd(fimage2D, ivec3(0,0,0), 2.0);
atomf = imageAtomicAdd(fimage2D, 2.0);
atomf = imageAtomicExchange(fimage1D, ivec2(1,0), 4.0, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsAcquireRelease);
atomf = imageAtomicExchange(fimage2D, 4.0, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsAcquireRelease);
atomf = imageAtomicExchange(fimage2D, ivec3(1,0,1), 4.0, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsAcquireRelease);
atomf = imageAtomicLoad(fimage1D, ivec2(1,1), gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsAcquire);
atomf = imageAtomicLoad(fimage2D, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsAcquire);
atomf = imageAtomicLoad(fimage2D, ivec3(1,1,1), gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsAcquire);
imageAtomicStore(fimage1D, ivec2(2,2), atomf, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelease);
imageAtomicStore(fimage2D, atomf, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelease);
imageAtomicStore(fimage2D, ivec3(2,2,1), atomf, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelease);
buf.dataf += atomf;
}
|