Fix #1331: Emit SPV_GOOGLE_hlsl_functionality1 for counters.
authorJohn Kessenich <cepheus@frii.com>
Fri, 6 Apr 2018 01:35:38 +0000 (19:35 -0600)
committerJohn Kessenich <cepheus@frii.com>
Fri, 6 Apr 2018 01:35:38 +0000 (19:35 -0600)
It was missing when there were no semantics.

SPIRV/GlslangToSpv.cpp
Test/baseResults/hlsl.noSemantic.functionality1.comp.out [new file with mode: 0644]
Test/hlsl.noSemantic.functionality1.comp [new file with mode: 0644]
Test/runtests

index 1434cba..6a28a1c 100755 (executable)
@@ -1279,8 +1279,10 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol)
                         id = getSymbolId(it->second);
                         if (id != spv::NoResult) {
                             spv::Id counterId = getSymbolId(symbol);
-                            if (counterId != spv::NoResult)
+                            if (counterId != spv::NoResult) {
+                                builder.addExtension("SPV_GOOGLE_hlsl_functionality1");
                                 builder.addDecorationId(id, spv::DecorationHlslCounterBufferGOOGLE, counterId);
+                            }
                         }
                     }
                 }
diff --git a/Test/baseResults/hlsl.noSemantic.functionality1.comp.out b/Test/baseResults/hlsl.noSemantic.functionality1.comp.out
new file mode 100644 (file)
index 0000000..8fd35e9
--- /dev/null
@@ -0,0 +1,63 @@
+hlsl.noSemantic.functionality1.comp
+// Module Version 10000
+// Generated by (magic number): 80006
+// Id's are bound by 31
+
+                              Capability Shader
+                              Extension  "SPV_GOOGLE_hlsl_functionality1"
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint GLCompute 4  "main"
+                              ExecutionMode 4 LocalSize 1 1 1
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 6  "@main("
+                              Name 11  "Buf"
+                              MemberName 11(Buf) 0  "@data"
+                              Name 13  "Buf"
+                              Name 16  "Buf@count"
+                              MemberName 16(Buf@count) 0  "@count"
+                              Name 18  "Buf@count"
+                              Decorate 10 ArrayStride 16
+                              MemberDecorate 11(Buf) 0 Offset 0
+                              Decorate 11(Buf) BufferBlock
+                              Decorate 13(Buf) DescriptorSet 0
+                              Decorate 13(Buf) Binding 0
+                              MemberDecorate 16(Buf@count) 0 Offset 0
+                              Decorate 16(Buf@count) BufferBlock
+                              Decorate 18(Buf@count) DescriptorSet 0
+                              DecorateId 13(Buf) DecorationHlslCounterBufferGOOGLE 18(Buf@count)
+               2:             TypeVoid
+               3:             TypeFunction 2
+               8:             TypeFloat 32
+               9:             TypeVector 8(float) 4
+              10:             TypeRuntimeArray 9(fvec4)
+         11(Buf):             TypeStruct 10
+              12:             TypePointer Uniform 11(Buf)
+         13(Buf):     12(ptr) Variable Uniform
+              14:             TypeInt 32 1
+              15:     14(int) Constant 0
+   16(Buf@count):             TypeStruct 14(int)
+              17:             TypePointer Uniform 16(Buf@count)
+   18(Buf@count):     17(ptr) Variable Uniform
+              19:             TypePointer Uniform 14(int)
+              21:     14(int) Constant 1
+              22:             TypeInt 32 0
+              23:     22(int) Constant 1
+              24:     22(int) Constant 0
+              26:    8(float) Constant 1065353216
+              27:    9(fvec4) ConstantComposite 26 26 26 26
+              28:             TypePointer Uniform 9(fvec4)
+         4(main):           2 Function None 3
+               5:             Label
+              30:           2 FunctionCall 6(@main()
+                              Return
+                              FunctionEnd
+       6(@main():           2 Function None 3
+               7:             Label
+              20:     19(ptr) AccessChain 18(Buf@count) 15
+              25:     22(int) AtomicIAdd 20 23 24 21
+              29:     28(ptr) AccessChain 13(Buf) 15 25
+                              Store 29 27
+                              Return
+                              FunctionEnd
diff --git a/Test/hlsl.noSemantic.functionality1.comp b/Test/hlsl.noSemantic.functionality1.comp
new file mode 100644 (file)
index 0000000..ac9a7a9
--- /dev/null
@@ -0,0 +1,7 @@
+AppendStructuredBuffer<float4> Buf : register(u0);\r
+\r
+[numthreads(1, 1, 1)]\r
+void main()\r
+{\r
+       Buf.Append(1.0f.xxxx);\r
+}
\ No newline at end of file
index f8b4bc5..6ebb6ee 100755 (executable)
@@ -207,6 +207,9 @@ diff -b $BASEDIR/hlsl.y-negate-3.vert.out $TARGETDIR/hlsl.y-negate-3.vert.out ||
 $EXE -H -e main -D -Od -fhlsl_functionality1 hlsl.structbuffer.incdec.frag > \
     $TARGETDIR/hlsl.structbuffer.incdec.frag.hlslfun1.out
 diff -b $BASEDIR/hlsl.structbuffer.incdec.frag.hlslfun1.out $TARGETDIR/hlsl.structbuffer.incdec.frag.hlslfun1.out || HASERROR=1
+$EXE -H -e main -D -Od -fhlsl_functionality1 hlsl.noSemantic.functionality1.comp > \
+    $TARGETDIR/hlsl.noSemantic.functionality1.comp.out
+diff -b $BASEDIR/hlsl.noSemantic.functionality1.comp.out $TARGETDIR/hlsl.noSemantic.functionality1.comp.out || HASERROR=1
 
 #
 # Final checking