[Mesa-dev] [PATCH 02/10] i965: Reuse intel_batchbuffer_reset_to_saved() for intel_batchbuffer_free()

Chris Wilson chris at chris-wilson.co.uk
Fri Jul 21 15:36:44 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 65c412ff30..140678f88c 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -153,17 +153,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->validation_list);
 
+   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