From bff9068a7fbbd51e34e962fb74a677f092bd4545 Mon Sep 17 00:00:00 2001 From: Francisco Casas <fcasas@codeweavers.com> Date: Tue, 11 Mar 2025 14:51:38 -0300 Subject: [PATCH 1/2] tests: Add a hard test for copy-propagation invalidation. This test is currently miscompiling on SM4 because copy_propagation_invalidate_variable_from_deref_recurse() is not always invalidating the right components. --- tests/hlsl/hard-copy-prop.shader_test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/hlsl/hard-copy-prop.shader_test b/tests/hlsl/hard-copy-prop.shader_test index 3af552fad..90507496b 100644 --- a/tests/hlsl/hard-copy-prop.shader_test +++ b/tests/hlsl/hard-copy-prop.shader_test @@ -205,3 +205,21 @@ float4 main() : sv_target return 0; } + +[pixel shader todo(sm<4)] +float a; + +float4 main() : sv_target +{ + float arr[2][2] = {1, 2, 3, 4}; + + if (a > 0) + arr[1][1] = 5; + + return float4(arr[0][0], arr[0][1], arr[1][0], arr[1][1]); +} + +[test] +uniform 0 float 11.0 +todo(sm<4) draw quad +todo(sm<6) probe (0, 0) rgba(1, 2, 3, 5) -- GitLab From 09b9f8ff9f52a6075a826e4f9afc0750aac69b53 Mon Sep 17 00:00:00 2001 From: Francisco Casas <fcasas@codeweavers.com> Date: Tue, 11 Mar 2025 14:26:27 -0300 Subject: [PATCH 2/2] vkd3d-shader/hlsl: Fix invalidation of the wrong components in copy-propagation. Fixes: 1bba18aa75863ba862b1ff90fd31ee74fd6ec7ef. --- libs/vkd3d-shader/hlsl_codegen.c | 4 ++-- tests/hlsl/hard-copy-prop.shader_test | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index aac4e4c04..e95eaa39d 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -1638,14 +1638,14 @@ static void copy_propagation_invalidate_variable_from_deref_recurse(struct hlsl_ return; copy_propagation_invalidate_variable_from_deref_recurse(ctx, var_def, deref, subtype, - depth + 1, index * subtype_comp_count, writemask, time); + depth + 1, comp_start + index * subtype_comp_count, writemask, time); } else { for (i = 0; i < hlsl_type_element_count(type); ++i) { copy_propagation_invalidate_variable_from_deref_recurse(ctx, var_def, deref, subtype, - depth + 1, i * subtype_comp_count, writemask, time); + depth + 1, comp_start + i * subtype_comp_count, writemask, time); } } } diff --git a/tests/hlsl/hard-copy-prop.shader_test b/tests/hlsl/hard-copy-prop.shader_test index 90507496b..063758922 100644 --- a/tests/hlsl/hard-copy-prop.shader_test +++ b/tests/hlsl/hard-copy-prop.shader_test @@ -222,4 +222,4 @@ float4 main() : sv_target [test] uniform 0 float 11.0 todo(sm<4) draw quad -todo(sm<6) probe (0, 0) rgba(1, 2, 3, 5) +probe (0, 0) rgba(1, 2, 3, 5) -- GitLab