diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index f0bf3a6e..8a1b30d7 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -1551,15 +1551,16 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion, builder.addExtension(spv::E_SPV_KHR_post_depth_coverage); } - if (glslangIntermediate->getDepth() != glslang::EldUnchanged && glslangIntermediate->isDepthReplacing()) + if (glslangIntermediate->isDepthReplacing()) builder.addExecutionMode(shaderEntry, spv::ExecutionModeDepthReplacing); #ifndef GLSLANG_WEB switch(glslangIntermediate->getDepth()) { - case glslang::EldGreater: mode = spv::ExecutionModeDepthGreater; break; - case glslang::EldLess: mode = spv::ExecutionModeDepthLess; break; - default: mode = spv::ExecutionModeMax; break; + case glslang::EldGreater: mode = spv::ExecutionModeDepthGreater; break; + case glslang::EldLess: mode = spv::ExecutionModeDepthLess; break; + case glslang::EldUnchanged: mode = spv::ExecutionModeDepthUnchanged; break; + default: mode = spv::ExecutionModeMax; break; } if (mode != spv::ExecutionModeMax) builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode); diff --git a/Test/baseResults/spv.depthUnchanged.frag.out b/Test/baseResults/spv.depthUnchanged.frag.out new file mode 100644 index 00000000..00740078 --- /dev/null +++ b/Test/baseResults/spv.depthUnchanged.frag.out @@ -0,0 +1,44 @@ +spv.depthUnchanged.frag +// Module Version 10000 +// Generated by (magic number): 8000a +// Id's are bound by 22 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 9 14 16 + ExecutionMode 4 OriginUpperLeft + ExecutionMode 4 DepthReplacing + ExecutionMode 4 DepthUnchanged + Source GLSL 430 + Name 4 "main" + Name 9 "outColor" + Name 14 "gl_FragDepth" + Name 16 "gl_FragCoord" + Decorate 9(outColor) Location 0 + Decorate 14(gl_FragDepth) BuiltIn FragDepth + Decorate 16(gl_FragCoord) BuiltIn FragCoord + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Output 7(fvec4) + 9(outColor): 8(ptr) Variable Output + 10: 6(float) Constant 1065353216 + 11: 6(float) Constant 0 + 12: 7(fvec4) ConstantComposite 10 11 11 10 + 13: TypePointer Output 6(float) +14(gl_FragDepth): 13(ptr) Variable Output + 15: TypePointer Input 7(fvec4) +16(gl_FragCoord): 15(ptr) Variable Input + 17: TypeInt 32 0 + 18: 17(int) Constant 1 + 19: TypePointer Input 6(float) + 4(main): 2 Function None 3 + 5: Label + Store 9(outColor) 12 + 20: 19(ptr) AccessChain 16(gl_FragCoord) 18 + 21: 6(float) Load 20 + Store 14(gl_FragDepth) 21 + Return + FunctionEnd diff --git a/Test/spv.depthUnchanged.frag b/Test/spv.depthUnchanged.frag new file mode 100644 index 00000000..bbc5139d --- /dev/null +++ b/Test/spv.depthUnchanged.frag @@ -0,0 +1,8 @@ +#version 430 +layout(location = 0) out vec4 outColor; +layout(depth_unchanged) out float gl_FragDepth; +void main() { + outColor = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragDepth = gl_FragCoord.y; +} + diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index 2ee292e4..e2a837db 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -328,6 +328,7 @@ INSTANTIATE_TEST_SUITE_P( "spv.demoteDisabled.frag", "spv.deepRvalue.frag", "spv.depthOut.frag", + "spv.depthUnchanged.frag", "spv.discard-dce.frag", "spv.doWhileLoop.frag", "spv.earlyReturnDiscard.frag",