mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Avoid infinite loop and invalid derefs in copy-prop.
Co-authored-by: Francisco Casas <fcasas@codeweavers.com> Co-authored-by: Zebediah Figura <zfigura@codeweavers.com> Because copy_propagation_transform_object_load() replaces a deref instead of an instruction, it is currently prone to two problems: 1- It can replace a deref with the same deref, returning true every time and getting the compilation stuck in an endless loop of copy-propagation iterations. 2- When performed multiple times in the same deref, the second time it can replace the deref with a deref from a temp that is only valid in another point of the program execution, resulting in an incorrect value. This patch preempts this by avoiding replacing derefs when the new deref doesn't point to a uniform variable. Because, uniform variables cannot be written to.
This commit is contained in:
committed by
Alexandre Julliard
parent
17888f6493
commit
d2f8a576a8
Notes:
Alexandre Julliard
2023-01-26 23:11:17 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/59
@@ -1,3 +1,15 @@
|
||||
[pixel shader fail]
|
||||
sampler sam;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
Texture2D tex;
|
||||
|
||||
tex = tex; // Uninitialized assignment to self.
|
||||
return tex.Sample(sam, float2(0, 0));
|
||||
}
|
||||
|
||||
|
||||
[require]
|
||||
shader model >= 4.0
|
||||
|
||||
@@ -35,7 +47,7 @@ float4 main() : sv_target
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
todo probe all rgba (77.77, 77.77, 77.77, 77.77)
|
||||
probe all rgba (77.77, 77.77, 77.77, 77.77)
|
||||
|
||||
|
||||
[texture 0]
|
||||
@@ -201,3 +213,28 @@ float4 main(Texture2D tex2) : sv_target
|
||||
tex2 = tex1;
|
||||
return tex2.Load(int3(0, 0, 0));
|
||||
}
|
||||
|
||||
|
||||
[require]
|
||||
shader model >= 5.0
|
||||
|
||||
|
||||
[texture 0]
|
||||
size (1, 1)
|
||||
1.0 2.0 3.0 4.0
|
||||
|
||||
[pixel shader todo]
|
||||
struct apple {
|
||||
Texture2D tex;
|
||||
float4 fo : COLOR;
|
||||
};
|
||||
|
||||
float4 main(struct apple input) : sv_target
|
||||
{
|
||||
input.tex = input.tex; // Assignment to self.
|
||||
return input.tex.Load(int3(0, 0, 0));
|
||||
}
|
||||
|
||||
[test]
|
||||
todo draw quad
|
||||
todo probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
|
||||
|
Reference in New Issue
Block a user