[Mesa-dev] [RFC] discard optimization and lowering passes

Marek Olšák maraeo at gmail.com
Thu Nov 25 06:55:54 PST 2010


I am ok with either solution as long as it fixes *Bug
31827*<https://bugs.freedesktop.org/show_bug.cgi?id=31827>
.

I have tested my patch and it works. There was a bug in lower_jumps that
made discard statements with a condition be treated as without it, causing
the removal of all instructions after discard. This code from my patch fixes
it:

--- a/src/glsl/lower_jumps.cpp
+++ b/src/glsl/lower_jumps.cpp
@@ -202,7 +202,9 @@ struct ir_lower_jumps_visitor : public
ir_control_flow_visitor {

   virtual void visit(class ir_discard * ir)
   {
-      truncate_after_instruction(ir);
+      if (!ir->condition) {
+         truncate_after_instruction(ir);
+      }
      this->block.min_strength = strength_discard;
   }

Marek

On Thu, Nov 25, 2010 at 12:40 PM, Kenneth Graunke <kenneth at whitecape.org>wrote:

> I was actually working on the same thing today, and wrote two passes for
> dealing with discards.  I was just looking into adding ir_to_mesa and
> brw_fs
> support when I saw your patch, so I just split that out and reused it.
>  Thanks
> for writing that!
>
> I'm not sure whether doing it in a separate pass (like I've done) or in
> lower_if_to_cond_assign is better.
>
> Also, I haven't been able to properly test any of this yet since I don't
> yet have brw_fs support.  It may be completely broken, but I wanted to put
> it
> out there anyway so people know there are two possible solutions.
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20101125/16da7cae/attachment.htm>


More information about the mesa-dev mailing list