<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 15, 2016 at 8:41 PM, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net" target="_blank">eric@anholt.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I found this in a shader that was doing an alpha test when alpha is fixed<br>
at 1.0.<br>
<br>
instructions in affected programs: 16 -> 15 (-6.25%)<br>
total uniforms in shared programs: 28703 -> 28703 (0.00%)<br>
---<br>
src/compiler/nir/nir_opt_constant_folding.c | 8 ++++++++<br>
1 file changed, 8 insertions(+)<br>
<br>
diff --git a/src/compiler/nir/nir_opt_constant_folding.c b/src/compiler/nir/nir_opt_constant_folding.c<br>
index 04876a4..8a353c2 100644<br>
--- a/src/compiler/nir/nir_opt_constant_folding.c<br>
+++ b/src/compiler/nir/nir_opt_constant_folding.c<br>
@@ -130,6 +130,14 @@ constant_fold_intrinsic_instr(nir_intrinsic_instr *instr)<br>
progress |= constant_fold_deref(&instr->instr, instr->variables[i]);<br>
}<br>
<br>
+ if (instr->intrinsic == nir_intrinsic_discard_if) {<br>
+ nir_const_value *src_val = nir_src_as_const_value(instr->src[0]);<br>
+ if (src_val && src_val->u[0] == 0) {<br>
+ nir_instr_remove(&instr->instr);<br>
+ progress = true;<br>
+ }<br>
+ }<br></blockquote><div><br></div><div>opt_constant_folding seems like a strange place to put this, but I can't think of anything better.<br><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
return progress;<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.7.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>