Merge pull request #1449 from KhronosGroup/fix-1443
HLSL: Fix FragCoord.w.
This commit is contained in:
commit
4f0f0e5a07
@ -55,6 +55,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.o_color = o_color;
|
||||
|
@ -22,6 +22,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.FragColor = FragColor;
|
||||
|
@ -24,6 +24,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
vColor = stage_input.vColor;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
|
@ -28,6 +28,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
vIn = stage_input.vIn;
|
||||
vIn2 = stage_input.vIn2;
|
||||
frag_main();
|
||||
|
@ -24,6 +24,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
gl_SampleID = stage_input.gl_SampleID;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
|
@ -22,6 +22,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.FragColor = FragColor;
|
||||
|
@ -24,6 +24,7 @@ void frag_main()
|
||||
void main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
vTex = stage_input.vTex;
|
||||
vIndex = stage_input.vIndex;
|
||||
frag_main();
|
||||
|
@ -26,6 +26,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.FragColor = FragColor;
|
||||
|
@ -24,6 +24,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.FragColor = FragColor;
|
||||
|
@ -28,5 +28,6 @@ void frag_main()
|
||||
void main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
frag_main();
|
||||
}
|
||||
|
@ -38,5 +38,6 @@ void frag_main()
|
||||
void main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
frag_main();
|
||||
}
|
||||
|
@ -38,5 +38,6 @@ void frag_main()
|
||||
void main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
frag_main();
|
||||
}
|
||||
|
27
reference/shaders-hlsl-no-opt/frag/frag-coord.frag
Normal file
27
reference/shaders-hlsl-no-opt/frag/frag-coord.frag
Normal file
@ -0,0 +1,27 @@
|
||||
static float4 gl_FragCoord;
|
||||
static float3 FragColor;
|
||||
|
||||
struct SPIRV_Cross_Input
|
||||
{
|
||||
float4 gl_FragCoord : SV_Position;
|
||||
};
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
{
|
||||
float3 FragColor : SV_Target0;
|
||||
};
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
FragColor = gl_FragCoord.xyz / gl_FragCoord.w.xxx;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.FragColor = FragColor;
|
||||
return stage_output;
|
||||
}
|
@ -66,6 +66,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
Input = stage_input.Input;
|
||||
InputI = stage_input.InputI;
|
||||
InputU = stage_input.InputU;
|
||||
|
@ -28,5 +28,6 @@ void frag_main()
|
||||
void main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
frag_main();
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.o_color = o_color;
|
||||
|
@ -22,6 +22,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.FragColor = FragColor;
|
||||
|
@ -24,6 +24,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
vColor = stage_input.vColor;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
|
@ -31,6 +31,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
vIn = stage_input.vIn;
|
||||
vIn2 = stage_input.vIn2;
|
||||
frag_main();
|
||||
|
@ -30,6 +30,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
gl_SampleID = stage_input.gl_SampleID;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
|
@ -27,6 +27,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.FragColor = FragColor;
|
||||
|
@ -38,6 +38,7 @@ void frag_main()
|
||||
void main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
vTex = stage_input.vTex;
|
||||
vIndex = stage_input.vIndex;
|
||||
frag_main();
|
||||
|
@ -25,6 +25,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.FragColor = FragColor;
|
||||
|
@ -23,6 +23,7 @@ void frag_main()
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_FragCoord = stage_input.gl_FragCoord;
|
||||
gl_FragCoord.w = 1.0 / gl_FragCoord.w;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.FragColor = FragColor;
|
||||
|
8
shaders-hlsl-no-opt/frag/frag-coord.frag
Normal file
8
shaders-hlsl-no-opt/frag/frag-coord.frag
Normal file
@ -0,0 +1,8 @@
|
||||
#version 450
|
||||
|
||||
layout(location = 0) out vec3 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = gl_FragCoord.xyz / gl_FragCoord.w;
|
||||
}
|
@ -2396,7 +2396,11 @@ void CompilerHLSL::emit_hlsl_entry_point()
|
||||
if (legacy)
|
||||
statement(builtin, " = stage_input.", builtin, " + float4(0.5f, 0.5f, 0.0f, 0.0f);");
|
||||
else
|
||||
{
|
||||
statement(builtin, " = stage_input.", builtin, ";");
|
||||
// ZW are undefined in D3D9, only do this fixup here.
|
||||
statement(builtin, ".w = 1.0 / ", builtin, ".w;");
|
||||
}
|
||||
break;
|
||||
|
||||
case BuiltInVertexId:
|
||||
|
Loading…
Reference in New Issue
Block a user