From 105b48c85c2be2970bbe9c9185af98ec9c8ff674 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 4 Jan 2022 16:51:01 -0800 Subject: [PATCH] r300: Fix omod failing to increase the number of channels stored. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In dEQP-GLES2.functional.shaders.operator.geometric.reflect.highp_vec2_fragment and friends this pass would turn: 0: DP3 temp[1].x, input[1].yx0_, input[0].wy0_; 1: MUL temp[2].xy, temp[1].xx__, const[0].xx__; into 0: DP3 temp[2].x * 2, input[1].yx0_, input[0].wy0_; 1: MUL temp[3].xy, temp[2].xy__, input[1].yx__; Note the attempt to use .y of temp[2]. Just bail when we more dst channels than src channels, since the rewrite can't generate more channels for us. Fixes this subset of tests (which I hadn't included in the xfails until now since results hadn't quite been stable). Cc: mesa-stable Reviewed-by: Marek Olšák Tested-by: Filip Gawin Part-of: --- src/gallium/drivers/r300/ci/r300-rv515-fails.txt | 7 ------- src/gallium/drivers/r300/compiler/radeon_optimize.c | 11 ++++++++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/r300/ci/r300-rv515-fails.txt b/src/gallium/drivers/r300/ci/r300-rv515-fails.txt index 02f463f8588..6d129ee2797 100644 --- a/src/gallium/drivers/r300/ci/r300-rv515-fails.txt +++ b/src/gallium/drivers/r300/ci/r300-rv515-fails.txt @@ -85,13 +85,6 @@ dEQP-GLES2.functional.shaders.loops.for_constant_iterations.mixed_break_continue dEQP-GLES2.functional.shaders.loops.for_dynamic_iterations.mixed_break_continue_vertex,Fail dEQP-GLES2.functional.shaders.loops.for_uniform_iterations.mixed_break_continue_vertex,Fail -dEQP-GLES2.functional.shaders.operator.geometric.reflect.highp_vec2_fragment,Fail -dEQP-GLES2.functional.shaders.operator.geometric.reflect.highp_vec3_fragment,Fail -dEQP-GLES2.functional.shaders.operator.geometric.reflect.highp_vec4_fragment,Fail -dEQP-GLES2.functional.shaders.operator.geometric.reflect.mediump_vec2_fragment,Fail -dEQP-GLES2.functional.shaders.operator.geometric.reflect.mediump_vec3_fragment,Fail -dEQP-GLES2.functional.shaders.operator.geometric.reflect.mediump_vec4_fragment,Fail - dEQP-GLES2.functional.shaders.return.return_in_dynamic_loop_dynamic_vertex,Fail dEQP-GLES2.functional.shaders.random.texture.fragment.141,Fail diff --git a/src/gallium/drivers/r300/compiler/radeon_optimize.c b/src/gallium/drivers/r300/compiler/radeon_optimize.c index 5c825a0a62a..a7e9445ce11 100644 --- a/src/gallium/drivers/r300/compiler/radeon_optimize.c +++ b/src/gallium/drivers/r300/compiler/radeon_optimize.c @@ -26,6 +26,8 @@ * */ +#include "util/u_math.h" + #include "radeon_dataflow.h" #include "radeon_compiler.h" @@ -837,8 +839,15 @@ static int peephole_mul_omod( return 0; } - /* Rewrite the instructions */ writemask_sum = rc_variable_writemask_sum(writer_list->Item); + + /* rc_normal_rewrite_writemask can't expand a previous writemask to store + * more channels replicated. + */ + if (util_bitcount(writemask_sum) < util_bitcount(inst_mul->U.I.DstReg.WriteMask)) + return 0; + + /* Rewrite the instructions */ for (var = writer_list->Item; var; var = var->Friend) { struct rc_variable * writer = var; unsigned conversion_swizzle = rc_make_conversion_swizzle(