Mesa (gallium-0.2): mesa: fix temp register allocation problems.

Zack Rusin zack at kemper.freedesktop.org
Thu Oct 2 07:37:23 PDT 2008


Module: Mesa
Branch: gallium-0.2
Commit: 5620c20b24dc4f780a2246eb5270c4476b487e0a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5620c20b24dc4f780a2246eb5270c4476b487e0a

Author: Brian Paul <brian.paul at tungstengraphics.com>
Date:   Fri Sep 26 11:18:06 2008 -0600

mesa: fix temp register allocation problems.

Complex texcombine modes were running out of registers (>32 registers for 8 tex units).

---

 src/mesa/main/texenvprogram.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index 2bce93e..f6bbbcf 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -411,6 +411,14 @@ static struct ureg get_tex_temp( struct texenv_fragment_program *p )
 }
 
 
+/** Mark a temp reg as being no longer allocatable. */
+static void reserve_temp( struct texenv_fragment_program *p, struct ureg r )
+{
+   if (r.file == PROGRAM_TEMPORARY)
+      p->temps_output |= (1 << r.idx);
+}
+
+
 static void release_temps(GLcontext *ctx, struct texenv_fragment_program *p )
 {
    GLuint max_temp = ctx->Const.FragmentProgram.MaxTemps;
@@ -504,10 +512,12 @@ emit_op(struct texenv_fragment_program *p,
 
    emit_dst( &inst->DstReg, dest, mask );
 
+#if 0
    /* Accounting for indirection tracking:
     */
    if (dest.file == PROGRAM_TEMPORARY)
       p->temps_output |= 1 << dest.idx;
+#endif
 
    return inst;
 }
@@ -562,6 +572,10 @@ static struct ureg emit_texld( struct texenv_fragment_program *p,
 
    p->program->Base.NumTexInstructions++;
 
+   /* Accounting for indirection tracking:
+    */
+   reserve_temp(p, dest);
+
    /* Is this a texture indirection?
     */
    if ((coord.file == PROGRAM_TEMPORARY &&
@@ -1079,6 +1093,7 @@ create_new_program(GLcontext *ctx, struct state_key *key,
       for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++)
 	 if (key->enabled_units & (1<<unit)) {
 	    p.src_previous = emit_texenv( &p, unit );
+            reserve_temp(&p, p.src_previous); /* don't re-use this temp reg */
 	    release_temps(ctx, &p);	/* release all temps */
 	 }
    }



More information about the mesa-commit mailing list