GLSL 4.6: Implement atomic counter ops and SPV_KHR_shader_atomic_counter_ops.

This commit is contained in:
John Kessenich
2017-07-23 16:08:26 -06:00
parent de16e52b25
commit 0d0c6d38f0
10 changed files with 202 additions and 8 deletions

View File

@@ -22,8 +22,20 @@ out SA outSA;
struct SS { float f; S s; };
out SS outSS;
layout(binding = 0) uniform atomic_uint aui;
uint ui;
void foo()
{
SS::f;
atomicCounterAdd(aui, ui); // ERROR, need 4.6
atomicCounterSubtract(aui, ui); // ERROR, need 4.6
atomicCounterMin(aui, ui); // ERROR, need 4.6
atomicCounterMax(aui, ui); // ERROR, need 4.6
atomicCounterAnd(aui, ui); // ERROR, need 4.6
atomicCounterOr(aui, ui); // ERROR, need 4.6
atomicCounterXor(aui, ui); // ERROR, need 4.6
atomicCounterExchange(aui, ui); // ERROR, need 4.6
atomicCounterCompSwap(aui, ui, ui); // ERROR, need 4.6
}
; // ERROR: no extraneous semicolons

View File

@@ -1,9 +1,18 @@
450.vert
ERROR: 0:12: 'out' : cannot be bool
ERROR: 0:13: 'sampler2D' : sampler/image types can only be used in uniform variables or function parameters: outo
ERROR: 0:27: '::' : not supported
ERROR: 0:29: 'extraneous semicolon' : not supported for this version or the enabled extensions
ERROR: 4 compilation errors. No code generated.
ERROR: 0:30: '::' : not supported
ERROR: 0:31: 'atomicCounterAdd' : no matching overloaded function found
ERROR: 0:32: 'atomicCounterSubtract' : no matching overloaded function found
ERROR: 0:33: 'atomicCounterMin' : no matching overloaded function found
ERROR: 0:34: 'atomicCounterMax' : no matching overloaded function found
ERROR: 0:35: 'atomicCounterAnd' : no matching overloaded function found
ERROR: 0:36: 'atomicCounterOr' : no matching overloaded function found
ERROR: 0:37: 'atomicCounterXor' : no matching overloaded function found
ERROR: 0:38: 'atomicCounterExchange' : no matching overloaded function found
ERROR: 0:39: 'atomicCounterCompSwap' : no matching overloaded function found
ERROR: 0:41: 'extraneous semicolon' : not supported for this version or the enabled extensions
ERROR: 13 compilation errors. No code generated.
Shader version: 450
@@ -21,8 +30,27 @@ ERROR: node is still EOpNull!
0:9 2 (const int)
0:9 Constant:
0:9 4.500000
0:25 Function Definition: foo( ( global void)
0:25 Function Parameters:
0:28 Function Definition: foo( ( global void)
0:28 Function Parameters:
0:? Sequence
0:31 Constant:
0:31 0.000000
0:32 Constant:
0:32 0.000000
0:33 Constant:
0:33 0.000000
0:34 Constant:
0:34 0.000000
0:35 Constant:
0:35 0.000000
0:36 Constant:
0:36 0.000000
0:37 Constant:
0:37 0.000000
0:38 Constant:
0:38 0.000000
0:39 Constant:
0:39 0.000000
0:? Linker Objects
0:? 'anon@0' ( out block{ out 3-element array of float CullDistance gl_CullDistance})
0:? 'outb' ( smooth out bool)
@@ -34,6 +62,8 @@ ERROR: node is still EOpNull!
0:? 'outsa' ( smooth out 4-element array of structure{ global float f})
0:? 'outSA' ( smooth out structure{ global 4-element array of float f})
0:? 'outSS' ( smooth out structure{ global float f, global structure{ global float f} s})
0:? 'aui' (layout( binding=0 offset=0) uniform atomic_uint)
0:? 'ui' ( global uint)
0:? 'gl_VertexID' ( gl_VertexId int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)
@@ -67,6 +97,8 @@ ERROR: node is still EOpNull!
0:? 'outsa' ( smooth out 4-element array of structure{ global float f})
0:? 'outSA' ( smooth out structure{ global 4-element array of float f})
0:? 'outSS' ( smooth out structure{ global float f, global structure{ global float f} s})
0:? 'aui' (layout( binding=0 offset=0) uniform atomic_uint)
0:? 'ui' ( global uint)
0:? 'gl_VertexID' ( gl_VertexId int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)

View File

@@ -0,0 +1,51 @@
spv.460.frag
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 32
Capability Shader
Capability AtomicStorage
Capability AtomicStorageOps
Extension "SPV_KHR_shader_atomic_counter_ops"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main"
ExecutionMode 4 OriginLowerLeft
Source GLSL 460
Name 4 "main"
Name 8 "aui"
Name 10 "ui"
Decorate 8(aui) Offset 0
Decorate 8(aui) Binding 0
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
7: TypePointer AtomicCounter 6(int)
8(aui): 7(ptr) Variable AtomicCounter
9: TypePointer Private 6(int)
10(ui): 9(ptr) Variable Private
12: 6(int) Constant 1
13: 6(int) Constant 0
4(main): 2 Function None 3
5: Label
11: 6(int) Load 10(ui)
14: 6(int) AtomicIAdd 8(aui) 12 13 11
15: 6(int) Load 10(ui)
16: 6(int) AtomicISub 8(aui) 12 13 15
17: 6(int) Load 10(ui)
18: 6(int) AtomicUMin 8(aui) 12 13 17
19: 6(int) Load 10(ui)
20: 6(int) AtomicUMax 8(aui) 12 13 19
21: 6(int) Load 10(ui)
22: 6(int) AtomicAnd 8(aui) 12 13 21
23: 6(int) Load 10(ui)
24: 6(int) AtomicOr 8(aui) 12 13 23
25: 6(int) Load 10(ui)
26: 6(int) AtomicXor 8(aui) 12 13 25
27: 6(int) Load 10(ui)
28: 6(int) AtomicExchange 8(aui) 12 13 27
29: 6(int) Load 10(ui)
30: 6(int) Load 10(ui)
31: 6(int) AtomicCompareExchange 8(aui) 12 13 13 30 29
Return
FunctionEnd

17
Test/spv.460.frag Normal file
View File

@@ -0,0 +1,17 @@
#version 460 core
layout(binding = 0) uniform atomic_uint aui;
uint ui;
void main()
{
atomicCounterAdd(aui, ui);
atomicCounterSubtract(aui, ui);
atomicCounterMin(aui, ui);
atomicCounterMax(aui, ui);
atomicCounterAnd(aui, ui);
atomicCounterOr(aui, ui);
atomicCounterXor(aui, ui);
atomicCounterExchange(aui, ui);
atomicCounterCompSwap(aui, ui, ui);
}