Legalization: Omit legalization warning when spirv-opt is linked.
authorGregF <greg@LunarG.com>
Mon, 5 Mar 2018 21:34:15 +0000 (14:34 -0700)
committerGregF <greg@LunarG.com>
Tue, 6 Mar 2018 20:00:08 +0000 (13:00 -0700)
12 files changed:
Test/baseLegalResults/hlsl.aliasOpaque.frag.out
Test/baseLegalResults/hlsl.array.flatten.frag.out [new file with mode: 0644]
Test/baseLegalResults/hlsl.flattenOpaque.frag.out
Test/baseLegalResults/hlsl.flattenOpaqueInit.vert.out
Test/baseLegalResults/hlsl.flattenOpaqueInitMix.vert.out
Test/baseLegalResults/hlsl.flattenSubset.frag.out
Test/baseLegalResults/hlsl.flattenSubset2.frag.out
Test/baseLegalResults/hlsl.partialFlattenLocal.vert.out
Test/baseLegalResults/hlsl.partialFlattenMixed.vert.out
Test/baseLegalResults/hlsl.samplecmp.dualmode.frag.out [new file with mode: 0644]
gtests/Hlsl.FromFile.cpp
hlsl/hlslParseHelper.cpp

index 621fae5186c3231572ddfeca736637482cd6758e..7ce3058dceffbdf74a97678a5561ce8b75e7a94d 100644 (file)
@@ -1,5 +1,4 @@
 hlsl.aliasOpaque.frag
-WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80005
 // Id's are bound by 87
diff --git a/Test/baseLegalResults/hlsl.array.flatten.frag.out b/Test/baseLegalResults/hlsl.array.flatten.frag.out
new file mode 100644 (file)
index 0000000..62e0596
--- /dev/null
@@ -0,0 +1,59 @@
+hlsl.array.flatten.frag
+// Module Version 10000
+// Generated by (magic number): 80005
+// Id's are bound by 180
+
+                              Capability Shader
+                              Capability Sampled1D
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Fragment 4  "main" 110
+                              ExecutionMode 4 OriginUpperLeft
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 42  "g_tex"
+                              Name 47  "g_samp"
+                              Name 110  "ps_output.color"
+                              Decorate 42(g_tex) DescriptorSet 0
+                              Decorate 47(g_samp) DescriptorSet 0
+                              Decorate 110(ps_output.color) Location 0
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+              11:             TypeImage 6(float) 1D sampled format:Unknown
+              12:             TypeInt 32 0
+              13:     12(int) Constant 3
+              14:             TypeArray 11 13
+              16:             TypeSampler
+              17:             TypeArray 16 13
+              30:             TypeInt 32 1
+              35:     30(int) Constant 1
+              41:             TypePointer UniformConstant 14
+       42(g_tex):     41(ptr) Variable UniformConstant
+              43:             TypePointer UniformConstant 11
+              46:             TypePointer UniformConstant 17
+      47(g_samp):     46(ptr) Variable UniformConstant
+              48:             TypePointer UniformConstant 16
+              51:             TypeSampledImage 11
+              53:    6(float) Constant 1045220557
+             109:             TypePointer Output 7(fvec4)
+110(ps_output.color):    109(ptr) Variable Output
+         4(main):           2 Function None 3
+               5:             Label
+             139:     43(ptr) AccessChain 42(g_tex) 35
+             140:          11 Load 139
+             141:     48(ptr) AccessChain 47(g_samp) 35
+             142:          16 Load 141
+             143:          51 SampledImage 140 142
+             144:    7(fvec4) ImageSampleImplicitLod 143 53
+             133:          14 Load 42(g_tex)
+             173:          11 CompositeExtract 133 2
+             134:          17 Load 47(g_samp)
+             179:          16 CompositeExtract 134 2
+             150:          51 SampledImage 173 179
+             151:    7(fvec4) ImageSampleImplicitLod 150 53
+             136:    7(fvec4) FAdd 144 151
+                              Store 110(ps_output.color) 136
+                              Return
+                              FunctionEnd
index 1e90a0869a6a55cb6cb26e5d526fedd6d62740cd..16f060dc0cb7c2f08516dd96a60d2e71a9e2d824 100644 (file)
@@ -1,5 +1,4 @@
 hlsl.flattenOpaque.frag
-WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80005
 // Id's are bound by 185
index d5800557e1a109af89c9131ac826254c03300d9d..c181243f2106ee5f8cab61cdc9786c56564bd64c 100644 (file)
@@ -1,5 +1,4 @@
 hlsl.flattenOpaqueInit.vert
-WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80005
 // Id's are bound by 134
index 054d4bda8ffaa5ad7e205b3526948f907c14fcb7..aca925fff6a27848ccb7488b11791dfead335fd7 100644 (file)
@@ -1,5 +1,4 @@
 hlsl.flattenOpaqueInitMix.vert
-WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80005
 // Id's are bound by 80
index bbffe8ae077da3944288c90d66beb740ea1c9ca0..01d6699f2354dd8f25b1958b1b21e3f534f391c6 100755 (executable)
@@ -1,5 +1,4 @@
 hlsl.flattenSubset.frag
-WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80005
 // Id's are bound by 66
index ea93e7a1e974aa621822f14d47d5dd9c1bb0e88b..bb1ec4b449b5bcad999afb5516e049e9a908dfb6 100755 (executable)
@@ -1,5 +1,4 @@
 hlsl.flattenSubset2.frag
-WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80005
 // Id's are bound by 53
index 0ec29fb05f85fa8f0cc3734c556b9ae167d48604..104a729062c83895e34c4b67199c6d67143d61c6 100755 (executable)
@@ -1,5 +1,4 @@
 hlsl.partialFlattenLocal.vert
-WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80005
 // Id's are bound by 169
index 8497977c271f677b719bf45c89e489d67826f5af..1bee2bd4f5d0454c701efc583deac6665948953e 100755 (executable)
@@ -1,5 +1,4 @@
 hlsl.partialFlattenMixed.vert
-WARNING: AST will form illegal SPIR-V; need to transform to legalize
 // Module Version 10000
 // Generated by (magic number): 80005
 // Id's are bound by 36
diff --git a/Test/baseLegalResults/hlsl.samplecmp.dualmode.frag.out b/Test/baseLegalResults/hlsl.samplecmp.dualmode.frag.out
new file mode 100644 (file)
index 0000000..8577f73
--- /dev/null
@@ -0,0 +1,28 @@
+hlsl.samplecmp.dualmode.frag
+// Module Version 10000
+// Generated by (magic number): 80005
+// Id's are bound by 42
+
+                              Capability Shader
+                              Capability Sampled1D
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Fragment 4  "main" 41
+                              ExecutionMode 4 OriginUpperLeft
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 41  "@entryPointOutput"
+                              Decorate 41(@entryPointOutput) Location 0
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+              36:    6(float) Constant 0
+              37:    7(fvec4) ConstantComposite 36 36 36 36
+              40:             TypePointer Output 7(fvec4)
+41(@entryPointOutput):     40(ptr) Variable Output
+         4(main):           2 Function None 3
+               5:             Label
+                              Store 41(@entryPointOutput) 37
+                              Return
+                              FunctionEnd
index 2c92bdb7fb9d0edfec15aa8a49fe12ac9361e8ae..bd28bb64c3788e74373b55812a09cbc6c87fa00f 100644 (file)
@@ -92,7 +92,6 @@ INSTANTIATE_TEST_CASE_P(
     ToSpirv, HlslCompileTest,
     ::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
         {"hlsl.amend.frag", "f1"},
-        {"hlsl.aliasOpaque.frag", "main"},
         {"hlsl.array.frag", "PixelShaderFunction"},
         {"hlsl.array.implicit-size.frag", "PixelShaderFunction"},
         {"hlsl.array.multidim.frag", "main"},
@@ -153,11 +152,6 @@ INSTANTIATE_TEST_CASE_P(
         {"hlsl.float1.frag", "PixelShaderFunction"},
         {"hlsl.float4.frag", "PixelShaderFunction"},
         {"hlsl.flatten.return.frag", "main"},
-        {"hlsl.flattenOpaque.frag", "main"},
-        {"hlsl.flattenOpaqueInit.vert", "main"},
-        {"hlsl.flattenOpaqueInitMix.vert", "main"},
-        {"hlsl.flattenSubset.frag", "main"},
-        {"hlsl.flattenSubset2.frag", "main"},
         {"hlsl.forLoop.frag", "PixelShaderFunction"},
         {"hlsl.gather.array.dx10.frag", "main"},
         {"hlsl.gather.basic.dx10.frag", "main"},
@@ -254,7 +248,6 @@ INSTANTIATE_TEST_CASE_P(
         {"hlsl.params.default.frag", "main"},
         {"hlsl.params.default.negative.frag", "main"},
         {"hlsl.partialInit.frag", "PixelShaderFunction"},
-        {"hlsl.partialFlattenLocal.vert", "main"},
         {"hlsl.PointSize.geom", "main"},
         {"hlsl.PointSize.vert", "main"},
         {"hlsl.pp.vert", "main"},
@@ -280,7 +273,6 @@ INSTANTIATE_TEST_CASE_P(
         {"hlsl.samplebias.offsetarray.dx10.frag", "main"},
         {"hlsl.samplecmp.array.dx10.frag", "main"},
         {"hlsl.samplecmp.basic.dx10.frag", "main"},
-        {"hlsl.samplecmp.dualmode.frag", "main"},
         {"hlsl.samplecmp.offset.dx10.frag", "main"},
         {"hlsl.samplecmp.offsetarray.dx10.frag", "main"},
         {"hlsl.samplecmp.negative.frag", "main"},
@@ -369,22 +361,34 @@ INSTANTIATE_TEST_CASE_P(
         {"hlsl.typeGraphCopy.vert", "main"},
         {"hlsl.typedef.frag", "PixelShaderFunction"},
         {"hlsl.whileLoop.frag", "PixelShaderFunction"},
-        {"hlsl.void.frag", "PixelShaderFunction"}
+        {"hlsl.void.frag", "PixelShaderFunction"},
+#ifndef ENABLE_OPT
+        {"hlsl.aliasOpaque.frag", "main"},
+        {"hlsl.flattenOpaque.frag", "main"},
+        {"hlsl.flattenOpaqueInit.vert", "main"},
+        {"hlsl.flattenOpaqueInitMix.vert", "main"},
+        {"hlsl.flattenSubset.frag", "main"},
+        {"hlsl.flattenSubset2.frag", "main"},
+        {"hlsl.partialFlattenLocal.vert", "main"},
+        {"hlsl.samplecmp.dualmode.frag", "main"},
+#endif
     }),
     FileNameAsCustomTestSuffix
 );
 // clang-format on
 
+#ifndef ENABLE_OPT
 // clang-format off
 INSTANTIATE_TEST_CASE_P(
     ToSpirv, HlslCompileAndFlattenTest,
     ::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
         {"hlsl.array.flatten.frag", "main"},
-        {"hlsl.partialFlattenMixed.vert", "main"},
+        {"hlsl.partialFlattenMixed.vert", "main"}
     }),
     FileNameAsCustomTestSuffix
 );
 // clang-format on
+#endif
 
 #ifdef ENABLE_OPT
 // clang-format off
@@ -398,7 +402,9 @@ INSTANTIATE_TEST_CASE_P(
         {"hlsl.flattenSubset.frag", "main"},
         {"hlsl.flattenSubset2.frag", "main"},
         {"hlsl.partialFlattenLocal.vert", "main"},
-        {"hlsl.partialFlattenMixed.vert", "main"}
+        {"hlsl.array.flatten.frag", "main"},
+        {"hlsl.partialFlattenMixed.vert", "main"},
+        {"hlsl.samplecmp.dualmode.frag", "main"}
     }),
     FileNameAsCustomTestSuffix
 );
index 2395dafe940ca749eb18243fb7b227f82fefc191..969619cfa77474018d3152400f23d69c3ea6ec69 100755 (executable)
@@ -9885,10 +9885,12 @@ void HlslParseContext::finish()
     addPatchConstantInvocation();
     fixTextureShadowModes();
 
+#ifndef ENABLE_OPT
     // Communicate out (esp. for command line) that we formed AST that will make
     // illegal AST SPIR-V and it needs transforms to legalize it.
     if (intermediate.needsLegalization())
         infoSink.info << "WARNING: AST will form illegal SPIR-V; need to transform to legalize";
+#endif
 
     TParseContextBase::finish();
 }