diff --git a/src/compiler/nir/nir_opt_fp_math_ctrl.c b/src/compiler/nir/nir_opt_fp_math_ctrl.c index fed39ff52af..0d24b5b202d 100644 --- a/src/compiler/nir/nir_opt_fp_math_ctrl.c +++ b/src/compiler/nir/nir_opt_fp_math_ctrl.c @@ -225,10 +225,20 @@ opt_intrin_fp_math_ctrl(nir_intrinsic_instr *intrin) case nir_intrinsic_ddx_fine: case nir_intrinsic_ddy: case nir_intrinsic_ddy_coarse: - case nir_intrinsic_ddy_fine: - if (intrin->instr.pass_flags) + case nir_intrinsic_ddy_fine: { + unsigned fp_math_ctrl = nir_intrinsic_fp_math_ctrl(intrin); + if ((fp_math_ctrl & nir_fp_preserve_signed_zero) == 0) + return false; + + if (intrin->instr.pass_flags) { src_mark_preserve_sz(&intrin->src[0], NULL); - return false; + return false; + } else { + fp_math_ctrl &= ~nir_fp_preserve_signed_zero; + nir_intrinsic_set_fp_math_ctrl(intrin, fp_math_ctrl); + return true; + } + } default: break; }