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

Author: Kenneth Graunke <[email protected]>
Date:   Fri Sep  1 17:32:01 2017 -0700

i965: Don't special case the batchbuffer when reference counting.

We don't need to special case the batch - when we add the batch to the
validation list, we can simply increase the refcount to 2, and when we
make a new batch, we'll drop it back down to 1 (when unreferencing all
buffers in the validation list).  The final reference is still held by
brw->batch.bo, as it was before.

This removes the special case from a bunch of loops.

Reviewed-by: Chris Wilson <[email protected]>

---

 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c 
b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index 73cf252827..08d35ace13 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -115,8 +115,7 @@ add_exec_bo(struct intel_batchbuffer *batch, struct brw_bo 
*bo)
          return index;
    }
 
-   if (bo != batch->bo)
-      brw_bo_reference(bo);
+   brw_bo_reference(bo);
 
    if (batch->exec_count == batch->exec_array_size) {
       batch->exec_array_size *= 2;
@@ -199,9 +198,7 @@ intel_batchbuffer_reset_to_saved(struct brw_context *brw)
 {
    for (int i = brw->batch.saved.exec_count;
         i < brw->batch.exec_count; i++) {
-      if (brw->batch.exec_bos[i] != brw->batch.bo) {
-         brw_bo_unreference(brw->batch.exec_bos[i]);
-      }
+      brw_bo_unreference(brw->batch.exec_bos[i]);
    }
    brw->batch.reloc_count = brw->batch.saved.reloc_count;
    brw->batch.exec_count = brw->batch.saved.exec_count;
@@ -217,9 +214,7 @@ intel_batchbuffer_free(struct intel_batchbuffer *batch)
    free(batch->cpu_map);
 
    for (int i = 0; i < batch->exec_count; i++) {
-      if (batch->exec_bos[i] != batch->bo) {
-         brw_bo_unreference(batch->exec_bos[i]);
-      }
+      brw_bo_unreference(batch->exec_bos[i]);
    }
    free(batch->relocs);
    free(batch->exec_bos);
@@ -449,9 +444,7 @@ brw_new_batch(struct brw_context *brw)
 {
    /* Unreference any BOs held by the previous batch, and reset counts. */
    for (int i = 0; i < brw->batch.exec_count; i++) {
-      if (brw->batch.exec_bos[i] != brw->batch.bo) {
-         brw_bo_unreference(brw->batch.exec_bos[i]);
-      }
+      brw_bo_unreference(brw->batch.exec_bos[i]);
       brw->batch.exec_bos[i] = NULL;
    }
    brw->batch.reloc_count = 0;

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to