glslang/Test/spv.atomicFloat.comp

197 lines
8.8 KiB
Plaintext
Raw Normal View History

#version 450 core
#extension GL_KHR_memory_scope_semantics : enable
#extension GL_EXT_shader_atomic_float: enable
#pragma use_vulkan_memory_model
layout(local_size_x = 16, local_size_y = 16) in;
layout(binding = 0) buffer Buffer
{
float dataf;
double datad;
} buf;
shared float atomf;
shared double atomd;
layout(binding = 0, r32f) volatile coherent uniform image1D fimage1D;
layout(binding = 1, r32f) volatile coherent uniform image1DArray fimage1DArray;
layout(binding = 2, r32f) volatile coherent uniform image2D fimage2D;
layout(binding = 3, r32f) volatile coherent uniform image2DArray fimage2DArray;
layout(binding = 4, r32f) volatile coherent uniform image2DRect fimage2DRect;
layout(binding = 5, r32f) volatile coherent uniform imageCube fimageCube;
layout(binding = 6, r32f) volatile coherent uniform imageCubeArray fimageCubeArray;
layout(binding = 9, r32f) volatile coherent uniform image3D fimage3D;
void main()
{
//atomicAdd
float resultf = 0;
resultf = atomicAdd(atomf, 3.0);
resultf = atomicAdd(atomf, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed);
resultf = atomicAdd(buf.dataf, 3.0);
resultf = atomicAdd(buf.dataf, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed);
double resultd = 0;
resultd = atomicAdd(atomd, 3.0);
resultd = atomicAdd(atomd, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed);
resultd = atomicAdd(buf.datad, 3.0);
resultd = atomicAdd(buf.datad, 4.5, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed);
//atomicExchange
resultf = atomicExchange(buf.dataf, resultf);
buf.dataf += resultf;
resultf = atomicExchange(buf.dataf, resultf, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed);
buf.dataf += resultf;
resultf = atomicExchange(atomf, resultf);
buf.dataf += resultf;
resultf = atomicExchange(atomf, resultf, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed);
buf.dataf += resultf;
resultd = atomicExchange(buf.datad, resultd);
buf.datad += resultd;
resultd = atomicExchange(buf.datad, resultd, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed);
buf.datad += resultd;
resultd = atomicExchange(atomd, resultd);
buf.datad += resultd;
resultd = atomicExchange(atomd, resultd, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed);
buf.datad += resultd;
//atomic load/store
resultf = atomicLoad(buf.dataf, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed);
atomicStore(buf.dataf, resultf, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed);
buf.dataf += resultf;
resultf = atomicLoad(atomf, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed);
atomicStore(atomf, resultf, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed);
buf.dataf += resultf;
resultd = atomicLoad(buf.datad, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed);
atomicStore(buf.datad, resultd, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed);
buf.datad += resultd;
resultd = atomicLoad(atomd, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed);
atomicStore(atomd, resultd, gl_ScopeDevice, gl_StorageSemanticsShared, gl_SemanticsRelaxed);
buf.datad += resultd;
// image atomics on 1D:
atomf = imageAtomicAdd(fimage1D, int(0), 2.0);
buf.dataf += atomf;
atomf = imageAtomicAdd(fimage1D, int(1), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicExchange(fimage1D, int(1), 4.0, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicLoad(fimage1D, int(1), gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
imageAtomicStore(fimage1D, int(2), atomf, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
// image atomics on 1D Array:
atomf = imageAtomicAdd(fimage1DArray, ivec2(0,0), 2.0);
buf.dataf += atomf;
atomf = imageAtomicAdd(fimage1DArray, ivec2(1,1), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicExchange(fimage1DArray, ivec2(1,0), 4.0, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicLoad(fimage1DArray, ivec2(1,1), gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
imageAtomicStore(fimage1DArray, ivec2(2,2), atomf, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
// image atomics on 2D:
atomf = imageAtomicAdd(fimage2D, ivec2(0,0), 2.0);
buf.dataf += atomf;
atomf = imageAtomicAdd(fimage2D, ivec2(1,1), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicExchange(fimage2D, ivec2(1,0), 4.0, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicLoad(fimage2D, ivec2(1,1), gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
imageAtomicStore(fimage2D, ivec2(2,2), atomf, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
// image atomics on 2D Rect:
atomf = imageAtomicAdd(fimage2DRect, ivec2(0,0), 2.0);
buf.dataf += atomf;
atomf = imageAtomicAdd(fimage2DRect, ivec2(1,1), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicExchange(fimage2DRect, ivec2(1,0), 4.0, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicLoad(fimage2DRect, ivec2(1,1), gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
imageAtomicStore(fimage2DRect, ivec2(2,2), atomf, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
// image atomics on 2D Array:
atomf = imageAtomicAdd(fimage2DArray, ivec3(0,0,0), 2.0);
buf.dataf += atomf;
atomf = imageAtomicAdd(fimage2DArray, ivec3(1,1,0), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicExchange(fimage2DArray, ivec3(1,0,1), 4.0, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicLoad(fimage2DArray, ivec3(1,1,1), gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
imageAtomicStore(fimage2DArray, ivec3(2,2,0), atomf, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
// image atomics on Cube:
atomf = imageAtomicAdd(fimageCube, ivec3(0,0,0), 2.0);
buf.dataf += atomf;
atomf = imageAtomicAdd(fimageCube, ivec3(1,1,0), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicExchange(fimageCube, ivec3(1,0,0), 4.0, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicLoad(fimageCube, ivec3(1,1,1), gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
imageAtomicStore(fimageCube, ivec3(2,2,1), atomf, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
// image atomics on Cube Array:
atomf = imageAtomicAdd(fimageCubeArray, ivec3(0,0,0), 2.0);
buf.dataf += atomf;
atomf = imageAtomicAdd(fimageCubeArray, ivec3(1,1,0), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicExchange(fimageCubeArray, ivec3(1,0,1), 4.0, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicLoad(fimageCubeArray, ivec3(1,1,1), gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
imageAtomicStore(fimageCubeArray, ivec3(2,2,0), atomf, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
// image atomics on 3D:
atomf = imageAtomicAdd(fimage3D, ivec3(0,0,0), 2.0);
buf.dataf += atomf;
atomf = imageAtomicAdd(fimage3D, ivec3(1,1,0), 3.0, gl_ScopeDevice, gl_StorageSemanticsImage , gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicExchange(fimage3D, ivec3(1,0,1), 4.0, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
atomf = imageAtomicLoad(fimage3D, ivec3(1,1,1), gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
imageAtomicStore(fimage3D, ivec3(2,2,0), atomf, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
buf.dataf += atomf;
}