[Mesa-dev] [PATCH 11/13] i965: Reuse intel_batchbuffer_reset_to_saved() for intel_batchbuffer_free()

Chris Wilson chris at chris-wilson.co.uk
Wed Jul 19 10:09:19 UTC 2017


Rather than have a seperate implementation that discards all of the
execobjects for the rare event of destroying the context, recast it as
an operation to reset to the saved state of no batch.
---
 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index 59b142cc75..933812810a 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -208,17 +208,18 @@ intel_batchbuffer_reset_to_saved(struct brw_context *brw)
 void
 intel_batchbuffer_free(struct intel_batchbuffer *batch)
 {
-   free(batch->cpu_map);
+   struct brw_context *brw = container_of(batch, brw, batch);
+
+   /* Clear out any references from a residual batch */
+   memset(&batch->saved, 0, sizeof(batch->saved));
+   intel_batchbuffer_reset_to_saved(brw);
 
-   for (int i = 0; i < batch->exec_count; i++) {
-      if (batch->exec_bos[i] != batch->bo) {
-         brw_bo_unreference(batch->exec_bos[i]);
-      }
-   }
    free(batch->relocs);
    free(batch->exec_bos);
    free(batch->exec_objects);
 
+   free(batch->cpu_map);
+
    brw_bo_unreference(batch->last_bo);
    brw_bo_unreference(batch->bo);
    if (batch->state_batch_sizes)
-- 
2.13.3



More information about the mesa-dev mailing list