Merge pull request #749 from KhronosGroup/fix-747

Deal with depth_greater/depth_less qualifiers.
This commit is contained in:
Hans-Kristian Arntzen 2018-11-12 13:10:26 +01:00 committed by GitHub
commit be732f5f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 248 additions and 5 deletions

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

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

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

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

View File

@ -0,0 +1,9 @@
#version 450
layout(depth_greater) out float gl_FragDepth;
layout(early_fragment_tests) in;
void main()
{
gl_FragDepth = 0.5;
}

View File

@ -0,0 +1,9 @@
#version 450
layout(depth_less) out float gl_FragDepth;
layout(early_fragment_tests) in;
void main()
{
gl_FragDepth = 0.5;
}

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

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

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

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

View File

@ -0,0 +1,9 @@
#version 450
layout(depth_greater) out float gl_FragDepth;
layout(early_fragment_tests) in;
void main()
{
gl_FragDepth = 0.5;
}

View File

@ -0,0 +1,9 @@
#version 450
layout(depth_less) out float gl_FragDepth;
layout(early_fragment_tests) in;
void main()
{
gl_FragDepth = 0.5;
}

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

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

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

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

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

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

View File

@ -678,10 +678,11 @@ void CompilerGLSL::emit_header()
if (execution.flags.get(ExecutionModeEarlyFragmentTests))
inputs.push_back("early_fragment_tests");
if (execution.flags.get(ExecutionModeDepthGreater))
inputs.push_back("depth_greater");
if (execution.flags.get(ExecutionModeDepthLess))
inputs.push_back("depth_less");
if (!options.es && execution.flags.get(ExecutionModeDepthGreater))
statement("layout(depth_greater) out float gl_FragDepth;");
else if (!options.es && execution.flags.get(ExecutionModeDepthLess))
statement("layout(depth_less) out float gl_FragDepth;");
break;

View File

@ -494,6 +494,8 @@ const char *CompilerHLSL::to_storage_qualifiers_glsl(const SPIRVariable &var)
void CompilerHLSL::emit_builtin_outputs_in_struct()
{
auto &execution = get_entry_point();
bool legacy = hlsl_options.shader_model <= 30;
active_output_builtins.for_each_bit([&](uint32_t i) {
const char *type = nullptr;
@ -508,7 +510,19 @@ void CompilerHLSL::emit_builtin_outputs_in_struct()
case BuiltInFragDepth:
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;
case BuiltInClipDistance: