i965: Reset the "need new CURBE BO" flag when we make a new CURBE bo.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_curbe.c
index 4be6c77aa1e359d571c1653a30c693d61c7f2790..3440523ea759a5796f934bdf1e3c884bfc487bdc 100644 (file)
@@ -130,7 +130,7 @@ static void calculate_curbe_offsets( struct brw_context *brw )
 const struct brw_tracked_state brw_curbe_offsets = {
    .dirty = {
       .mesa = _NEW_TRANSFORM,
-      .brw  = BRW_NEW_VERTEX_PROGRAM,
+      .brw  = BRW_NEW_VERTEX_PROGRAM | BRW_NEW_CONTEXT,
       .cache = CACHE_NEW_WM_PROG
    },
    .prepare = calculate_curbe_offsets
@@ -256,13 +256,24 @@ static void prepare_constant_buffer(struct brw_context *brw)
        */
       _mesa_load_state_parameters(ctx, vp->program.Base.Parameters); 
 
-      /* XXX just use a memcpy here */
-      for (i = 0; i < nr; i++) {
-         const GLfloat *value = vp->program.Base.Parameters->ParameterValues[i];
-        buf[offset + i * 4 + 0] = value[0];
-        buf[offset + i * 4 + 1] = value[1];
-        buf[offset + i * 4 + 2] = value[2];
-        buf[offset + i * 4 + 3] = value[3];
+      if (vp->use_const_buffer) {
+        /* Load the subset of push constants that will get used when
+         * we also have a pull constant buffer.
+         */
+        for (i = 0; i < vp->program.Base.Parameters->NumParameters; i++) {
+           if (brw->vs.constant_map[i] != -1) {
+              assert(brw->vs.constant_map[i] <= nr);
+              memcpy(buf + offset + brw->vs.constant_map[i] * 4,
+                     vp->program.Base.Parameters->ParameterValues[i],
+                     4 * sizeof(float));
+           }
+        }
+      } else {
+        for (i = 0; i < nr; i++) {
+           memcpy(buf + offset + i * 4,
+                  vp->program.Base.Parameters->ParameterValues[i],
+                  4 * sizeof(float));
+        }
       }
    }
 
@@ -307,6 +318,7 @@ static void prepare_constant_buffer(struct brw_context *brw)
         brw->curbe.curbe_bo = dri_bo_alloc(brw->intel.bufmgr, "CURBE",
                                            4096, 1 << 6);
         brw->curbe.curbe_next_offset = 0;
+        brw->curbe.need_new_bo = GL_FALSE;
       }
 
       brw->curbe.curbe_offset = brw->curbe.curbe_next_offset;
@@ -340,7 +352,7 @@ static void emit_constant_buffer(struct brw_context *brw)
    struct intel_context *intel = &brw->intel;
    GLuint sz = brw->curbe.total_size;
 
-   BEGIN_BATCH(2, IGNORE_CLIPRECTS);
+   BEGIN_BATCH(2);
    if (sz == 0) {
       OUT_BATCH((CMD_CONST_BUFFER << 16) | (2 - 2));
       OUT_BATCH(0);