mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
736f3ae2df
This preempts us from replacing a swizzle incorrectly, as in the following example: 1: A.x = 1.0 2: A 3: A.x = 2.0 4: @2.x were @4 ends up being 2.0 instead of 1.0, because that's the value stored in A.x at time 4, and we should be querying it at time 2. This also helps us to avoid replacing a swizzle with itself in copy-prop which can result in infinite loops, as with the included tests this commit. Consider the following sequence of instructions: 1 : A 2 : B = @1 3 : B 4 : A = @3 5 : @1.x Current copy-prop would replace 5 so it points to @3 now: 1 : A 2 : B = @1 3 : B 4 : A = @3 5 : @3.x But in the next iteration it would make it point back to @1, keeping it spinning infinitively. The solution is to index the instructions and don't replace the swizzle if the new load happens after the current load.
76 lines
1.0 KiB
Plaintext
76 lines
1.0 KiB
Plaintext
[pixel shader]
|
|
float cond;
|
|
|
|
float4 main() : sv_target
|
|
{
|
|
float4 a = {1, 2, 3, 4};
|
|
float4 b;
|
|
|
|
// invalidate a
|
|
if (cond)
|
|
a = float4(-1, -2, -3, -4);
|
|
|
|
b = a;
|
|
a.y = 357;
|
|
return b.y;
|
|
}
|
|
|
|
[test]
|
|
uniform 0 float 0.0
|
|
draw quad
|
|
probe all rgba (2.0, 2.0, 2.0, 2.0)
|
|
uniform 0 float 1.0
|
|
draw quad
|
|
probe all rgba (-2.0, -2.0, -2.0, -2.0)
|
|
|
|
|
|
[pixel shader]
|
|
float cond;
|
|
|
|
float4 main() : sv_target
|
|
{
|
|
float2 r = {1, 2};
|
|
float2 tmp;
|
|
|
|
// invalidate r
|
|
if (cond)
|
|
r = float2(10, 20);
|
|
|
|
tmp = r;
|
|
r = tmp;
|
|
return r.y;
|
|
}
|
|
|
|
[test]
|
|
uniform 0 float 0.0
|
|
draw quad
|
|
probe all rgba (2.0, 2.0, 2.0, 2.0)
|
|
uniform 0 float 1.0
|
|
draw quad
|
|
probe all rgba (20.0, 20.0, 20.0, 20.0)
|
|
|
|
|
|
[pixel shader]
|
|
float cond;
|
|
|
|
float4 main() : sv_target
|
|
{
|
|
float2 r = {3, 4};
|
|
|
|
// invalidate r
|
|
if (cond)
|
|
r = float2(30, 40);
|
|
|
|
r = r;
|
|
r = float2(1, r.y);
|
|
|
|
return float4(r, 0, 0);
|
|
}
|
|
[test]
|
|
uniform 0 float 0.0
|
|
draw quad
|
|
probe all rgba (1.0, 4.0, 0.0, 0.0)
|
|
uniform 0 float 1.0
|
|
draw quad
|
|
probe all rgba (1.0, 40.0, 0.0, 0.0)
|