See https://bugs.winehq.org/show_bug.cgi?id=54832
I'm starting to see this particular FIXME in quite a few games (Escape Goat 2, Murder Miners, and Little Racers STREET to name a few), and since I'm not sure how to fix this I figured I could at least provide a test for someone that knows more SM4 than me :P
-- v6: tests: Add a test for arrays with an expression as the index.
From: Ethan Lee flibitijibibo@gmail.com
See https://bugs.winehq.org/show_bug.cgi?id=54832
Signed-off-by: Ethan Lee flibitijibibo@gmail.com --- Makefile.am | 1 + tests/array-index-expr.shader_test | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/array-index-expr.shader_test
diff --git a/Makefile.am b/Makefile.am index f7c5c9a1..e279ebd3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -50,6 +50,7 @@ vkd3d_shader_tests = \ tests/arithmetic-int.shader_test \ tests/arithmetic-int-uniform.shader_test \ tests/arithmetic-uint.shader_test \ + tests/array-index-expr.shader_test \ tests/array-parameters.shader_test \ tests/asfloat.shader_test \ tests/asuint.shader_test \ diff --git a/tests/array-index-expr.shader_test b/tests/array-index-expr.shader_test new file mode 100644 index 00000000..54ffcf49 --- /dev/null +++ b/tests/array-index-expr.shader_test @@ -0,0 +1,25 @@ +% https://bugs.winehq.org/show_bug.cgi?id=54832 +[pixel shader todo] +uniform float4 f[2]; +uniform float2 i; + +float4 main() : sv_target +{ + return f[i.x + i.y]; +} + +[test] +uniform 0 float4 1.0 2.0 3.0 4.0 +uniform 4 float4 5.0 6.0 7.0 8.0 +uniform 8 float4 0 0 0 0 +todo draw quad +todo probe all rgba (1.0, 2.0, 3.0, 4.0) +uniform 8 float4 1 0 0 0 +todo draw quad +todo probe all rgba (5.0, 6.0, 7.0, 8.0) +uniform 8 float4 0 1 0 0 +todo draw quad +todo probe all rgba (5.0, 6.0, 7.0, 8.0) +uniform 8 float4 1 1 0 0 +todo draw quad +todo probe all rgba (0.0, 0.0, 0.0, 0.0)
Francisco Casas (@fcasas) commented about tests/array-index-expr.shader_test:
+[test] +uniform 0 float4 1.0 2.0 3.0 4.0 +uniform 4 float4 5.0 6.0 7.0 8.0 +uniform 8 float4 0 0 0 0 +todo draw quad +todo probe all rgba (1.0, 2.0, 3.0, 4.0) +uniform 8 float4 1 0 0 0 +todo draw quad +todo probe all rgba (5.0, 6.0, 7.0, 8.0) +uniform 8 float4 0 1 0 0 +todo draw quad +todo probe all rgba (5.0, 6.0, 7.0, 8.0) +uniform 8 float4 1 1 0 0 +todo draw quad +todo probe all rgba (0.0, 0.0, 0.0, 0.0)
This is testing a position outside the array, which as far as I know is undefined behavior.
On the WARP driver it retrieves (1.0, 1.0, 0.0, 0.0), instead of (0.0, 0.0, 0.0, 0.0) as it is actually accessing the `i` variable because of the overflow.
I suggest enlarging the array `f` to at least 3 elements.