From dee49f42061ce3d2e4a47630e63781a1ec584ddb Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 31 Mar 2025 16:13:50 -0700 Subject: [PATCH] brw/algebraic: Optimize derivative of convergent value This is mostly defensive. If a convergent value ever ended up as a source of a DDX or DDY, the eu_emit code will ignore the stride. This will result in bad code being generated. No shader-db or fossil-db changes on any Intel platform. v2: DDX and DDY will always be float, but brw_imm_for_type only works with integer types. Reviewed-by: Kenneth Graunke Suggested-by: Ken Fixes: d5d7ae22ae4 ("brw/nir: Fix up handling of sources that might be convergent vectors") Part-of: --- src/intel/compiler/brw_opt_algebraic.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/intel/compiler/brw_opt_algebraic.cpp b/src/intel/compiler/brw_opt_algebraic.cpp index 15517eff1be..8880ba955b9 100644 --- a/src/intel/compiler/brw_opt_algebraic.cpp +++ b/src/intel/compiler/brw_opt_algebraic.cpp @@ -324,6 +324,17 @@ brw_opt_constant_fold_instruction(const intel_device_info *devinfo, brw_inst *in } break; + case FS_OPCODE_DDX_COARSE: + case FS_OPCODE_DDX_FINE: + case FS_OPCODE_DDY_COARSE: + case FS_OPCODE_DDY_FINE: + if (is_uniform(inst->src[0]) || inst->src[0].is_scalar) { + inst->opcode = BRW_OPCODE_MOV; + inst->src[0] = retype(brw_imm_uq(0), inst->dst.type); + progress = true; + } + break; + default: break; }