atomic = true;
break;
+ case glslang::EOpAtomicCounterAdd:
+ case glslang::EOpAtomicCounterSubtract:
+ case glslang::EOpAtomicCounterMin:
+ case glslang::EOpAtomicCounterMax:
+ case glslang::EOpAtomicCounterAnd:
+ case glslang::EOpAtomicCounterOr:
+ case glslang::EOpAtomicCounterXor:
+ case glslang::EOpAtomicCounterExchange:
+ case glslang::EOpAtomicCounterCompSwap:
+ builder.addExtension("SPV_KHR_shader_atomic_counter_ops");
+ builder.addCapability(spv::CapabilityAtomicStorageOps);
+ atomic = true;
+ break;
+
default:
break;
}
case glslang::EOpAtomicXor:
case glslang::EOpAtomicExchange:
case glslang::EOpAtomicCompSwap:
+ case glslang::EOpAtomicCounterAdd:
+ case glslang::EOpAtomicCounterSubtract:
+ case glslang::EOpAtomicCounterMin:
+ case glslang::EOpAtomicCounterMax:
+ case glslang::EOpAtomicCounterAnd:
+ case glslang::EOpAtomicCounterOr:
+ case glslang::EOpAtomicCounterXor:
+ case glslang::EOpAtomicCounterExchange:
+ case glslang::EOpAtomicCounterCompSwap:
if (arg == 0)
lvalue = true;
break;
switch (op) {
case glslang::EOpAtomicAdd:
case glslang::EOpImageAtomicAdd:
+ case glslang::EOpAtomicCounterAdd:
opCode = spv::OpAtomicIAdd;
break;
+ case glslang::EOpAtomicCounterSubtract:
+ opCode = spv::OpAtomicISub;
+ break;
case glslang::EOpAtomicMin:
case glslang::EOpImageAtomicMin:
+ case glslang::EOpAtomicCounterMin:
opCode = typeProxy == glslang::EbtUint ? spv::OpAtomicUMin : spv::OpAtomicSMin;
break;
case glslang::EOpAtomicMax:
case glslang::EOpImageAtomicMax:
+ case glslang::EOpAtomicCounterMax:
opCode = typeProxy == glslang::EbtUint ? spv::OpAtomicUMax : spv::OpAtomicSMax;
break;
case glslang::EOpAtomicAnd:
case glslang::EOpImageAtomicAnd:
+ case glslang::EOpAtomicCounterAnd:
opCode = spv::OpAtomicAnd;
break;
case glslang::EOpAtomicOr:
case glslang::EOpImageAtomicOr:
+ case glslang::EOpAtomicCounterOr:
opCode = spv::OpAtomicOr;
break;
case glslang::EOpAtomicXor:
case glslang::EOpImageAtomicXor:
+ case glslang::EOpAtomicCounterXor:
opCode = spv::OpAtomicXor;
break;
case glslang::EOpAtomicExchange:
case glslang::EOpImageAtomicExchange:
+ case glslang::EOpAtomicCounterExchange:
opCode = spv::OpAtomicExchange;
break;
case glslang::EOpAtomicCompSwap:
case glslang::EOpImageAtomicCompSwap:
+ case glslang::EOpAtomicCounterCompSwap:
opCode = spv::OpAtomicCompareExchange;
break;
case glslang::EOpAtomicCounterIncrement:
case 5009: return "ImageGatherBiasLodAMD";
#endif
+ case 4445: return "AtomicStorageOps";
+
case 4447: return "SampleMaskPostDepthCoverage";
#ifdef NV_EXTENSIONS
case 5251: return "GeometryShaderPassthroughNV";
struct SS { float f; S s; };\r
out SS outSS;\r
\r
+layout(binding = 0) uniform atomic_uint aui;\r
+uint ui;\r
+\r
void foo()\r
{\r
SS::f;\r
+ atomicCounterAdd(aui, ui); // ERROR, need 4.6\r
+ atomicCounterSubtract(aui, ui); // ERROR, need 4.6\r
+ atomicCounterMin(aui, ui); // ERROR, need 4.6\r
+ atomicCounterMax(aui, ui); // ERROR, need 4.6\r
+ atomicCounterAnd(aui, ui); // ERROR, need 4.6\r
+ atomicCounterOr(aui, ui); // ERROR, need 4.6\r
+ atomicCounterXor(aui, ui); // ERROR, need 4.6\r
+ atomicCounterExchange(aui, ui); // ERROR, need 4.6\r
+ atomicCounterCompSwap(aui, ui, ui); // ERROR, need 4.6\r
}\r
; // ERROR: no extraneous semicolons\r
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
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)
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)
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)
--- /dev/null
+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
--- /dev/null
+#version 460 core\r
+\r
+layout(binding = 0) uniform atomic_uint aui;\r
+uint ui;\r
+\r
+void main()\r
+{\r
+ atomicCounterAdd(aui, ui);\r
+ atomicCounterSubtract(aui, ui);\r
+ atomicCounterMin(aui, ui);\r
+ atomicCounterMax(aui, ui);\r
+ atomicCounterAnd(aui, ui);\r
+ atomicCounterOr(aui, ui);\r
+ atomicCounterXor(aui, ui);\r
+ atomicCounterExchange(aui, ui);\r
+ atomicCounterCompSwap(aui, ui, ui);\r
+}\r
EOpAtomicCounterIncrement,
EOpAtomicCounterDecrement,
EOpAtomicCounter,
+ EOpAtomicCounterAdd,
+ EOpAtomicCounterSubtract,
+ EOpAtomicCounterMin,
+ EOpAtomicCounterMax,
+ EOpAtomicCounterAnd,
+ EOpAtomicCounterOr,
+ EOpAtomicCounterXor,
+ EOpAtomicCounterExchange,
+ EOpAtomicCounterCompSwap,
EOpAny,
EOpAll,
if ((profile != EEsProfile && version >= 300) ||
(profile == EEsProfile && version >= 310)) {
commonBuiltins.append(
- "uint atomicCounterIncrement(atomic_uint x);"
- "uint atomicCounterDecrement(atomic_uint x);"
- "uint atomicCounter(atomic_uint x);"
+ "uint atomicCounterIncrement(atomic_uint);"
+ "uint atomicCounterDecrement(atomic_uint);"
+ "uint atomicCounter(atomic_uint);"
+
+ "\n");
+ }
+ if (profile != EEsProfile && version >= 460) {
+ commonBuiltins.append(
+ "uint atomicCounterAdd(atomic_uint, uint);"
+ "uint atomicCounterSubtract(atomic_uint, uint);"
+ "uint atomicCounterMin(atomic_uint, uint);"
+ "uint atomicCounterMax(atomic_uint, uint);"
+ "uint atomicCounterAnd(atomic_uint, uint);"
+ "uint atomicCounterOr(atomic_uint, uint);"
+ "uint atomicCounterXor(atomic_uint, uint);"
+ "uint atomicCounterExchange(atomic_uint, uint);"
+ "uint atomicCounterCompSwap(atomic_uint, uint, uint);"
"\n");
}
symbolTable.relateToOperator("atomicCounterDecrement", EOpAtomicCounterDecrement);
symbolTable.relateToOperator("atomicCounter", EOpAtomicCounter);
+ if (profile != EEsProfile && version >= 460) {
+ symbolTable.relateToOperator("atomicCounterAdd", EOpAtomicCounterAdd);
+ symbolTable.relateToOperator("atomicCounterSubtract", EOpAtomicCounterSubtract);
+ symbolTable.relateToOperator("atomicCounterMin", EOpAtomicCounterMin);
+ symbolTable.relateToOperator("atomicCounterMax", EOpAtomicCounterMax);
+ symbolTable.relateToOperator("atomicCounterAnd", EOpAtomicCounterAnd);
+ symbolTable.relateToOperator("atomicCounterOr", EOpAtomicCounterOr);
+ symbolTable.relateToOperator("atomicCounterXor", EOpAtomicCounterXor);
+ symbolTable.relateToOperator("atomicCounterExchange", EOpAtomicCounterExchange);
+ symbolTable.relateToOperator("atomicCounterCompSwap", EOpAtomicCounterCompSwap);
+ }
+
symbolTable.relateToOperator("fma", EOpFma);
symbolTable.relateToOperator("frexp", EOpFrexp);
symbolTable.relateToOperator("ldexp", EOpLdexp);
case EOpAtomicExchange: out.debug << "AtomicExchange"; break;
case EOpAtomicCompSwap: out.debug << "AtomicCompSwap"; break;
+ case EOpAtomicCounterAdd: out.debug << "AtomicCounterAdd"; break;
+ case EOpAtomicCounterSubtract: out.debug << "AtomicCounterSubtract"; break;
+ case EOpAtomicCounterMin: out.debug << "AtomicCounterMin"; break;
+ case EOpAtomicCounterMax: out.debug << "AtomicCounterMax"; break;
+ case EOpAtomicCounterAnd: out.debug << "AtomicCounterAnd"; break;
+ case EOpAtomicCounterOr: out.debug << "AtomicCounterOr"; break;
+ case EOpAtomicCounterXor: out.debug << "AtomicCounterXor"; break;
+ case EOpAtomicCounterExchange: out.debug << "AtomicCounterExchange"; break;
+ case EOpAtomicCounterCompSwap: out.debug << "AtomicCounterCompSwap"; break;
+
case EOpImageQuerySize: out.debug << "imageQuerySize"; break;
case EOpImageQuerySamples: out.debug << "imageQuerySamples"; break;
case EOpImageLoad: out.debug << "imageLoad"; break;
INSTANTIATE_TEST_CASE_P(
Glsl, CompileOpenGLToSpirvTest,
::testing::ValuesIn(std::vector<std::string>({
+ "spv.460.frag",
"spv.atomic.comp",
"spv.glFragColor.frag",
"spv.specConst.vert",