GL_KHR_memory_scope_semantics

This commit is contained in:
Jeff Bolz
2018-09-05 10:11:41 -05:00
parent 97068d8b30
commit 36831c9bad
28 changed files with 5544 additions and 4242 deletions

View File

@@ -0,0 +1,243 @@
spv.memoryScopeSemantics.comp
error: SPIRV-Tools Validation Errors
error: Capability Int64Atomics is not allowed by Vulkan 1.0 specification (or requires extension)
OpCapability Int64Atomics
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 142
Capability Shader
Capability Int64
Capability Int64Atomics
Capability CapabilityVulkanMemoryModelKHR
Capability CapabilityVulkanMemoryModelDeviceScopeKHR
Extension "SPV_KHR_vulkan_memory_model"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical VulkanKHR
EntryPoint GLCompute 4 "main"
ExecutionMode 4 LocalSize 1 1 1
Source GLSL 450
SourceExtension "GL_ARB_gpu_shader_int64"
SourceExtension "GL_KHR_memory_scope_semantics"
Name 4 "main"
Name 8 "origi"
Name 10 "atomi"
Name 21 "origu"
Name 23 "atomu"
Name 24 "value"
Name 36 "imagei"
Name 45 "imageu"
Name 65 "BufferU"
MemberName 65(BufferU) 0 "x"
Name 67 "bufferu"
Name 72 "y"
Name 77 "BufferI"
MemberName 77(BufferI) 0 "x"
Name 79 "bufferi"
Name 83 "A"
MemberName 83(A) 0 "x"
Name 84 "BufferJ"
MemberName 84(BufferJ) 0 "a"
Name 87 "bufferj"
Name 98 "BufferK"
MemberName 98(BufferK) 0 "x"
Name 100 "bufferk"
Name 109 "imagej"
Name 121 "samp"
Name 132 "atomu64"
Name 137 "atomi64"
Decorate 36(imagei) DescriptorSet 0
Decorate 36(imagei) Binding 1
Decorate 45(imageu) DescriptorSet 0
Decorate 45(imageu) Binding 0
MemberDecorate 65(BufferU) 0 Offset 0
Decorate 65(BufferU) BufferBlock
Decorate 67(bufferu) DescriptorSet 0
Decorate 67(bufferu) Binding 2
MemberDecorate 77(BufferI) 0 Offset 0
Decorate 77(BufferI) BufferBlock
Decorate 79(bufferi) DescriptorSet 0
Decorate 79(bufferi) Binding 3
Decorate 82 ArrayStride 4
MemberDecorate 83(A) 0 Offset 0
MemberDecorate 84(BufferJ) 0 Offset 0
Decorate 84(BufferJ) BufferBlock
Decorate 87(bufferj) DescriptorSet 0
Decorate 87(bufferj) Binding 4
MemberDecorate 98(BufferK) 0 Offset 0
Decorate 98(BufferK) Block
Decorate 100(bufferk) DescriptorSet 0
Decorate 100(bufferk) Binding 7
Decorate 109(imagej) DescriptorSet 0
Decorate 109(imagej) Binding 5
Decorate 121(samp) DescriptorSet 0
Decorate 121(samp) Binding 6
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypePointer Function 6(int)
9: TypePointer Workgroup 6(int)
10(atomi): 9(ptr) Variable Workgroup
11: 6(int) Constant 3
12: 6(int) Constant 1
13: 6(int) Constant 320
14: 6(int) Constant 4
15: TypeInt 32 0
16: 15(int) Constant 5
17: 15(int) Constant 0
18: 15(int) Constant 324
20: TypePointer Function 15(int)
22: TypePointer Workgroup 15(int)
23(atomu): 22(ptr) Variable Workgroup
24(value): 22(ptr) Variable Workgroup
26: 15(int) Constant 2
28: 6(int) Constant 64
29: 6(int) Constant 2
30: 15(int) Constant 66
33: 15(int) Constant 68
34: TypeImage 6(int) 2D nonsampled format:R32i
35: TypePointer UniformConstant 34
36(imagei): 35(ptr) Variable UniformConstant
37: TypeVector 6(int) 2
38: 6(int) Constant 0
39: 37(ivec2) ConstantComposite 38 38
40: TypePointer Image 6(int)
43: TypeImage 15(int) 2D nonsampled format:R32ui
44: TypePointer UniformConstant 43
45(imageu): 44(ptr) Variable UniformConstant
46: 15(int) Constant 3
47: TypePointer Image 15(int)
50: 15(int) Constant 4
52: 15(int) Constant 7
57: 6(int) Constant 7
61: 15(int) Constant 10
63: 15(int) Constant 322
65(BufferU): TypeStruct 15(int)
66: TypePointer Uniform 65(BufferU)
67(bufferu): 66(ptr) Variable Uniform
68: TypePointer Uniform 15(int)
70: 15(int) Constant 1
77(BufferI): TypeStruct 15(int)
78: TypePointer Uniform 77(BufferI)
79(bufferi): 78(ptr) Variable Uniform
82: TypeArray 15(int) 26
83(A): TypeStruct 82
84(BufferJ): TypeStruct 83(A)
85: TypeArray 84(BufferJ) 26
86: TypePointer Uniform 85
87(bufferj): 86(ptr) Variable Uniform
94: TypePointer Uniform 83(A)
98(BufferK): TypeStruct 15(int)
99: TypePointer Uniform 98(BufferK)
100(bufferk): 99(ptr) Variable Uniform
105: TypeVector 6(int) 4
107: TypeArray 34 26
108: TypePointer UniformConstant 107
109(imagej): 108(ptr) Variable UniformConstant
115: 105(ivec4) ConstantComposite 38 38 38 38
116: TypeFloat 32
117: TypeImage 116(float) 2D sampled format:Unknown
118: TypeSampledImage 117
119: TypeArray 118 26
120: TypePointer UniformConstant 119
121(samp): 120(ptr) Variable UniformConstant
122: TypePointer UniformConstant 118
125: TypeVector 116(float) 2
126: 116(float) Constant 0
127: 125(fvec2) ConstantComposite 126 126
128: TypeVector 116(float) 4
130: TypeInt 64 0
131: TypePointer Workgroup 130(int64_t)
132(atomu64): 131(ptr) Variable Workgroup
133:130(int64_t) Constant 7 0
135: TypeInt 64 1
136: TypePointer Workgroup 135(int64_t)
137(atomi64): 136(ptr) Variable Workgroup
138:135(int64_t) Constant 10 0
4(main): 2 Function None 3
5: Label
8(origi): 7(ptr) Variable Function
21(origu): 20(ptr) Variable Function
72(y): 20(ptr) Variable Function
19: 6(int) AtomicIAdd 10(atomi) 12 18 11
Store 8(origi) 19
25: 15(int) Load 24(value) MakePointerVisibleKHR 26
27: 15(int) AtomicAnd 23(atomu) 16 17 25
Store 21(origu) 27
31: 6(int) AtomicLoad 10(atomi) 12 30
Store 8(origi) 31
32: 15(int) Load 24(value) MakePointerVisibleKHR 26
AtomicStore 23(atomu) 12 33 32
41: 40(ptr) ImageTexelPointer 36(imagei) 39 17
42: 6(int) AtomicLoad 41 12 30
Store 8(origi) 42
48: 47(ptr) ImageTexelPointer 45(imageu) 39 17
49: 15(int) AtomicIAdd 48 12 30 46
Store 21(origu) 49
51: 47(ptr) ImageTexelPointer 45(imageu) 39 17
AtomicStore 51 12 33 50
53: 15(int) AtomicOr 23(atomu) 12 17 52
Store 21(origu) 53
54: 15(int) AtomicXor 23(atomu) 12 17 52
Store 21(origu) 54
55: 15(int) Load 24(value) MakePointerVisibleKHR 26
56: 15(int) AtomicUMin 23(atomu) 12 17 55
Store 21(origu) 56
58: 6(int) AtomicSMax 10(atomi) 12 17 57
Store 8(origi) 58
59: 6(int) Load 8(origi)
60: 6(int) AtomicExchange 10(atomi) 12 17 59
Store 8(origi) 60
62: 15(int) Load 24(value) MakePointerVisibleKHR 26
64: 15(int) AtomicCompareExchange 23(atomu) 12 63 63 62 61
Store 21(origu) 64
69: 68(ptr) AccessChain 67(bufferu) 38
71: 15(int) AtomicIAdd 69 12 18 70
MemoryBarrier 26 18
ControlBarrier 26 26 63
ControlBarrier 26 26 17
73: 68(ptr) AccessChain 67(bufferu) 38
74: 15(int) Load 73 MakePointerVisibleKHR NonPrivatePointerKHR 26
Store 72(y) 74
75: 15(int) Load 72(y)
76: 68(ptr) AccessChain 67(bufferu) 38
Store 76 75 MakePointerAvailableKHR NonPrivatePointerKHR 26
80: 68(ptr) AccessChain 79(bufferi) 38
81: 15(int) Load 80 MakePointerVisibleKHR NonPrivatePointerKHR 16
Store 72(y) 81
88: 68(ptr) AccessChain 87(bufferj) 38 38 38 12
89: 15(int) Load 88 Volatile MakePointerVisibleKHR NonPrivatePointerKHR 46
Store 72(y) 89
90: 15(int) Load 72(y)
91: 68(ptr) AccessChain 79(bufferi) 38
Store 91 90 MakePointerAvailableKHR NonPrivatePointerKHR 16
92: 15(int) Load 72(y)
93: 68(ptr) AccessChain 87(bufferj) 38 38 38 12
Store 93 92 Volatile MakePointerAvailableKHR NonPrivatePointerKHR 46
95: 94(ptr) AccessChain 87(bufferj) 12 38
96: 83(A) Load 95 Volatile MakePointerVisibleKHR NonPrivatePointerKHR 46
97: 94(ptr) AccessChain 87(bufferj) 38 38
Store 97 96 Volatile MakePointerAvailableKHR NonPrivatePointerKHR 46
101: 68(ptr) AccessChain 100(bufferk) 38
102: 15(int) Load 101 NonPrivatePointerKHR
103: 68(ptr) AccessChain 79(bufferi) 38
Store 103 102 MakePointerAvailableKHR NonPrivatePointerKHR 16
104: 34 Load 36(imagei)
106: 105(ivec4) ImageRead 104 39 MakeTexelVisibleKHR NonPrivateTexelKHR VolatileTexelKHR 16
110: 35(ptr) AccessChain 109(imagej) 38
111: 34 Load 110
112: 105(ivec4) ImageRead 111 39 NonPrivateTexelKHR
113: 35(ptr) AccessChain 109(imagej) 12
114: 34 Load 113
ImageWrite 114 39 115 NonPrivateTexelKHR
123: 122(ptr) AccessChain 121(samp) 38
124: 118 Load 123
129: 128(fvec4) ImageSampleExplicitLod 124 127 Lod NonPrivateTexelKHR 126
134:130(int64_t) AtomicUMax 132(atomu64) 12 17 133
Store 132(atomu64) 134 MakePointerAvailableKHR 26
139:130(int64_t) Load 132(atomu64) MakePointerVisibleKHR 26
140:135(int64_t) Bitcast 139
141:135(int64_t) AtomicCompareExchange 137(atomi64) 12 63 63 140 138
Return
FunctionEnd

View File

@@ -0,0 +1,17 @@
spv.memoryScopeSemantics_Error.comp
ERROR: 0:15: 'atomicStore' : gl_SemanticsAcquire must not be used with (image) atomic store
ERROR: 0:16: 'imageAtomicLoad' : gl_SemanticsRelease must not be used with (image) atomic load
ERROR: 0:17: 'atomicStore' : gl_SemanticsAcquireRelease must not be used with (image) atomic load/store
ERROR: 0:18: 'atomicStore' : Invalid semantics value
ERROR: 0:19: 'imageAtomicLoad' : Invalid storage class semantics value
ERROR: 0:20: 'memoryBarrier' : Semantics must include exactly one of gl_SemanticsRelease, gl_SemanticsAcquire, or gl_SemanticsAcquireRelease
ERROR: 0:21: 'memoryBarrier' : Storage class semantics must not be zero
ERROR: 0:22: 'memoryBarrier' : Semantics must include exactly one of gl_SemanticsRelease, gl_SemanticsAcquire, or gl_SemanticsAcquireRelease
ERROR: 0:23: 'atomicAdd' : Semantics must not include multiple of gl_SemanticsRelease, gl_SemanticsAcquire, or gl_SemanticsAcquireRelease
ERROR: 0:24: 'atomicCompSwap' : semUnequal must not be gl_SemanticsRelease or gl_SemanticsAcquireRelease
ERROR: 0:25: 'memoryBarrier' : gl_SemanticsMakeVisible requires gl_SemanticsAcquire or gl_SemanticsAcquireRelease
ERROR: 0:26: 'memoryBarrier' : gl_SemanticsMakeAvailable requires gl_SemanticsRelease or gl_SemanticsAcquireRelease
ERROR: 12 compilation errors. No code generated.
SPIR-V is not generated for failed compile or link

View File

@@ -11,7 +11,7 @@ spv.specConstant.vert
Source GLSL 400
Name 4 "main"
Name 9 "arraySize"
Name 14 "foo(vf4[s2543];"
Name 14 "foo(vf4[s2765];"
Name 13 "p"
Name 17 "builtin_spec_constant("
Name 20 "color"
@@ -102,10 +102,10 @@ spv.specConstant.vert
Store 20(color) 46
48: 10 Load 22(ucol)
Store 47(param) 48
49: 2 FunctionCall 14(foo(vf4[s2543];) 47(param)
49: 2 FunctionCall 14(foo(vf4[s2765];) 47(param)
Return
FunctionEnd
14(foo(vf4[s2543];): 2 Function None 12
14(foo(vf4[s2765];): 2 Function None 12
13(p): 11(ptr) FunctionParameter
15: Label
54: 24(ptr) AccessChain 53(dupUcol) 23

View File

@@ -0,0 +1,61 @@
#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;
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);
}

View File

@@ -0,0 +1,28 @@
#version 450
#extension GL_KHR_memory_scope_semantics : require
shared uint value;
shared int atomi;
shared uint atomu;
layout(binding = 0, r32ui) workgroupcoherent uniform uimage2D imageu;
layout(binding = 1, r32i) coherent uniform iimage2D imagei;
layout (binding = 2) buffer BufferU { workgroupcoherent uint x; } bufferu;
layout (binding = 3) subgroupcoherent buffer BufferI { uint x; } bufferi;
void main()
{
atomicStore(atomu, value, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsAcquire);
int origi = imageAtomicLoad(imagei, ivec2(0,0), gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelease);
atomicStore(atomu, value, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsAcquireRelease);
atomicStore(atomu, value, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_StorageSemanticsBuffer);
origi = imageAtomicLoad(imagei, ivec2(0,0), gl_ScopeDevice, gl_SemanticsAcquire, gl_SemanticsAcquire);
memoryBarrier(gl_ScopeWorkgroup, gl_StorageSemanticsBuffer | gl_StorageSemanticsShared, 0);
memoryBarrier(gl_ScopeWorkgroup, 0, gl_SemanticsRelease);
memoryBarrier(gl_ScopeWorkgroup, gl_StorageSemanticsBuffer | gl_StorageSemanticsShared, gl_SemanticsRelease | gl_SemanticsAcquire);
atomicAdd(atomu, value, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelease | gl_SemanticsAcquire);
uint origu = atomicCompSwap(atomu, 10u, value, gl_ScopeDevice, gl_StorageSemanticsBuffer | gl_StorageSemanticsShared, gl_SemanticsAcquire, gl_StorageSemanticsBuffer | gl_StorageSemanticsShared, gl_SemanticsAcquireRelease);
memoryBarrier(gl_ScopeWorkgroup, gl_StorageSemanticsBuffer, gl_SemanticsRelease | gl_SemanticsMakeVisible);
memoryBarrier(gl_ScopeWorkgroup, gl_StorageSemanticsBuffer, gl_SemanticsAcquire | gl_SemanticsMakeAvailable);
}