On Tue, Mar 15, 2016 at 8:41 PM, Eric Anholt <e...@anholt.net> wrote:

> I found this in a shader that was doing an alpha test when alpha is fixed
> at 1.0.
>
> instructions in affected programs:     16 -> 15 (-6.25%)
> total uniforms in shared programs: 28703 -> 28703 (0.00%)
> ---
>  src/compiler/nir/nir_opt_constant_folding.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/src/compiler/nir/nir_opt_constant_folding.c
> b/src/compiler/nir/nir_opt_constant_folding.c
> index 04876a4..8a353c2 100644
> --- a/src/compiler/nir/nir_opt_constant_folding.c
> +++ b/src/compiler/nir/nir_opt_constant_folding.c
> @@ -130,6 +130,14 @@ constant_fold_intrinsic_instr(nir_intrinsic_instr
> *instr)
>        progress |= constant_fold_deref(&instr->instr, instr->variables[i]);
>     }
>
> +   if (instr->intrinsic == nir_intrinsic_discard_if) {
> +      nir_const_value *src_val = nir_src_as_const_value(instr->src[0]);
> +      if (src_val && src_val->u[0] == 0) {
> +         nir_instr_remove(&instr->instr);
> +         progress = true;
> +      }
> +   }
>

opt_constant_folding seems like a strange place to put this, but I can't
think of anything better.

Reviewed-by: Jason Ekstrand <ja...@jlekstrand.net>


> +
>     return progress;
>  }
>
> --
> 2.7.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to