Mesa (master): i965: Clear the cached constant buffer entry in the VS at control flow.

Eric Anholt anholt at kemper.freedesktop.org
Mon Aug 30 18:23:10 UTC 2010


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

Author: Eric Anholt <eric at anholt.net>
Date:   Mon Aug 30 11:19:30 2010 -0700

i965: Clear the cached constant buffer entry in the VS at control flow.

Fixes the 7 regressions with constant buffers forced on with piglit -t
glsl (glsl-vs-if-*).

---

 src/mesa/drivers/dri/i965/brw_vs_emit.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c
index 720a656..1d88c6b 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c
@@ -116,6 +116,22 @@ get_first_reladdr_output(struct gl_vertex_program *vp)
    return first_reladdr_output;
 }
 
+/* Clears the record of which vp_const_buffer elements have been
+ * loaded into our constant buffer registers, for the starts of new
+ * blocks after control flow.
+ */
+static void
+clear_current_const(struct brw_vs_compile *c)
+{
+   unsigned int i;
+
+   if (c->vp->use_const_buffer) {
+      for (i = 0; i < 3; i++) {
+         c->current_const[i].index = -1;
+      }
+   }
+}
+
 /**
  * Preallocate GRF register before code emit.
  * Do things as simply as possible.  Allocate and populate all regs
@@ -313,10 +329,10 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c )
 
    if (c->vp->use_const_buffer) {
       for (i = 0; i < 3; i++) {
-         c->current_const[i].index = -1;
          c->current_const[i].reg = brw_vec8_grf(reg, 0);
          reg++;
       }
+      clear_current_const(c);
    }
 
    for (i = 0; i < 128; i++) {
@@ -1826,15 +1842,18 @@ void brw_vs_emit(struct brw_vs_compile *c )
 	 if_depth++;
 	 break;
       case OPCODE_ELSE:
+	 clear_current_const(c);
 	 assert(if_depth > 0);
 	 if_inst[if_depth-1] = brw_ELSE(p, if_inst[if_depth-1]);
 	 break;
       case OPCODE_ENDIF:
+	 clear_current_const(c);
          assert(if_depth > 0);
 	 brw_ENDIF(p, if_inst[--if_depth]);
 	 if_depth_in_loop[loop_depth]--;
 	 break;			
       case OPCODE_BGNLOOP:
+	 clear_current_const(c);
          loop_inst[loop_depth++] = brw_DO(p, BRW_EXECUTE_8);
 	 if_depth_in_loop[loop_depth] = 0;
          break;
@@ -1850,6 +1869,7 @@ void brw_vs_emit(struct brw_vs_compile *c )
          break;
       case OPCODE_ENDLOOP: 
          {
+	    clear_current_const(c);
             struct brw_instruction *inst0, *inst1;
 	    GLuint br = 1;
 




More information about the mesa-commit mailing list