mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-12-15 08:03:30 -08:00
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.
84 lines
1.1 KiB
Plaintext
84 lines
1.1 KiB
Plaintext
% Unrolling edge cases.
|
|
|
|
[pixel shader]
|
|
float a : register(c0);
|
|
|
|
float4 main() : sv_target
|
|
{
|
|
int i;
|
|
if (a > 0)
|
|
{
|
|
[unroll]
|
|
for (i = 0; i < 10; ++i);
|
|
|
|
return float4(i, a, 2.0, 3.0);
|
|
}
|
|
|
|
return float4(0.0, a, 3.0, 4.0);
|
|
}
|
|
|
|
[test]
|
|
uniform 0 float 1
|
|
draw quad
|
|
probe (0,0) f32(10.0, 1.0, 2.0, 3.0)
|
|
|
|
[pixel shader]
|
|
float4 main() : sv_target
|
|
{
|
|
int i;
|
|
[unroll(4)]
|
|
for (i = 0; i < 8; ++i);
|
|
|
|
return float4(i, 0, 0, 0);
|
|
}
|
|
|
|
[test]
|
|
draw quad
|
|
probe (0,0) rgba(4.0, 0.0, 0.0, 0.0)
|
|
|
|
[pixel shader fail(sm<6)]
|
|
float4 main() : sv_target
|
|
{
|
|
int i;
|
|
[unroll]
|
|
for (i = 0; i < 1024; ++i);
|
|
|
|
return float4(i, 0, 0, 0);
|
|
}
|
|
|
|
[test]
|
|
draw quad
|
|
probe (0,0) rgba(1024.0, 0, 0, 0)
|
|
|
|
[pixel shader]
|
|
float4 main() : sv_target
|
|
{
|
|
int i;
|
|
[unroll(1337)]
|
|
for (i = 0; i < 1337; ++i);
|
|
|
|
return float4(i, 0, 0, 0);
|
|
}
|
|
|
|
[test]
|
|
draw quad
|
|
probe (0,0) rgba(1337.0, 0, 0, 0)
|
|
|
|
[pixel shader]
|
|
float4 main() : sv_target
|
|
{
|
|
float i = 0;
|
|
|
|
[unroll]
|
|
for (;;)
|
|
{
|
|
if (((float4)1).w == 1) break;
|
|
++i;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
[test]
|
|
draw quad
|
|
probe (0,0) rgba(0, 0, 0, 0)
|