Mesa (master): i965: Make a helper for recreating growing buffers.

Kenneth Graunke kwg at kemper.freedesktop.org
Wed Jan 17 22:45:21 UTC 2018


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Sat Jan  6 20:34:35 2018 -0800

i965: Make a helper for recreating growing buffers.

Now that we have two of these, we're duplicating a bunch of this logic.
The next commit will add more logic, which would make the duplication
seem worse.

This ends up setting EXEC_OBJECT_CAPTURE on the batch, which isn't
necessary (it's already captured), but it should be harmless.

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>

---

 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 30 +++++++++++++++------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index bfb50053e7..877f68ee7c 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -161,32 +161,36 @@ add_exec_bo(struct intel_batchbuffer *batch, struct brw_bo *bo)
 }
 
 static void
-intel_batchbuffer_reset(struct brw_context *brw)
+recreate_growing_buffer(struct brw_context *brw,
+                        struct brw_growing_bo *grow,
+                        const char *name, unsigned size)
 {
    struct intel_screen *screen = brw->screen;
    struct intel_batchbuffer *batch = &brw->batch;
    struct brw_bufmgr *bufmgr = screen->bufmgr;
 
+   grow->bo = brw_bo_alloc(bufmgr, name, size, 4096);
+   grow->bo->kflags = can_do_exec_capture(screen) ? EXEC_OBJECT_CAPTURE : 0;
+
+   if (!batch->use_shadow_copy)
+      grow->map = brw_bo_map(brw, grow->bo, MAP_READ | MAP_WRITE);
+}
+
+static void
+intel_batchbuffer_reset(struct brw_context *brw)
+{
+   struct intel_batchbuffer *batch = &brw->batch;
+
    if (batch->last_bo != NULL) {
       brw_bo_unreference(batch->last_bo);
       batch->last_bo = NULL;
    }
    batch->last_bo = batch->batch.bo;
 
-   batch->batch.bo = brw_bo_alloc(bufmgr, "batchbuffer", BATCH_SZ, 4096);
-   if (!batch->use_shadow_copy) {
-      batch->batch.map =
-         brw_bo_map(brw, batch->batch.bo, MAP_READ | MAP_WRITE);
-   }
+   recreate_growing_buffer(brw, &batch->batch, "batchbuffer", BATCH_SZ);
    batch->map_next = batch->batch.map;
 
-   batch->state.bo = brw_bo_alloc(bufmgr, "statebuffer", STATE_SZ, 4096);
-   batch->state.bo->kflags =
-      can_do_exec_capture(screen) ? EXEC_OBJECT_CAPTURE : 0;
-   if (!batch->use_shadow_copy) {
-      batch->state.map =
-         brw_bo_map(brw, batch->state.bo, MAP_READ | MAP_WRITE);
-   }
+   recreate_growing_buffer(brw, &batch->state, "statebuffer", STATE_SZ);
 
    /* Avoid making 0 a valid state offset - otherwise the decoder will try
     * and decode data when we use offset 0 as a null pointer.




More information about the mesa-commit mailing list