[Mesa-dev] [PATCH 06/21] u_vbuf: override set_vertex_buffers

Marek Olšák maraeo at gmail.com
Wed Apr 11 08:38:40 PDT 2012


---
 src/gallium/auxiliary/util/u_vbuf.c          |   81 +++++++++++++++-----------
 src/gallium/auxiliary/util/u_vbuf.h          |   18 +-----
 src/gallium/drivers/r300/r300_blit.c         |    4 +-
 src/gallium/drivers/r300/r300_context.c      |    4 +-
 src/gallium/drivers/r300/r300_context.h      |    6 +-
 src/gallium/drivers/r300/r300_emit.c         |    9 ++-
 src/gallium/drivers/r300/r300_render.c       |   22 +++----
 src/gallium/drivers/r300/r300_state.c        |   12 ++--
 src/gallium/drivers/r600/evergreen_state.c   |    4 +-
 src/gallium/drivers/r600/r600_pipe.h         |    2 +
 src/gallium/drivers/r600/r600_state.c        |    4 +-
 src/gallium/drivers/r600/r600_state_common.c |    8 +-
 12 files changed, 86 insertions(+), 88 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c
index 7883845..92a7df1 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -70,6 +70,11 @@ struct u_vbuf_priv {
    struct translate_cache *translate_cache;
    struct cso_cache *cso_cache;
 
+   /* Vertex buffers for the driver.
+    * There are no user buffers. */
+   struct pipe_vertex_buffer real_vertex_buffer[PIPE_MAX_ATTRIBS];
+   int nr_real_vertex_buffers;
+
    /* The index buffer. */
    struct pipe_index_buffer index_buffer;
 
@@ -99,6 +104,9 @@ struct u_vbuf_priv {
 
    void (*driver_set_index_buffer)(struct pipe_context *pipe,
 				   const struct pipe_index_buffer *);
+   void (*driver_set_vertex_buffers)(struct pipe_context *,
+				     unsigned num_buffers,
+				     const struct pipe_vertex_buffer *);
 };
 
 static void u_vbuf_init_format_caps(struct u_vbuf_priv *mgr)
@@ -209,8 +217,8 @@ void u_vbuf_destroy(struct u_vbuf *mgrb)
    for (i = 0; i < mgr->b.nr_vertex_buffers; i++) {
       pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, NULL);
    }
-   for (i = 0; i < mgr->b.nr_real_vertex_buffers; i++) {
-      pipe_resource_reference(&mgr->b.real_vertex_buffer[i].buffer, NULL);
+   for (i = 0; i < mgr->nr_real_vertex_buffers; i++) {
+      pipe_resource_reference(&mgr->real_vertex_buffer[i].buffer, NULL);
    }
 
    translate_cache_destroy(mgr->translate_cache);
@@ -324,13 +332,13 @@ u_vbuf_translate_buffers(struct u_vbuf_priv *mgr, struct translate_key *key,
    }
 
    /* Setup the new vertex buffer. */
-   mgr->b.real_vertex_buffer[out_vb].buffer_offset = out_offset;
-   mgr->b.real_vertex_buffer[out_vb].stride = key->output_stride;
+   mgr->real_vertex_buffer[out_vb].buffer_offset = out_offset;
+   mgr->real_vertex_buffer[out_vb].stride = key->output_stride;
 
    /* Move the buffer reference. */
    pipe_resource_reference(
-      &mgr->b.real_vertex_buffer[out_vb].buffer, NULL);
-   mgr->b.real_vertex_buffer[out_vb].buffer = out_buffer;
+      &mgr->real_vertex_buffer[out_vb].buffer, NULL);
+   mgr->real_vertex_buffer[out_vb].buffer = out_buffer;
 }
 
 static boolean
@@ -364,15 +372,15 @@ u_vbuf_translate_find_free_vb_slots(struct u_vbuf_priv *mgr,
                /*printf("found slot=%i for type=%i\n", i, type);*/
                fallback_vbs[type] = i;
                i++;
-               if (i > mgr->b.nr_real_vertex_buffers) {
-                  mgr->b.nr_real_vertex_buffers = i;
+               if (i > mgr->nr_real_vertex_buffers) {
+                  mgr->nr_real_vertex_buffers = i;
                }
                break;
             }
          }
          if (i == PIPE_MAX_ATTRIBS) {
             /* fail, reset the number to its original value */
-            mgr->b.nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
+            mgr->nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
             return FALSE;
          }
       }
@@ -495,7 +503,7 @@ u_vbuf_translate_begin(struct u_vbuf_priv *mgr,
 
          /* Fixup the stride for constant attribs. */
          if (type == VB_CONST) {
-            mgr->b.real_vertex_buffer[mgr->fallback_vbs[VB_CONST]].stride = 0;
+            mgr->real_vertex_buffer[mgr->fallback_vbs[VB_CONST]].stride = 0;
          }
       }
    }
@@ -544,11 +552,11 @@ static void u_vbuf_translate_end(struct u_vbuf_priv *mgr)
    for (i = 0; i < VB_NUM; i++) {
       unsigned vb = mgr->fallback_vbs[i];
       if (vb != ~0) {
-         pipe_resource_reference(&mgr->b.real_vertex_buffer[vb].buffer, NULL);
+         pipe_resource_reference(&mgr->real_vertex_buffer[vb].buffer, NULL);
          mgr->fallback_vbs[i] = ~0;
       }
    }
-   mgr->b.nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
+   mgr->nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
 }
 
 #define FORMAT_REPLACE(what, withwhat) \
@@ -682,11 +690,11 @@ void u_vbuf_destroy_vertex_elements(struct u_vbuf *mgr,
    FREE(ve);
 }
 
-void u_vbuf_set_vertex_buffers(struct u_vbuf *mgrb,
-                               unsigned count,
-                               const struct pipe_vertex_buffer *bufs)
+static void u_vbuf_set_vertex_buffers(struct pipe_context *pipe,
+                                      unsigned count,
+                                      const struct pipe_vertex_buffer *bufs)
 {
-   struct u_vbuf_priv *mgr = (struct u_vbuf_priv*)mgrb;
+   struct u_vbuf_priv *mgr = (struct u_vbuf_priv*)pipe->draw;
    unsigned i;
 
    mgr->any_user_vbs = FALSE;
@@ -711,36 +719,41 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf *mgrb,
 
       pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, vb->buffer);
 
-      mgr->b.real_vertex_buffer[i].buffer_offset =
+      mgr->real_vertex_buffer[i].buffer_offset =
       mgr->b.vertex_buffer[i].buffer_offset = vb->buffer_offset;
 
-      mgr->b.real_vertex_buffer[i].stride =
+      mgr->real_vertex_buffer[i].stride =
       mgr->b.vertex_buffer[i].stride = vb->stride;
 
       if (!vb->buffer ||
           mgr->incompatible_vb[i]) {
-         pipe_resource_reference(&mgr->b.real_vertex_buffer[i].buffer, NULL);
+         pipe_resource_reference(&mgr->real_vertex_buffer[i].buffer, NULL);
          continue;
       }
 
       if (u_vbuf_resource(vb->buffer)->user_ptr) {
-         pipe_resource_reference(&mgr->b.real_vertex_buffer[i].buffer, NULL);
+         pipe_resource_reference(&mgr->real_vertex_buffer[i].buffer, NULL);
          mgr->any_user_vbs = TRUE;
          continue;
       }
 
-      pipe_resource_reference(&mgr->b.real_vertex_buffer[i].buffer, vb->buffer);
+      pipe_resource_reference(&mgr->real_vertex_buffer[i].buffer, vb->buffer);
    }
 
    for (i = count; i < mgr->b.nr_vertex_buffers; i++) {
       pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, NULL);
    }
-   for (i = count; i < mgr->b.nr_real_vertex_buffers; i++) {
-      pipe_resource_reference(&mgr->b.real_vertex_buffer[i].buffer, NULL);
+   for (i = count; i < mgr->nr_real_vertex_buffers; i++) {
+      pipe_resource_reference(&mgr->real_vertex_buffer[i].buffer, NULL);
    }
 
    mgr->b.nr_vertex_buffers = count;
-   mgr->b.nr_real_vertex_buffers = count;
+   mgr->nr_real_vertex_buffers = count;
+
+   if (!mgr->any_user_vbs && !mgr->incompatible_vb_layout) {
+      mgr->driver_set_vertex_buffers(pipe, mgr->nr_real_vertex_buffers,
+                                     mgr->real_vertex_buffer);
+   }
 }
 
 static void u_vbuf_set_index_buffer(struct pipe_context *pipe,
@@ -835,7 +848,7 @@ u_vbuf_upload_buffers(struct u_vbuf_priv *mgr,
       start = start_offset[i];
       assert(start < end);
 
-      real_vb = &mgr->b.real_vertex_buffer[i];
+      real_vb = &mgr->real_vertex_buffer[i];
       ptr = u_vbuf_resource(mgr->b.vertex_buffer[i].buffer)->user_ptr;
 
       u_upload_data(mgr->b.uploader, start, end - start, ptr + start,
@@ -855,7 +868,7 @@ unsigned u_vbuf_draw_max_vertex_count(struct u_vbuf *mgrb)
 
    for (i = 0; i < nr; i++) {
       struct pipe_vertex_buffer *vb =
-            &mgr->b.real_vertex_buffer[velems[i].vertex_buffer_index];
+            &mgr->real_vertex_buffer[velems[i].vertex_buffer_index];
       unsigned size, max_count, value;
 
       /* We're not interested in constant and per-instance attribs. */
@@ -1059,9 +1072,8 @@ static void u_vbuf_get_minmax_index(struct pipe_context *pipe,
    }
 }
 
-enum u_vbuf_return_flags
-u_vbuf_draw_begin(struct u_vbuf *mgrb,
-                  struct pipe_draw_info *info)
+void u_vbuf_draw_begin(struct u_vbuf *mgrb,
+                       struct pipe_draw_info *info)
 {
    struct u_vbuf_priv *mgr = (struct u_vbuf_priv*)mgrb;
    int start_vertex, min_index;
@@ -1071,7 +1083,7 @@ u_vbuf_draw_begin(struct u_vbuf *mgrb,
    if (!mgr->incompatible_vb_layout &&
        !mgr->ve->incompatible_layout &&
        !mgr->any_user_vbs) {
-      return 0;
+      return;
    }
 
    if (info->indexed) {
@@ -1150,9 +1162,9 @@ u_vbuf_draw_begin(struct u_vbuf *mgrb,
       util_dump_vertex_buffer(stdout, mgr->b.vertex_buffer+i);
       printf("\n");
    }
-   for (i = 0; i < mgr->b.nr_real_vertex_buffers; i++) {
+   for (i = 0; i < mgr->nr_real_vertex_buffers; i++) {
       printf("real %i: ", i);
-      util_dump_vertex_buffer(stdout, mgr->b.real_vertex_buffer+i);
+      util_dump_vertex_buffer(stdout, mgr->real_vertex_buffer+i);
       printf("\n");
    }
    */
@@ -1165,7 +1177,8 @@ u_vbuf_draw_begin(struct u_vbuf *mgrb,
       info->start = 0;
    }
 
-   return U_VBUF_BUFFERS_UPDATED;
+   mgr->driver_set_vertex_buffers(mgr->pipe, mgr->nr_real_vertex_buffers,
+                                  mgr->real_vertex_buffer);
 }
 
 void u_vbuf_draw_end(struct u_vbuf *mgrb)
@@ -1184,5 +1197,7 @@ static void u_vbuf_install(struct u_vbuf_priv *mgr)
 
    pipe->draw = mgr;
    mgr->driver_set_index_buffer = pipe->set_index_buffer;
+   mgr->driver_set_vertex_buffers = pipe->set_vertex_buffers;
    pipe->set_index_buffer = u_vbuf_set_index_buffer;
+   pipe->set_vertex_buffers = u_vbuf_set_vertex_buffers;
 }
diff --git a/src/gallium/auxiliary/util/u_vbuf.h b/src/gallium/auxiliary/util/u_vbuf.h
index 4a449fc..06665b5 100644
--- a/src/gallium/auxiliary/util/u_vbuf.h
+++ b/src/gallium/auxiliary/util/u_vbuf.h
@@ -61,12 +61,6 @@ struct u_vbuf {
    struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
    unsigned nr_vertex_buffers;
 
-   /* Contains only real vertex buffers.
-    * Hardware drivers should use real_vertex_buffers[i]
-    * instead of vertex_buffers[i].buffer. */
-   struct pipe_vertex_buffer real_vertex_buffer[PIPE_MAX_ATTRIBS];
-   int nr_real_vertex_buffers;
-
    /* This uploader can optionally be used by the driver.
     *
     * Allowed functions:
@@ -92,10 +86,6 @@ enum u_fetch_alignment {
    U_VERTEX_FETCH_DWORD_ALIGNED
 };
 
-enum u_vbuf_return_flags {
-   U_VBUF_BUFFERS_UPDATED = 1
-};
-
 
 struct u_vbuf *
 u_vbuf_create(struct pipe_context *pipe,
@@ -119,12 +109,8 @@ void u_vbuf_bind_vertex_elements(struct u_vbuf *mgr,
 void u_vbuf_destroy_vertex_elements(struct u_vbuf *mgr,
                                     struct u_vbuf_elements *ve);
 
-void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr,
-                               unsigned count,
-                               const struct pipe_vertex_buffer *bufs);
-
-enum u_vbuf_return_flags u_vbuf_draw_begin(struct u_vbuf *mgr,
-                                           struct pipe_draw_info *info);
+void u_vbuf_draw_begin(struct u_vbuf *mgr,
+                       struct pipe_draw_info *info);
 
 unsigned u_vbuf_draw_max_vertex_count(struct u_vbuf *mgr);
 
diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c
index 920612b..103780f 100644
--- a/src/gallium/drivers/r300/r300_blit.c
+++ b/src/gallium/drivers/r300/r300_blit.c
@@ -67,8 +67,8 @@ static void r300_blitter_begin(struct r300_context* r300, enum r300_blitter_op o
         util_blitter_save_vertex_buffers(r300->blitter, r300->vbuf_mgr->nr_vertex_buffers,
                                          r300->vbuf_mgr->vertex_buffer);
     } else {
-        util_blitter_save_vertex_buffers(r300->blitter, r300->swtcl_nr_vertex_buffers,
-                                         r300->swtcl_vertex_buffer);
+        util_blitter_save_vertex_buffers(r300->blitter, r300->nr_vertex_buffers,
+                                         r300->vertex_buffer);
     }
 
     if (op & R300_SAVE_FRAMEBUFFER) {
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 2cd0d5a..769d0bf 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -80,7 +80,7 @@ static void r300_release_referenced_objects(struct r300_context *r300)
     }
 
     /* Manually-created vertex buffers. */
-    pipe_resource_reference(&r300->dummy_vb, NULL);
+    pipe_resource_reference(&r300->dummy_vb.buffer, NULL);
     pipe_resource_reference(&r300->vbo, NULL);
 
     r300->context.delete_depth_stencil_alpha_state(&r300->context,
@@ -480,7 +480,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
         vb.height0 = 1;
         vb.depth0 = 1;
 
-        r300->dummy_vb = screen->resource_create(screen, &vb);
+        r300->dummy_vb.buffer = screen->resource_create(screen, &vb);
     }
 
     {
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index de58266..086799d 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -470,7 +470,7 @@ struct r300_context {
 
     /* When no vertex buffer is set, this one is used instead to prevent
      * hardlocks. */
-    struct pipe_resource *dummy_vb;
+    struct pipe_vertex_buffer dummy_vb;
 
     /* The currently active query. */
     struct r300_query *query_current;
@@ -580,8 +580,8 @@ struct r300_context {
 
     struct u_vbuf *vbuf_mgr;
     struct pipe_index_buffer index_buffer;
-    struct pipe_vertex_buffer swtcl_vertex_buffer[PIPE_MAX_ATTRIBS];
-    unsigned swtcl_nr_vertex_buffers;
+    struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
+    unsigned nr_vertex_buffers;
 
     struct util_slab_mempool pool_transfers;
 
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 3897e99..355fa3f 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -823,7 +823,7 @@ void r300_emit_textures_state(struct r300_context *r300,
 void r300_emit_vertex_arrays(struct r300_context* r300, int offset,
                              boolean indexed, int instance_id)
 {
-    struct pipe_vertex_buffer *vbuf = r300->vbuf_mgr->real_vertex_buffer;
+    struct pipe_vertex_buffer *vbuf = r300->vertex_buffer;
     struct pipe_vertex_element *velem = r300->velems->velem;
     struct r300_resource *buf;
     int i;
@@ -1225,10 +1225,11 @@ validate:
                                 r300_resource(r300->vbo)->domain);
     /* ...vertex buffers for HWTCL path... */
     if (do_validate_vertex_buffers && r300->vertex_arrays_dirty) {
-        struct pipe_vertex_buffer *vbuf = r300->vbuf_mgr->real_vertex_buffer;
-        struct pipe_vertex_buffer *last = r300->vbuf_mgr->real_vertex_buffer +
-                                      r300->vbuf_mgr->nr_real_vertex_buffers;
+        struct pipe_vertex_buffer *vbuf = r300->vertex_buffer;
+        struct pipe_vertex_buffer *last = r300->vertex_buffer +
+                                      r300->nr_vertex_buffers;
         struct pipe_resource *buf;
+
         for (; vbuf != last; vbuf++) {
             buf = vbuf->buffer;
             if (!buf)
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index 49013c0..84162bf 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -148,7 +148,7 @@ static void r300_emit_draw_init(struct r300_context *r300, unsigned mode,
 static void r300_split_index_bias(struct r300_context *r300, int index_bias,
                                   int *buffer_offset, int *index_offset)
 {
-    struct pipe_vertex_buffer *vb, *vbufs = r300->vbuf_mgr->real_vertex_buffer;
+    struct pipe_vertex_buffer *vb, *vbufs = r300->vertex_buffer;
     struct pipe_vertex_element *velem = r300->velems->velem;
     unsigned i, size;
     int max_neg_bias;
@@ -367,7 +367,7 @@ static void r300_draw_arrays_immediate(struct r300_context *r300,
         velem = &r300->velems->velem[i];
         size[i] = r300->velems->format_size[i] / 4;
         vbi = velem->vertex_buffer_index;
-        vbuf = &r300->vbuf_mgr->real_vertex_buffer[vbi];
+        vbuf = &r300->vertex_buffer[vbi];
         stride[i] = vbuf->stride / 4;
 
         /* Map the buffer. */
@@ -401,7 +401,7 @@ static void r300_draw_arrays_immediate(struct r300_context *r300,
         vbi = r300->velems->velem[i].vertex_buffer_index;
 
         if (map[vbi]) {
-            r300->rws->buffer_unmap(r300_resource(r300->vbuf_mgr->real_vertex_buffer[vbi].buffer)->buf);
+            r300->rws->buffer_unmap(r300_resource(r300->vertex_buffer[vbi].buffer)->buf);
             map[vbi] = NULL;
         }
     }
@@ -754,11 +754,7 @@ static void r300_draw_vbo(struct pipe_context* pipe,
     }
 
     r300_update_derived_state(r300);
-
-    /* Start the vbuf manager and update buffers if needed. */
-    if (u_vbuf_draw_begin(r300->vbuf_mgr, &info) & U_VBUF_BUFFERS_UPDATED) {
-        r300->vertex_arrays_dirty = TRUE;
-    }
+    u_vbuf_draw_begin(r300->vbuf_mgr, &info);
 
     /* Draw. */
     if (info.indexed) {
@@ -831,10 +827,10 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe,
             (indexed ? PREP_INDEXED : 0),
             indexed ? 256 : 6);
 
-    for (i = 0; i < r300->swtcl_nr_vertex_buffers; i++) {
-        if (r300->swtcl_vertex_buffer[i].buffer) {
+    for (i = 0; i < r300->nr_vertex_buffers; i++) {
+        if (r300->vertex_buffer[i].buffer) {
             void *buf = pipe_buffer_map(pipe,
-                                  r300->swtcl_vertex_buffer[i].buffer,
+                                  r300->vertex_buffer[i].buffer,
                                   PIPE_TRANSFER_READ |
                                   PIPE_TRANSFER_UNSYNCHRONIZED,
                                   &vb_transfer[i]);
@@ -856,8 +852,8 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe,
     draw_flush(r300->draw);
     r300->draw_vbo_locked = FALSE;
 
-    for (i = 0; i < r300->swtcl_nr_vertex_buffers; i++) {
-        if (r300->swtcl_vertex_buffer[i].buffer) {
+    for (i = 0; i < r300->nr_vertex_buffers; i++) {
+        if (r300->vertex_buffer[i].buffer) {
             pipe_buffer_unmap(pipe, vb_transfer[i]);
             draw_set_mapped_vertex_buffer(r300->draw, i, NULL);
         }
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 5ae37c3..85869a9 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -1593,22 +1593,20 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
                                     const struct pipe_vertex_buffer* buffers)
 {
     struct r300_context* r300 = r300_context(pipe);
-    struct pipe_vertex_buffer dummy_vb = {0};
 
     /* There must be at least one vertex buffer set, otherwise it locks up. */
     if (!count) {
-        dummy_vb.buffer = r300->dummy_vb;
-        buffers = &dummy_vb;
+        buffers = &r300->dummy_vb;
         count = 1;
     }
 
+    util_copy_vertex_buffers(r300->vertex_buffer,
+                             &r300->nr_vertex_buffers,
+                             buffers, count);
+
     if (r300->screen->caps.has_tcl) {
-        u_vbuf_set_vertex_buffers(r300->vbuf_mgr, count, buffers);
         r300->vertex_arrays_dirty = TRUE;
     } else {
-        util_copy_vertex_buffers(r300->swtcl_vertex_buffer,
-                                 &r300->swtcl_nr_vertex_buffers,
-                                 buffers, count);
         draw_set_vertex_buffers(r300->draw, count, buffers);
     }
 }
diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index fc0cec9..b09a750 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -1724,8 +1724,8 @@ static void evergreen_emit_db_misc_state(struct r600_context *rctx, struct r600_
 static void evergreen_emit_vertex_buffers(struct r600_context *rctx, struct r600_atom *atom)
 {
 	struct radeon_winsys_cs *cs = rctx->cs;
-	struct pipe_vertex_buffer *vb = rctx->vbuf_mgr->real_vertex_buffer;
-	unsigned count = rctx->vbuf_mgr->nr_real_vertex_buffers;
+	struct pipe_vertex_buffer *vb = rctx->vertex_buffer;
+	unsigned count = rctx->nr_vertex_buffers;
 	unsigned i;
 	uint64_t va;
 
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index 3c7039a..93cac6d 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -347,6 +347,8 @@ struct r600_context {
 
 	bool			vertex_buffers_dirty;
 	struct pipe_index_buffer index_buffer;
+	struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
+	unsigned		nr_vertex_buffers;
 };
 
 static INLINE void r600_emit_atom(struct r600_context *rctx, struct r600_atom *atom)
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 98e1830..90b6c87 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -1702,8 +1702,8 @@ static void r600_emit_db_misc_state(struct r600_context *rctx, struct r600_atom
 static void r600_emit_vertex_buffers(struct r600_context *rctx, struct r600_atom *atom)
 {
 	struct radeon_winsys_cs *cs = rctx->cs;
-	struct pipe_vertex_buffer *vb = rctx->vbuf_mgr->real_vertex_buffer;
-	unsigned count = rctx->vbuf_mgr->nr_real_vertex_buffers;
+	struct pipe_vertex_buffer *vb = rctx->vertex_buffer;
+	unsigned count = rctx->nr_vertex_buffers;
 	unsigned i, offset;
 
 	for (i = 0; i < count; i++) {
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index 52bdedd..8011873 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -403,7 +403,7 @@ void r600_set_vertex_buffers(struct pipe_context *ctx, unsigned count,
 {
 	struct r600_context *rctx = (struct r600_context *)ctx;
 
-	u_vbuf_set_vertex_buffers(rctx->vbuf_mgr, count, buffers);
+	util_copy_vertex_buffers(rctx->vertex_buffer, &rctx->nr_vertex_buffers, buffers, count);
 	rctx->vertex_buffers_dirty = true;
 }
 
@@ -765,11 +765,11 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo)
 	r600_update_derived_state(rctx);
 
 	/* Update vertex buffers. */
-	if ((u_vbuf_draw_begin(rctx->vbuf_mgr, &info) & U_VBUF_BUFFERS_UPDATED) ||
-	    rctx->vertex_buffers_dirty) {
+	u_vbuf_draw_begin(rctx->vbuf_mgr, &info);
+	if (rctx->vertex_buffers_dirty) {
 		r600_inval_vertex_cache(rctx);
 		rctx->vertex_buffer_state.num_dw = (rctx->chip_class >= EVERGREEN ? 12 : 10) *
-						   rctx->vbuf_mgr->nr_real_vertex_buffers;
+						   rctx->nr_vertex_buffers;
 		r600_atom_dirty(rctx, &rctx->vertex_buffer_state);
 		rctx->vertex_buffers_dirty = FALSE;
 	}
-- 
1.7.5.4



More information about the mesa-dev mailing list