From a8e1e5b5c2aeb7c2fb4eff2203a026090f0853b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Ondra=C4=8Dka?= Date: Wed, 22 Feb 2023 20:32:33 +0100 Subject: [PATCH] r300: simplify KILL transformation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We had some special cases before when we could actually get some IFs on R300 with VDPAU. Now that VDPAU is gone and everything goes through ntt, we don't have to worry anymore. Remove the complicated logic and just always transform KILL into KIL none.-1 No shader-db change on RV530 or RV370. Signed-off-by: Pavel Ondračka Reviewed-by: Emma Anholt Reviewed-by: Filip Gawin Part-of: --- .../drivers/r300/compiler/r3xx_fragprog.c | 3 - .../r300/compiler/radeon_program_alu.c | 65 +++---------------- .../r300/compiler/radeon_program_alu.h | 3 - 3 files changed, 8 insertions(+), 63 deletions(-) diff --git a/src/gallium/drivers/r300/compiler/r3xx_fragprog.c b/src/gallium/drivers/r300/compiler/r3xx_fragprog.c index bd28884c7be..9f058e78189 100644 --- a/src/gallium/drivers/r300/compiler/r3xx_fragprog.c +++ b/src/gallium/drivers/r300/compiler/r3xx_fragprog.c @@ -100,9 +100,6 @@ void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c) struct radeon_compiler_pass fs_list[] = { /* NAME DUMP PREDICATE FUNCTION PARAM */ {"rewrite depth out", 1, 1, rc_rewrite_depth_out, NULL}, - /* This transformation needs to be done before any of the IF - * instructions are modified. */ - {"transform KILP", 1, 1, rc_transform_KILL, NULL}, {"force alpha to one", 1, alpha2one, rc_local_transform, force_alpha_to_one}, {"transform TEX", 1, 1, rc_local_transform, rewrite_tex}, {"transform IF", 1, is_r500, r500_transform_IF, NULL}, diff --git a/src/gallium/drivers/r300/compiler/radeon_program_alu.c b/src/gallium/drivers/r300/compiler/radeon_program_alu.c index 4f2c5081c62..c6d682b40ac 100644 --- a/src/gallium/drivers/r300/compiler/radeon_program_alu.c +++ b/src/gallium/drivers/r300/compiler/radeon_program_alu.c @@ -569,6 +569,13 @@ static void transform_SUB(struct radeon_compiler* c, inst->U.I.SrcReg[1] = negate(inst->U.I.SrcReg[1]); } +static void transform_KILP(struct radeon_compiler * c, + struct rc_instruction * inst) +{ + inst->U.I.SrcReg[0] = negate(builtin_one); + inst->U.I.Opcode = RC_OPCODE_KIL; +} + /** * Can be used as a transformation for @ref radeonClauseLocalTransform, * no userData necessary. @@ -593,6 +600,7 @@ int radeonTransformALU( case RC_OPCODE_DP2: transform_DP2(c, inst); return 1; case RC_OPCODE_DST: transform_DST(c, inst); return 1; case RC_OPCODE_FLR: transform_FLR(c, inst); return 1; + case RC_OPCODE_KILP: transform_KILP(c, inst); return 1; case RC_OPCODE_LIT: transform_LIT(c, inst); return 1; case RC_OPCODE_LRP: transform_LRP(c, inst); return 1; case RC_OPCODE_POW: transform_POW(c, inst); return 1; @@ -1080,63 +1088,6 @@ int radeonTransformDeriv(struct radeon_compiler* c, return 1; } -/** - * IF Temp[0].x -> IF Temp[0].x - * ... -> ... - * KILL -> KIL -abs(Temp[0].x) - * ... -> ... - * ENDIF -> ENDIF - * - * === OR === - * - * IF Temp[0].x -> IF Temp[0].x - * ... -> ... - * ELSE -> ELSE - * ... -> ... - * KILL -> KIL -abs(Temp[0].x) - * ... -> ... - * ENDIF -> ENDIF - * - * === OR === - * - * KILL -> KIL -none.1111 - * - * This needs to be done in its own pass, because it might modify the - * instructions before and after KILL. - */ -void rc_transform_KILL(struct radeon_compiler * c, void *user) -{ - struct rc_instruction * inst; - for (inst = c->Program.Instructions.Next; - inst != &c->Program.Instructions; inst = inst->Next) { - struct rc_instruction * if_inst; - unsigned in_if = 0; - - if (inst->U.I.Opcode != RC_OPCODE_KILP) - continue; - - for (if_inst = inst->Prev; if_inst != &c->Program.Instructions; - if_inst = if_inst->Prev) { - - if (if_inst->U.I.Opcode == RC_OPCODE_IF) { - in_if = 1; - break; - } - } - - inst->U.I.Opcode = RC_OPCODE_KIL; - - if (!in_if) { - inst->U.I.SrcReg[0] = negate(builtin_one); - } else { - /* This should work even if the KILP is inside the ELSE - * block, because -0.0 is considered negative. */ - inst->U.I.SrcReg[0] = - negate(absolute(if_inst->U.I.SrcReg[0])); - } - } -} - int rc_force_output_alpha_to_one(struct radeon_compiler *c, struct rc_instruction *inst, void *data) { diff --git a/src/gallium/drivers/r300/compiler/radeon_program_alu.h b/src/gallium/drivers/r300/compiler/radeon_program_alu.h index 6f347d1c9f0..eb522b2ead8 100644 --- a/src/gallium/drivers/r300/compiler/radeon_program_alu.h +++ b/src/gallium/drivers/r300/compiler/radeon_program_alu.h @@ -65,9 +65,6 @@ int radeonTransformDeriv( struct rc_instruction * inst, void*); -void rc_transform_KILL(struct radeon_compiler * c, - void *user); - int rc_force_output_alpha_to_one(struct radeon_compiler *c, struct rc_instruction *inst, void *data);