Test for spv1.6 + memory model HelperInvocation
authorGraeme Leese <gleese@broadcom.com>
Fri, 14 Oct 2022 14:03:14 +0000 (15:03 +0100)
committerGraeme Leese <gleese@broadcom.com>
Fri, 14 Oct 2022 14:30:03 +0000 (15:30 +0100)
This should generate a Volatile tag on the access, not on the variable
itself.

Test/baseResults/spv.1.6.helperInvocation.memmodel.frag.out [new file with mode: 0644]
Test/spv.1.6.helperInvocation.memmodel.frag [new file with mode: 0644]
gtests/Spv.FromFile.cpp

diff --git a/Test/baseResults/spv.1.6.helperInvocation.memmodel.frag.out b/Test/baseResults/spv.1.6.helperInvocation.memmodel.frag.out
new file mode 100644 (file)
index 0000000..fea4e45
--- /dev/null
@@ -0,0 +1,48 @@
+spv.1.6.helperInvocation.memmodel.frag
+// Module Version 10600
+// Generated by (magic number): 8000b
+// Id's are bound by 21
+
+                              Capability Shader
+                              Capability VulkanMemoryModelKHR
+                              Capability DemoteToHelperInvocationEXT
+                              Extension  "SPV_EXT_demote_to_helper_invocation"
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical VulkanKHR
+                              EntryPoint Fragment 4  "main" 9 14
+                              ExecutionMode 4 OriginUpperLeft
+                              Source ESSL 310
+                              SourceExtension  "GL_EXT_demote_to_helper_invocation"
+                              Name 4  "main"
+                              Name 7  "B"
+                              MemberName 7(B) 0  "o"
+                              Name 9  ""
+                              Name 14  "gl_HelperInvocation"
+                              MemberDecorate 7(B) 0 Offset 0
+                              Decorate 7(B) Block
+                              Decorate 9 DescriptorSet 0
+                              Decorate 9 Binding 0
+                              Decorate 14(gl_HelperInvocation) BuiltIn HelperInvocation
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+            7(B):             TypeStruct 6(float)
+               8:             TypePointer StorageBuffer 7(B)
+               9:      8(ptr) Variable StorageBuffer
+              10:             TypeInt 32 1
+              11:     10(int) Constant 0
+              12:             TypeBool
+              13:             TypePointer Input 12(bool)
+14(gl_HelperInvocation):     13(ptr) Variable Input
+              16:    6(float) Constant 1065353216
+              17:    6(float) Constant 0
+              19:             TypePointer StorageBuffer 6(float)
+         4(main):           2 Function None 3
+               5:             Label
+                              DemoteToHelperInvocationEXT
+              15:    12(bool) Load 14(gl_HelperInvocation) Volatile 
+              18:    6(float) Select 15 16 17
+              20:     19(ptr) AccessChain 9 11
+                              Store 20 18
+                              Return
+                              FunctionEnd
diff --git a/Test/spv.1.6.helperInvocation.memmodel.frag b/Test/spv.1.6.helperInvocation.memmodel.frag
new file mode 100644 (file)
index 0000000..b727f8e
--- /dev/null
@@ -0,0 +1,16 @@
+#version 310 es\r
+\r
+#pragma use_vulkan_memory_model\r
+\r
+#extension GL_EXT_demote_to_helper_invocation : require\r
+\r
+precision highp float;\r
+\r
+layout (set=0, binding=0) buffer B {\r
+   float o;\r
+};\r
+\r
+void main() {\r
+   demote;\r
+   o = gl_HelperInvocation ? 1.0 : 0.0;\r
+}\r
index 93e364d..e1b7a25 100644 (file)
@@ -660,6 +660,7 @@ INSTANTIATE_TEST_SUITE_P(
     ::testing::ValuesIn(std::vector<std::string>({
         "spv.1.6.conditionalDiscard.frag",
         "spv.1.6.helperInvocation.frag",
+        "spv.1.6.helperInvocation.memmodel.frag",
         "spv.1.6.specConstant.comp",
         "spv.1.6.samplerBuffer.frag",
         "spv.1.6.separate.frag",