Merge pull request #749 from KhronosGroup/fix-747
Deal with depth_greater/depth_less qualifiers.
This commit is contained in:
commit
be732f5f51
19
reference/opt/shaders-hlsl/frag/depth-greater-than.frag
Normal file
19
reference/opt/shaders-hlsl/frag/depth-greater-than.frag
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
static float gl_FragDepth;
|
||||||
|
struct SPIRV_Cross_Output
|
||||||
|
{
|
||||||
|
float gl_FragDepth : SV_DepthGreaterEqual;
|
||||||
|
};
|
||||||
|
|
||||||
|
void frag_main()
|
||||||
|
{
|
||||||
|
gl_FragDepth = 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
[earlydepthstencil]
|
||||||
|
SPIRV_Cross_Output main()
|
||||||
|
{
|
||||||
|
frag_main();
|
||||||
|
SPIRV_Cross_Output stage_output;
|
||||||
|
stage_output.gl_FragDepth = gl_FragDepth;
|
||||||
|
return stage_output;
|
||||||
|
}
|
19
reference/opt/shaders-hlsl/frag/depth-less-than.frag
Normal file
19
reference/opt/shaders-hlsl/frag/depth-less-than.frag
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
static float gl_FragDepth;
|
||||||
|
struct SPIRV_Cross_Output
|
||||||
|
{
|
||||||
|
float gl_FragDepth : SV_DepthLessEqual;
|
||||||
|
};
|
||||||
|
|
||||||
|
void frag_main()
|
||||||
|
{
|
||||||
|
gl_FragDepth = 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
[earlydepthstencil]
|
||||||
|
SPIRV_Cross_Output main()
|
||||||
|
{
|
||||||
|
frag_main();
|
||||||
|
SPIRV_Cross_Output stage_output;
|
||||||
|
stage_output.gl_FragDepth = gl_FragDepth;
|
||||||
|
return stage_output;
|
||||||
|
}
|
17
reference/opt/shaders-msl/frag/depth-greater-than.frag
Normal file
17
reference/opt/shaders-msl/frag/depth-greater-than.frag
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <metal_stdlib>
|
||||||
|
#include <simd/simd.h>
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
|
||||||
|
struct main0_out
|
||||||
|
{
|
||||||
|
float gl_FragDepth [[depth(greater)]];
|
||||||
|
};
|
||||||
|
|
||||||
|
[[ early_fragment_tests ]] fragment main0_out main0()
|
||||||
|
{
|
||||||
|
main0_out out = {};
|
||||||
|
out.gl_FragDepth = 0.5;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
17
reference/opt/shaders-msl/frag/depth-less-than.frag
Normal file
17
reference/opt/shaders-msl/frag/depth-less-than.frag
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <metal_stdlib>
|
||||||
|
#include <simd/simd.h>
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
|
||||||
|
struct main0_out
|
||||||
|
{
|
||||||
|
float gl_FragDepth [[depth(less)]];
|
||||||
|
};
|
||||||
|
|
||||||
|
[[ early_fragment_tests ]] fragment main0_out main0()
|
||||||
|
{
|
||||||
|
main0_out out = {};
|
||||||
|
out.gl_FragDepth = 0.5;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
#version 450
|
||||||
|
layout(depth_greater) out float gl_FragDepth;
|
||||||
|
layout(early_fragment_tests) in;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragDepth = 0.5;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
#version 450
|
||||||
|
layout(depth_less) out float gl_FragDepth;
|
||||||
|
layout(early_fragment_tests) in;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragDepth = 0.5;
|
||||||
|
}
|
||||||
|
|
19
reference/shaders-hlsl/frag/depth-greater-than.frag
Normal file
19
reference/shaders-hlsl/frag/depth-greater-than.frag
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
static float gl_FragDepth;
|
||||||
|
struct SPIRV_Cross_Output
|
||||||
|
{
|
||||||
|
float gl_FragDepth : SV_DepthGreaterEqual;
|
||||||
|
};
|
||||||
|
|
||||||
|
void frag_main()
|
||||||
|
{
|
||||||
|
gl_FragDepth = 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
[earlydepthstencil]
|
||||||
|
SPIRV_Cross_Output main()
|
||||||
|
{
|
||||||
|
frag_main();
|
||||||
|
SPIRV_Cross_Output stage_output;
|
||||||
|
stage_output.gl_FragDepth = gl_FragDepth;
|
||||||
|
return stage_output;
|
||||||
|
}
|
19
reference/shaders-hlsl/frag/depth-less-than.frag
Normal file
19
reference/shaders-hlsl/frag/depth-less-than.frag
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
static float gl_FragDepth;
|
||||||
|
struct SPIRV_Cross_Output
|
||||||
|
{
|
||||||
|
float gl_FragDepth : SV_DepthLessEqual;
|
||||||
|
};
|
||||||
|
|
||||||
|
void frag_main()
|
||||||
|
{
|
||||||
|
gl_FragDepth = 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
[earlydepthstencil]
|
||||||
|
SPIRV_Cross_Output main()
|
||||||
|
{
|
||||||
|
frag_main();
|
||||||
|
SPIRV_Cross_Output stage_output;
|
||||||
|
stage_output.gl_FragDepth = gl_FragDepth;
|
||||||
|
return stage_output;
|
||||||
|
}
|
17
reference/shaders-msl/frag/depth-greater-than.frag
Normal file
17
reference/shaders-msl/frag/depth-greater-than.frag
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <metal_stdlib>
|
||||||
|
#include <simd/simd.h>
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
|
||||||
|
struct main0_out
|
||||||
|
{
|
||||||
|
float gl_FragDepth [[depth(greater)]];
|
||||||
|
};
|
||||||
|
|
||||||
|
[[ early_fragment_tests ]] fragment main0_out main0()
|
||||||
|
{
|
||||||
|
main0_out out = {};
|
||||||
|
out.gl_FragDepth = 0.5;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
17
reference/shaders-msl/frag/depth-less-than.frag
Normal file
17
reference/shaders-msl/frag/depth-less-than.frag
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <metal_stdlib>
|
||||||
|
#include <simd/simd.h>
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
|
||||||
|
struct main0_out
|
||||||
|
{
|
||||||
|
float gl_FragDepth [[depth(less)]];
|
||||||
|
};
|
||||||
|
|
||||||
|
[[ early_fragment_tests ]] fragment main0_out main0()
|
||||||
|
{
|
||||||
|
main0_out out = {};
|
||||||
|
out.gl_FragDepth = 0.5;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
#version 450
|
||||||
|
layout(depth_greater) out float gl_FragDepth;
|
||||||
|
layout(early_fragment_tests) in;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragDepth = 0.5;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
#version 450
|
||||||
|
layout(depth_less) out float gl_FragDepth;
|
||||||
|
layout(early_fragment_tests) in;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragDepth = 0.5;
|
||||||
|
}
|
||||||
|
|
8
shaders-hlsl/frag/depth-greater-than.frag
Normal file
8
shaders-hlsl/frag/depth-greater-than.frag
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#version 450
|
||||||
|
layout(early_fragment_tests) in;
|
||||||
|
layout(depth_greater) out float gl_FragDepth;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragDepth = 0.5;
|
||||||
|
}
|
8
shaders-hlsl/frag/depth-less-than.frag
Normal file
8
shaders-hlsl/frag/depth-less-than.frag
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#version 450
|
||||||
|
layout(early_fragment_tests) in;
|
||||||
|
layout(depth_less) out float gl_FragDepth;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragDepth = 0.5;
|
||||||
|
}
|
8
shaders-msl/frag/depth-greater-than.frag
Normal file
8
shaders-msl/frag/depth-greater-than.frag
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#version 450
|
||||||
|
layout(early_fragment_tests) in;
|
||||||
|
layout(depth_greater) out float gl_FragDepth;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragDepth = 0.5;
|
||||||
|
}
|
8
shaders-msl/frag/depth-less-than.frag
Normal file
8
shaders-msl/frag/depth-less-than.frag
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#version 450
|
||||||
|
layout(early_fragment_tests) in;
|
||||||
|
layout(depth_less) out float gl_FragDepth;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragDepth = 0.5;
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
#version 450
|
||||||
|
layout(early_fragment_tests) in;
|
||||||
|
layout(depth_greater) out float gl_FragDepth;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragDepth = 0.5;
|
||||||
|
}
|
8
shaders/desktop-only/frag/depth-less-than.desktop.frag
Normal file
8
shaders/desktop-only/frag/depth-less-than.desktop.frag
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#version 450
|
||||||
|
layout(early_fragment_tests) in;
|
||||||
|
layout(depth_less) out float gl_FragDepth;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragDepth = 0.5;
|
||||||
|
}
|
@ -678,10 +678,11 @@ void CompilerGLSL::emit_header()
|
|||||||
|
|
||||||
if (execution.flags.get(ExecutionModeEarlyFragmentTests))
|
if (execution.flags.get(ExecutionModeEarlyFragmentTests))
|
||||||
inputs.push_back("early_fragment_tests");
|
inputs.push_back("early_fragment_tests");
|
||||||
if (execution.flags.get(ExecutionModeDepthGreater))
|
|
||||||
inputs.push_back("depth_greater");
|
if (!options.es && execution.flags.get(ExecutionModeDepthGreater))
|
||||||
if (execution.flags.get(ExecutionModeDepthLess))
|
statement("layout(depth_greater) out float gl_FragDepth;");
|
||||||
inputs.push_back("depth_less");
|
else if (!options.es && execution.flags.get(ExecutionModeDepthLess))
|
||||||
|
statement("layout(depth_less) out float gl_FragDepth;");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -494,6 +494,8 @@ const char *CompilerHLSL::to_storage_qualifiers_glsl(const SPIRVariable &var)
|
|||||||
|
|
||||||
void CompilerHLSL::emit_builtin_outputs_in_struct()
|
void CompilerHLSL::emit_builtin_outputs_in_struct()
|
||||||
{
|
{
|
||||||
|
auto &execution = get_entry_point();
|
||||||
|
|
||||||
bool legacy = hlsl_options.shader_model <= 30;
|
bool legacy = hlsl_options.shader_model <= 30;
|
||||||
active_output_builtins.for_each_bit([&](uint32_t i) {
|
active_output_builtins.for_each_bit([&](uint32_t i) {
|
||||||
const char *type = nullptr;
|
const char *type = nullptr;
|
||||||
@ -508,7 +510,19 @@ void CompilerHLSL::emit_builtin_outputs_in_struct()
|
|||||||
|
|
||||||
case BuiltInFragDepth:
|
case BuiltInFragDepth:
|
||||||
type = "float";
|
type = "float";
|
||||||
semantic = legacy ? "DEPTH" : "SV_Depth";
|
if (legacy)
|
||||||
|
{
|
||||||
|
semantic = "DEPTH";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (hlsl_options.shader_model >= 50 && execution.flags.get(ExecutionModeDepthGreater))
|
||||||
|
semantic = "SV_DepthGreaterEqual";
|
||||||
|
else if (hlsl_options.shader_model >= 50 && execution.flags.get(ExecutionModeDepthLess))
|
||||||
|
semantic = "SV_DepthLessEqual";
|
||||||
|
else
|
||||||
|
semantic = "SV_Depth";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BuiltInClipDistance:
|
case BuiltInClipDistance:
|
||||||
|
Loading…
Reference in New Issue
Block a user