mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-12-15 08:03:30 -08:00
vkd3d-shader/hlsl: Flatten conditional branches containing stores.
For an if block
if (cond)
{
<then_block>
}
else
{
<else_block>
}
We flatten it by first replacing any store instruction `v[[k]] = x`
in the then_block with the following:
1: load(v[[k]])
2: cond ? x : @1
3: v[[k]] = @2
Similarly, we replace any store instruction `v[[k]] = x` in the
else_block with the following:
1: load(v[[k]])
2: cond ? @1 : x
3: v[[k]] = @2
Then we can concatenate <then_block> and <else_block> together and
get rid of the if block.
This commit is contained in:
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
@@ -1,4 +1,4 @@
|
||||
[pixel shader todo(sm<4)]
|
||||
[pixel shader]
|
||||
uniform float4 u;
|
||||
|
||||
float4 main() : sv_target
|
||||
@@ -11,13 +11,13 @@ float4 main() : sv_target
|
||||
|
||||
[test]
|
||||
uniform 0 float4 0.0 0.0 0.0 0.0
|
||||
todo(sm<4) draw quad
|
||||
probe (0, 0) rgba (0.9, 0.8, 0.7, 0.6)
|
||||
draw quad
|
||||
probe (0, 0) f32(0.9, 0.8, 0.7, 0.6)
|
||||
uniform 0 float4 0.1 0.0 0.0 0.0
|
||||
todo(sm<4) draw quad
|
||||
probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4)
|
||||
draw quad
|
||||
probe (0, 0) f32(0.1, 0.2, 0.3, 0.4)
|
||||
|
||||
[pixel shader todo(sm<4)]
|
||||
[pixel shader]
|
||||
uniform float4 u;
|
||||
|
||||
float4 main() : sv_target
|
||||
@@ -29,7 +29,7 @@ float4 main() : sv_target
|
||||
return float4(0.9, 0.8, 0.7, 0.6);
|
||||
}
|
||||
|
||||
[pixel shader todo(sm<4)]
|
||||
[pixel shader]
|
||||
uniform float4 u;
|
||||
|
||||
float4 main() : sv_target
|
||||
@@ -43,8 +43,8 @@ float4 main() : sv_target
|
||||
|
||||
[test]
|
||||
uniform 0 float4 0.0 0.0 0.0 0.0
|
||||
todo(sm<4) draw quad
|
||||
probe (0, 0) rgba (0.9, 0.8, 0.7, 0.6)
|
||||
draw quad
|
||||
probe (0, 0) f32(0.9, 0.8, 0.7, 0.6)
|
||||
|
||||
[pixel shader fail(sm<6)]
|
||||
float4 u;
|
||||
@@ -370,7 +370,7 @@ todo(msl & sm>=6) draw quad
|
||||
probe (0, 0) rgba (1.0, 1.0, 0.0, 4.0)
|
||||
|
||||
% Branches with resource stores can't be flattened.
|
||||
[pixel shader fail(sm<6) todo]
|
||||
[pixel shader fail(sm<6)]
|
||||
uniform float a;
|
||||
RWBuffer<float> u;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user