[Mesa-dev] [PATCH 03/10] i965: Split merge_inputs and clear_buffers.

Mathias.Froehlich at gmx.net Mathias.Froehlich at gmx.net
Wed Dec 12 06:44:37 UTC 2018


From: Mathias Fröhlich <mathias.froehlich at web.de>

The merge_inputs function handles that part that changes when the
inputs change. The clear_buffers function triggers when we may need
a new upload. Thus the merge_inputs can be limited to be once
per brw_draw_prims.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
---
 src/mesa/drivers/dri/i965/brw_draw.c | 30 ++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index b818a0d77a..9826bc8761 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -278,21 +278,34 @@ brw_emit_prim(struct brw_context *brw,
 
 
 static void
-brw_merge_inputs(struct brw_context *brw)
+brw_clear_buffers(struct brw_context *brw)
 {
-   const struct gen_device_info *devinfo = &brw->screen->devinfo;
-   const struct gl_context *ctx = &brw->ctx;
-   GLuint i;
-
-   for (i = 0; i < brw->vb.nr_buffers; i++) {
+   for (unsigned i = 0; i < brw->vb.nr_buffers; ++i) {
       brw_bo_unreference(brw->vb.buffers[i].bo);
       brw->vb.buffers[i].bo = NULL;
    }
    brw->vb.nr_buffers = 0;
 
+   for (unsigned i = 0; i < brw->vb.nr_enabled; ++i) {
+      brw->vb.enabled[i]->buffer = -1;
+   }
+#ifndef NDEBUG
+   for (unsigned i = 0; i < VERT_ATTRIB_MAX; i++) {
+      assert(brw->vb.inputs[i].buffer == -1);
+   }
+#endif
+}
+
+
+static void
+brw_merge_inputs(struct brw_context *brw)
+{
+   const struct gen_device_info *devinfo = &brw->screen->devinfo;
+   const struct gl_context *ctx = &brw->ctx;
+   GLuint i;
+
    for (i = 0; i < VERT_ATTRIB_MAX; i++) {
       struct brw_vertex_element *input = &brw->vb.inputs[i];
-      input->buffer = -1;
       _mesa_draw_attrib_and_binding(ctx, i,
                                     &input->glattrib, &input->glbinding);
    }
@@ -843,6 +856,7 @@ brw_prepare_drawing(struct gl_context *ctx,
 
    /* Bind all inputs, derive varying and size information:
     */
+   brw_clear_buffers(brw);
    brw_merge_inputs(brw);
 
    brw->ib.ib = ib;
@@ -908,7 +922,7 @@ brw_draw_single_prim(struct gl_context *ctx,
       brw->baseinstance = prim->base_instance;
       if (prim_id > 0) { /* For i == 0 we just did this before the loop */
          brw->ctx.NewDriverState |= BRW_NEW_VERTICES;
-         brw_merge_inputs(brw);
+         brw_clear_buffers(brw);
       }
    }
 
-- 
2.19.2



More information about the mesa-dev mailing list