Module: Mesa
Branch: master
Commit: 680f486ffd4aab8b9354f1b5a035b3881ac2310c
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=680f486ffd4aab8b9354f1b5a035b3881ac2310c

Author: Tom Stellard <tstel...@gmail.com>
Date:   Mon Jul 12 13:14:38 2010 -0700

r300/compiler: Don't unroll loops with continue or break.

---

 .../dri/r300/compiler/radeon_emulate_loops.c       |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_emulate_loops.c 
b/src/mesa/drivers/dri/r300/compiler/radeon_emulate_loops.c
index 131e9e7..fed4d88 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_emulate_loops.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_emulate_loops.c
@@ -191,7 +191,7 @@ static void get_incr_amount(void * data, struct 
rc_instruction * inst,
 static int transform_const_loop(struct emulate_loop_state * s,
                                                struct loop_info * loop)
 {
-       int end_loops = 1;
+       int end_loops;
        int iterations;
        struct count_inst count_inst;
        float limit_value;
@@ -235,6 +235,7 @@ static int transform_const_loop(struct emulate_loop_state * 
s,
        count_inst.Swz = counter->Swizzle;
        count_inst.Amount = 0.0f;
        count_inst.Unknown = 0;
+       end_loops = 1;
        for(inst = loop->BeginLoop->Next; end_loops > 0; inst = inst->Next){
                switch(inst->U.I.Opcode){
                /* XXX In the future we might want to try to unroll nested
@@ -246,6 +247,16 @@ static int transform_const_loop(struct emulate_loop_state 
* s,
                        loop->EndLoop = inst;
                        end_loops--;
                        break;
+               case RC_OPCODE_BRK:
+                       /* Don't unroll loops if it has a BRK instruction
+                        * other one used when testing the main conditional
+                        * of the loop. */
+
+                       /* Make sure we haven't entered a nested loops. */
+                       if(inst != loop->Brk && end_loops == 1) {
+                               return 0;
+                       }
+                       break;
                /* XXX Check if the counter is modified within an if statement.
                 */
                case RC_OPCODE_IF:

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to