From: Timur Kristóf Date: Thu, 26 Aug 2021 14:36:28 +0000 (+0200) Subject: aco: Emit zero for the derivatives of uniforms. X-Git-Tag: upstream/22.3.5~18627 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cfb0d931f27438c1f7c94defa078f2f9454c5a54;p=platform%2Fupstream%2Fmesa.git aco: Emit zero for the derivatives of uniforms. Observed in a shader from Resident Evil Village. This also helps prevent emitting invalid IR. Cc: mesa-stable Signed-off-by: Timur Kristóf Reviewed-by: Rhys Perry Part-of: --- diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index 631e3c5..31c25dd 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -3487,6 +3487,14 @@ visit_alu_instr(isel_context* ctx, nir_alu_instr* instr) case nir_op_fddy_fine: case nir_op_fddx_coarse: case nir_op_fddy_coarse: { + if (!nir_src_is_divergent(instr->src[0].src)) { + /* Source is the same in all lanes, so the derivative is zero. + * This also avoids emitting invalid IR. + */ + bld.copy(Definition(dst), Operand::zero()); + break; + } + Temp src = as_vgpr(ctx, get_alu_src(ctx, instr->src[0])); uint16_t dpp_ctrl1, dpp_ctrl2; if (instr->op == nir_op_fddx_fine) {