Forbid memoryBarrierAtomicCounter for Vulkan compiles
authorJeff Bolz <jbolz@nvidia.com>
Tue, 17 Mar 2020 04:53:04 +0000 (23:53 -0500)
committerJeff Bolz <jbolz@nvidia.com>
Tue, 17 Mar 2020 04:53:04 +0000 (23:53 -0500)
Test/baseResults/spv.atomicCounter.comp.out [new file with mode: 0644]
Test/spv.atomicCounter.comp [new file with mode: 0644]
glslang/MachineIndependent/Initialize.cpp
gtests/Spv.FromFile.cpp

diff --git a/Test/baseResults/spv.atomicCounter.comp.out b/Test/baseResults/spv.atomicCounter.comp.out
new file mode 100644 (file)
index 0000000..46cccc0
--- /dev/null
@@ -0,0 +1,15 @@
+spv.atomicCounter.comp
+ERROR: 0:5: 'atomic counter types' : not allowed when using GLSL for Vulkan 
+ERROR: 0:7: 'atomic counter types' : not allowed when using GLSL for Vulkan 
+ERROR: 0:14: 'atomic counter types' : not allowed when using GLSL for Vulkan 
+ERROR: 0:16: 'atomicCounterIncrement' : no matching overloaded function found 
+ERROR: 0:16: 'return' : type does not match, or is not convertible to, the function's return type 
+ERROR: 0:21: 'memoryBarrierAtomicCounter' : no matching overloaded function found 
+ERROR: 0:23: 'atomicCounter' : no matching overloaded function found 
+ERROR: 0:23: '=' :  cannot convert from ' const float' to ' temp highp uint'
+ERROR: 0:24: 'atomicCounterDecrement' : no matching overloaded function found 
+ERROR: 0:25: 'atomicCounterIncrement' : no matching overloaded function found 
+ERROR: 10 compilation errors.  No code generated.
+
+
+SPIR-V is not generated for failed compile or link
diff --git a/Test/spv.atomicCounter.comp b/Test/spv.atomicCounter.comp
new file mode 100644 (file)
index 0000000..ecb2304
--- /dev/null
@@ -0,0 +1,26 @@
+#version 450\r
+\r
+\r
+\r
+layout(binding = 0) uniform atomic_uint counter;\r
+\r
+layout(binding = 0, offset = 4) uniform atomic_uint countArr[4];\r
+shared uint value;\r
+\r
+int arrX[gl_WorkGroupSize.x];\r
+int arrY[gl_WorkGroupSize.y];\r
+int arrZ[gl_WorkGroupSize.z];\r
+\r
+uint func(atomic_uint c)\r
+{\r
+    return atomicCounterIncrement(c);\r
+}\r
+\r
+void main()\r
+{\r
+    memoryBarrierAtomicCounter();\r
+    func(counter);\r
+    uint val = atomicCounter(countArr[2]);\r
+    atomicCounterDecrement(counter);\r
+    atomicCounterIncrement(counter);\r
+}\r
index 7076e62..6869ef2 100644 (file)
@@ -4067,10 +4067,10 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
     }
 #ifndef GLSLANG_WEB
     if ((profile != EEsProfile && version >= 420) || esBarrier) {
-        commonBuiltins.append(
-            "void memoryBarrierAtomicCounter();"
-            "void memoryBarrierImage();"
-            );
+        if (spvVersion.vulkan == 0) {
+            commonBuiltins.append("void memoryBarrierAtomicCounter();");
+        }
+        commonBuiltins.append("void memoryBarrierImage();");
     }
     if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
         stageBuiltins[EShLangMeshNV].append(
index 244fa1e..dc88fe1 100644 (file)
@@ -271,6 +271,7 @@ INSTANTIATE_TEST_CASE_P(
         "spv.always-discard2.frag",
         "spv.arbPostDepthCoverage.frag",
         "spv.arbPostDepthCoverage_Error.frag",
+        "spv.atomicCounter.comp",
         "spv.bitCast.frag",
         "spv.bool.vert",
         "spv.boolInBlock.frag",