[Mesa-stable] [PATCH 12/13] i965: If STATE_BASE_VERTEX is used, set its value

Ian Romanick idr at freedesktop.org
Fri Jun 20 18:01:02 PDT 2014


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: "10.2" <mesa-stable at lists.freedesktop.org>
---
 src/mesa/drivers/dri/i965/brw_draw.c | 37 ++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index ac21656..dd914b6 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -40,6 +40,7 @@
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
 #include "drivers/common/meta.h"
+#include "program/prog_parameter.h"
 
 #include "brw_blorp.h"
 #include "brw_draw.h"
@@ -392,6 +393,27 @@ static bool brw_try_draw_prims( struct gl_context *ctx,
    bool retval = true;
    GLuint i;
    bool fail_next = false;
+   GLint last_start = -1;
+   GLint base_vertex_idx = -1;
+
+   struct gl_program_parameter_list *const plist =
+      ctx->VertexProgram._Current->Base.Parameters;
+
+   /* Find the storage associated with STATE_BASE_VERTEX.  If there is
+    * storage, then we'll need to update its value each time
+    * prims[i].basevertex changes.
+    */
+   for (unsigned j = 0; j < plist->NumParameters; j++) {
+      if (plist->Parameters[j].StateIndexes[0] == STATE_INTERNAL
+          && plist->Parameters[j].StateIndexes[1] == STATE_BASE_VERTEX) {
+         base_vertex_idx = j;
+         break;
+      }
+   }
+
+   if (base_vertex_idx >= 0) {
+      ctx->VertexProgram._Current->Base.Parameters->ParameterValues[base_vertex_idx][0].i = brw->basevertex;
+   }
 
    if (ctx->NewState)
       _mesa_update_state( ctx );
@@ -462,11 +484,26 @@ static bool brw_try_draw_prims( struct gl_context *ctx,
           brw->basevertex != prims[i].basevertex) {
          brw->num_instances = prims[i].num_instances;
          brw->basevertex = prims[i].basevertex;
+
+         if (base_vertex_idx >= 0) {
+            plist->ParameterValues[base_vertex_idx][0].i = brw->basevertex;
+            ctx->NewState |= _NEW_PROGRAM_CONSTANTS;
+            _mesa_update_state(ctx);
+         }
+
          if (i > 0) { /* For i == 0 we just did this before the loop */
             brw->state.dirty.brw |= BRW_NEW_VERTICES;
             brw_merge_inputs(brw, arrays);
          }
       }
+
+      if (prims[i].start != last_start && base_vertex_idx >= 0) {
+         plist->ParameterValues[base_vertex_idx][0].i = prims[i].start;
+         ctx->NewState |= _NEW_PROGRAM_CONSTANTS;
+         _mesa_update_state(ctx);
+         last_start = prims[i].start;
+      }
+
       if (brw->gen < 6)
 	 brw_set_prim(brw, &prims[i]);
       else
-- 
1.8.1.4



More information about the mesa-stable mailing list