mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-09 12:00:05 +00:00
Allow DepthUnchanged and DepthReplaced Modes in same SPIR-V module.
Fixes #2555
This commit is contained in:
parent
0eca413092
commit
b479ce0bfa
@ -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);
|
||||
|
44
Test/baseResults/spv.depthUnchanged.frag.out
Normal file
44
Test/baseResults/spv.depthUnchanged.frag.out
Normal file
@ -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
|
8
Test/spv.depthUnchanged.frag
Normal file
8
Test/spv.depthUnchanged.frag
Normal file
@ -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;
|
||||
}
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user