Update: As we discussed on IRC, the bug that this MR tries to solve is a symptom of a more severe underlying problem in copy-propagation, specifically, the use and replace of `hlsl_deref`s in `copy_propagation_transform_object_load()`. Zeb pointed out this problem and suggested the following example (with `a`, `b`, and `c` objects): ``` a = b; b = c; ret = Tex2D(a); ``` were if `ret = Tex2D(a);` gets replaced into `ret = Tex2D(b);` before copy-prop replaces `b` with its uniform copy, it could happen that the third line ends up as `text2D(c)`. This actually happens using the master branch to compile the following shader: ```hlsl Texture2D t_good, t_bad; float4 main() : sv_target { Texture2D a, b[1]; // This is basically a `b[0] = t_good` but so that the copy-prop is delayed int4 co = {0, 0, 0, 0}; b[(int) co.x + (int) co.y] = t_good; a = b[0]; b[0] = t_bad; return a.Load(int3(0, 0, 0)); } ``` were `t_bad` is loaded instead of `t_good`. So probably Giovanni's solution, with some modifications, is the correct solution (as comparing deref shouldn't be solving this underlying issue). -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/59#note_21280