vkd3d-shader/hlsl: Flatten conditional blocks containing discard_neg instructions.

For any `discard_neg c` instruction in a conditional block, we replace c with
    cond ? c : 0    in a then block,
and
    cond ? 0 : c    in an else block.
This commit is contained in:
Shaun Ren
2025-10-27 21:46:35 -04:00
committed by Henri Verbeet
parent 787d49d6d8
commit 59b87c769a
Notes: Henri Verbeet 2025-10-30 19:59:51 +01:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1732
2 changed files with 56 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
[pixel shader todo(sm<4)]
[pixel shader]
uniform float4 x;
float4 main() : sv_target
@@ -10,13 +10,13 @@ float4 main() : sv_target
[test]
uniform 0 float4 1 2 3 4
todo(sm<4 | glsl | msl & sm>=6) draw quad
todo(glsl | msl & sm>=6) draw quad
probe (0, 0) f32(1, 2, 3, 4)
uniform 0 float4 9 8 7 6
todo(sm<4 | glsl | msl & sm>=6) draw quad
todo(glsl | msl & sm>=6) draw quad
probe (0, 0) f32(1, 2, 3, 4)
[pixel shader todo(sm<4)]
[pixel shader]
uniform float4 x;
float4 main() : sv_target
@@ -29,13 +29,13 @@ float4 main() : sv_target
[test]
uniform 0 float4 1 2 3 4
todo(sm<4 | glsl | msl & sm>=6) draw quad
todo(glsl | msl & sm>=6) draw quad
probe (0, 0) f32(1, 2, 3, 4)
uniform 0 float4 9 8 7 6
todo(sm<4 | glsl | msl & sm>=6) draw quad
todo(glsl | msl & sm>=6) draw quad
probe (0, 0) f32(1, 2, 3, 4)
[pixel shader todo(sm<4)]
[pixel shader]
uniform float4 x;
float4 main() : sv_target
@@ -50,13 +50,13 @@ float4 main() : sv_target
[test]
uniform 0 float4 1 2 3 4
todo(sm<4 | glsl | msl & sm>=6) draw quad
todo(glsl | msl & sm>=6) draw quad
probe (0, 0) f32(1, 2, 3, 4)
uniform 0 float4 9 8 7 6
todo(sm<4 | glsl | msl & sm>=6) draw quad
todo(glsl | msl & sm>=6) draw quad
probe (0, 0) f32(1, 2, 3, 4)
[pixel shader todo(sm<4)]
[pixel shader]
uniform float4 x;
float4 main() : sv_target
@@ -72,10 +72,10 @@ float4 main() : sv_target
[test]
uniform 0 float4 1 2 3 4
todo(sm<4 | glsl | msl & sm>=6) draw quad
todo(glsl | msl & sm>=6) draw quad
probe (0, 0) f32(1, 2, 3, 4)
uniform 0 float4 9 8 7 6
todo(sm<4 | glsl | msl & sm>=6) draw quad
todo(glsl | msl & sm>=6) draw quad
probe (0, 0) f32(1, 2, 3, 4)
[require]