Add --hlsl-dx-position-w option

This reciprocates the w component of SV_Position in HLSL fragment shaders
to provide DirectX compatibility for HLSL shaders in Vulkan.

Fixes #2244
This commit is contained in:
Greg Fischer
2021-11-16 18:42:12 -07:00
parent 8a7860e4cb
commit e9564feb55
9 changed files with 323 additions and 2 deletions

12
Test/hlsl.w-recip.frag Normal file
View File

@@ -0,0 +1,12 @@
float4 AmbientColor = float4(1, 0.5, 0, 1);
float4 AmbientColor2 = float4(0.5, 1, 0, 0);
float4 main(float4 vpos : SV_POSITION) : SV_TARGET
{
float4 vpos_t = float4(vpos.xyz, 1 / vpos.w);
if (vpos_t.x < 400)
return AmbientColor;
else
return AmbientColor2;
}