Merge pull request #1274 from greg-lunarg/legal2

Legalization: Omit legalization warning when spirv-opt is linked.
This commit is contained in:
John Kessenich 2018-03-06 13:17:04 -07:00 committed by GitHub
commit 2c65069ecd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 106 additions and 19 deletions

View 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

View File

@ -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

View 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

View 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

View 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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View 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
);

View File

@ -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();
}