glslang/Test/spv.memoryScopeSemantics.comp
Rex Xu b4bab3ce01 Fix a parser error of GL_KHR_memory_scope_semantics
When 2DMS or 2DMSArray is used, IMAGE_PARAMS will take an additional
paramter to represent sample number. The semantics check should get the
correct semantics values, taking this case into account.
2020-02-06 16:51:10 +08:00

74 lines
3.7 KiB
Plaintext

#version 450
#extension GL_KHR_memory_scope_semantics : require
#extension GL_ARB_gpu_shader_int64 : require
#pragma use_vulkan_memory_model
shared uint value;
shared int atomi;
shared uint atomu;
layout(binding = 0, r32ui) workgroupcoherent uniform uimage2D imageu;
layout(binding = 1, r32i) volatile coherent uniform iimage2D imagei;
layout(binding = 5, r32i) nonprivate uniform iimage2D imagej[2];
layout (binding = 2) buffer BufferU { workgroupcoherent uint x; } bufferu;
layout (binding = 3) coherent buffer BufferI { uint x; } bufferi;
struct A { uint x[2]; };
layout (binding = 4) volatile buffer BufferJ { subgroupcoherent A a; } bufferj[2];
layout (binding = 6) nonprivate uniform sampler2D samp[2];
layout (binding = 7) nonprivate uniform BufferK { uint x; } bufferk;
shared uint64_t atomu64;
shared int64_t atomi64;
layout (binding = 8) volatile buffer BufferL { uint x; } bufferl;
layout (binding = 9) buffer BufferM { volatile uint x; } bufferm;
layout(binding = 10, r32i) volatile coherent uniform iimage2DMS imageMS;
void main()
{
int origi = atomicAdd(atomi, 3, gl_ScopeDevice, gl_StorageSemanticsBuffer | gl_StorageSemanticsShared, gl_SemanticsRelease);
uint origu = atomicAnd(atomu, value);
origi = atomicLoad(atomi, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsAcquire);
atomicStore(atomu, value, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelease);
origi = imageAtomicLoad(imagei, ivec2(0,0), gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsAcquire);
origu = imageAtomicAdd(imageu, ivec2(0,0), 3u, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsAcquire);
imageAtomicStore(imageu, ivec2(0,0), 4u, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelease);
origu = atomicOr(atomu, 7u, gl_ScopeDevice, 0, 0);
origu = atomicXor(atomu, 7u, gl_ScopeDevice, 0, 0);
origu = atomicMin(atomu, value, gl_ScopeDevice, 0, 0);
origi = atomicMax(atomi, 7, gl_ScopeDevice, 0, 0);
origi = atomicExchange(atomi, origi, gl_ScopeDevice, 0, 0);
origu = atomicCompSwap(atomu, 10u, value, gl_ScopeDevice, gl_StorageSemanticsBuffer | gl_StorageSemanticsShared, gl_SemanticsAcquire, gl_StorageSemanticsBuffer | gl_StorageSemanticsShared, gl_SemanticsAcquire);
atomicAdd(bufferu.x, 1, gl_ScopeDevice, gl_StorageSemanticsBuffer | gl_StorageSemanticsShared, gl_SemanticsRelease);
memoryBarrier(gl_ScopeWorkgroup, gl_StorageSemanticsBuffer | gl_StorageSemanticsShared, gl_SemanticsRelease);
controlBarrier(gl_ScopeWorkgroup, gl_ScopeWorkgroup, gl_StorageSemanticsBuffer | gl_StorageSemanticsShared, gl_SemanticsAcquire);
controlBarrier(gl_ScopeWorkgroup, gl_ScopeWorkgroup, 0, 0);
uint y;
y = bufferu.x;
bufferu.x = y;
y = bufferi.x;
y = bufferj[0].a.x[1];
bufferi.x = y;
bufferj[0].a.x[1] = y;
bufferj[0].a = bufferj[1].a;
bufferi.x = bufferk.x;
imageLoad(imagei, ivec2(0,0));
imageLoad(imagej[0], ivec2(0,0));
imageStore(imagej[1], ivec2(0,0), ivec4(0,0,0,0));
texture(samp[0], vec2(0,0));
atomu64 = atomicMax(atomu64, uint64_t(7), gl_ScopeDevice, 0, 0);
atomicCompSwap(atomi64, int64_t(10), int64_t(atomu64), gl_ScopeDevice, gl_StorageSemanticsBuffer | gl_StorageSemanticsShared, gl_SemanticsAcquire, gl_StorageSemanticsBuffer | gl_StorageSemanticsShared, gl_SemanticsAcquire);
y = bufferl.x;
atomicAdd(bufferl.x, 1);
atomicOr(bufferm.x, 2);
imageAtomicAdd(imagei, ivec2(0,0), 3);
atomicAdd(bufferu.x, 4u, gl_ScopeDevice, 0, 0);
atomicAdd(bufferu.x, 5u, gl_ScopeDevice, 0, gl_SemanticsVolatile);
imageAtomicStore(imageMS, ivec2(0,0), 1, 4, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelease);
}