From: Kenneth Graunke Date: Sun, 7 Jan 2018 04:34:35 +0000 (-0800) Subject: i965: Make a helper for recreating growing buffers. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=81ca8e69e327f07f57d597fa6ce23ff67b932de8;p=mesa.git 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 --- diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c index bfb50053e73..877f68ee7cf 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.