r300/compiler: Always unroll loops when doing loop emulation.
authorTom Stellard <tstellar@gmail.com>
Wed, 4 Aug 2010 03:17:00 +0000 (20:17 -0700)
committerTom Stellard <tstellar@gmail.com>
Wed, 4 Aug 2010 03:17:00 +0000 (20:17 -0700)
src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c
src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c
src/mesa/drivers/dri/r300/compiler/radeon_emulate_loops.c
src/mesa/drivers/dri/r300/compiler/radeon_emulate_loops.h

index 070939497ced85a936b9fe98f4c37511b5c29e1e..c6246a81a24f8fdd162be8d4241894905780ef0d 100644 (file)
@@ -113,7 +113,7 @@ void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c)
                debug_program_log(c, "after unroll loops");
        }
        else{
-               rc_transform_loops(&c->Base, &loop_state, R300_PFS_MAX_ALU_INST);
+               rc_transform_loops(&c->Base, &loop_state);
                debug_program_log(c, "after transform loops");
 
                rc_emulate_branches(&c->Base);
index fe34ff67cdc0f64f618ac36db8347c1fcdd24c86..e940fedec20abdb89f91a71e1466e7f6027e2b99 100644 (file)
@@ -645,11 +645,11 @@ void r3xx_compile_vertex_program(struct r300_vertex_program_compiler* compiler)
         * on all chipsets. */
 
        if (compiler->Base.is_r500){
-               rc_transform_loops(&compiler->Base, &loop_state, R500_VS_MAX_ALU);
+               rc_transform_loops(&compiler->Base, &loop_state);
                rc_emulate_loops(&loop_state, R500_VS_MAX_ALU);
        } else {
+               rc_transform_loops(&compiler->Base, &loop_state);
                rc_emulate_loops(&loop_state, R300_VS_MAX_ALU);
-               rc_transform_loops(&compiler->Base, &loop_state, R300_VS_MAX_ALU);
        }
        debug_program_log(compiler, "after emulate loops");
 
index 94e3e5f4f516185e565cdc8aa537d27f4c12d7bb..24c3ae57b6e28ddc52f11e781fb446e1d41e980f 100644 (file)
@@ -186,6 +186,10 @@ static void get_incr_amount(void * data, struct rc_instruction * inst,
        }
 }
 
+/**
+ * If prog_inst_limit is -1, then all eligible loops will be unrolled regardless
+ * of how many iterations they have.
+ */
 static int try_unroll_loop(struct radeon_compiler * c, struct loop_info * loop,
                                                unsigned int prog_inst_limit)
 {
@@ -296,7 +300,8 @@ static int try_unroll_loop(struct radeon_compiler * c, struct loop_info * loop,
                return 0;
        }
 
-       if (iterations > loop_max_possible_iterations(c, loop,
+       if (prog_inst_limit > 0
+               && iterations > loop_max_possible_iterations(c, loop,
                                                        prog_inst_limit)) {
                return 0;
        }
@@ -422,8 +427,7 @@ static int build_loop_info(struct radeon_compiler * c, struct loop_info * loop,
  *        Null if there is an error.
  */
 static struct rc_instruction * transform_loop(struct emulate_loop_state * s,
-                                               struct rc_instruction * inst,
-                                               int prog_inst_limit)
+                                               struct rc_instruction * inst)
 {
        struct loop_info * loop;
 
@@ -435,7 +439,7 @@ static struct rc_instruction * transform_loop(struct emulate_loop_state * s,
        if (!build_loop_info(s->C, loop, inst))
                return NULL;
 
-       if(try_unroll_loop(s->C, loop, prog_inst_limit)){
+       if(try_unroll_loop(s->C, loop, -1)){
                return loop->BeginLoop->Next;
        }
 
@@ -472,8 +476,7 @@ static struct rc_instruction * transform_loop(struct emulate_loop_state * s,
 }
 
 void rc_transform_loops(struct radeon_compiler *c,
-                                       struct emulate_loop_state * s,
-                                       int prog_inst_limit)
+                                               struct emulate_loop_state * s)
 {
        struct rc_instruction * ptr;
 
@@ -483,7 +486,7 @@ void rc_transform_loops(struct radeon_compiler *c,
        while(ptr != &s->C->Program.Instructions) {
                if(ptr->Type == RC_INSTRUCTION_NORMAL &&
                                        ptr->U.I.Opcode == RC_OPCODE_BGNLOOP){
-                       ptr = transform_loop(s, ptr, prog_inst_limit);
+                       ptr = transform_loop(s, ptr);
                        if(!ptr){
                                return;
                        }
index 339527ba3bd467ab3c98e00b37802c2aeb63772b..86d91ef14bd8546f888746c56dde96cea0b11407 100644 (file)
@@ -24,7 +24,7 @@ struct emulate_loop_state {
 };
 
 void rc_transform_loops(struct radeon_compiler *c,
-                       struct emulate_loop_state * s, int prog_inst_limit);
+                                               struct emulate_loop_state * s);
 
 void rc_unroll_loops(struct radeon_compiler * c, int prog_inst_limit);