Module: Mesa Branch: main Commit: 219dc0fc0886fcd7f50c5945986c892261db5c51 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=219dc0fc0886fcd7f50c5945986c892261db5c51
Author: Pavel Ondračka <[email protected]> Date: Fri Jul 14 10:05:27 2023 +0200 r300: add a helper for checking number of temporary sources Reviewed-by: Filip Gawin <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24152> --- src/gallium/drivers/r300/compiler/radeon_compiler_util.c | 10 ++++++++++ src/gallium/drivers/r300/compiler/radeon_compiler_util.h | 3 +++ src/gallium/drivers/r300/compiler/radeon_program_alu.c | 8 +------- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/r300/compiler/radeon_compiler_util.c b/src/gallium/drivers/r300/compiler/radeon_compiler_util.c index 2a2542a47b2..17cb498b199 100644 --- a/src/gallium/drivers/r300/compiler/radeon_compiler_util.c +++ b/src/gallium/drivers/r300/compiler/radeon_compiler_util.c @@ -758,3 +758,13 @@ unsigned int rc_get_scalar_src_swz(unsigned int swizzle) assert(swz != RC_SWIZZLE_UNUSED); return swz; } + +bool rc_inst_has_three_diff_temp_srcs(struct rc_instruction *inst) +{ + return (inst->U.I.SrcReg[0].File == RC_FILE_TEMPORARY && + inst->U.I.SrcReg[1].File == RC_FILE_TEMPORARY && + inst->U.I.SrcReg[2].File == RC_FILE_TEMPORARY && + inst->U.I.SrcReg[0].Index != inst->U.I.SrcReg[1].Index && + inst->U.I.SrcReg[1].Index != inst->U.I.SrcReg[2].Index && + inst->U.I.SrcReg[0].Index != inst->U.I.SrcReg[2].Index); +} diff --git a/src/gallium/drivers/r300/compiler/radeon_compiler_util.h b/src/gallium/drivers/r300/compiler/radeon_compiler_util.h index 7c1d6bbc961..c16f768e89e 100644 --- a/src/gallium/drivers/r300/compiler/radeon_compiler_util.h +++ b/src/gallium/drivers/r300/compiler/radeon_compiler_util.h @@ -30,6 +30,8 @@ #ifndef RADEON_PROGRAM_UTIL_H #define RADEON_PROGRAM_UTIL_H +#include <stdbool.h> + #include "radeon_opcodes.h" struct radeon_compiler; @@ -126,4 +128,5 @@ float rc_get_constant_value( unsigned int rc_get_scalar_src_swz(unsigned int swizzle); +bool rc_inst_has_three_diff_temp_srcs(struct rc_instruction *inst); #endif /* RADEON_PROGRAM_UTIL_H */ diff --git a/src/gallium/drivers/r300/compiler/radeon_program_alu.c b/src/gallium/drivers/r300/compiler/radeon_program_alu.c index 2e2d75143e1..a56d81c62e7 100644 --- a/src/gallium/drivers/r300/compiler/radeon_program_alu.c +++ b/src/gallium/drivers/r300/compiler/radeon_program_alu.c @@ -397,13 +397,7 @@ static void transform_r300_vertex_CMP(struct radeon_compiler* c, { /* R5xx has a CMP, but we can use it only if it reads from less than * three different temps. */ - if (c->is_r500 && - (inst->U.I.SrcReg[0].File != RC_FILE_TEMPORARY || - inst->U.I.SrcReg[1].File != RC_FILE_TEMPORARY || - inst->U.I.SrcReg[2].File != RC_FILE_TEMPORARY || - inst->U.I.SrcReg[0].Index == inst->U.I.SrcReg[1].Index || - inst->U.I.SrcReg[1].Index == inst->U.I.SrcReg[2].Index || - inst->U.I.SrcReg[0].Index == inst->U.I.SrcReg[2].Index)) + if (c->is_r500 && !rc_inst_has_three_diff_temp_srcs(inst)) return; /* There is no decent CMP available on r300, so let's rig one up.
