[Mesa-dev] [PATCH] i965: Avoids loop for buffer object availability in add_exec_bo
aravindan.muthukumar at intel.com
aravindan.muthukumar at intel.com
Fri Jul 28 08:37:01 UTC 2017
From: Aravindan Muthukumar <aravindan.muthukumar at intel.com>
Original logic loops over the list for every buffer object. Maintained
a flag to identify whether bo is already there in list.
Improves performance - 3DMark by 2%
Tested with piglit
Signed-off-by: Aravindan Muthukumar <aravindan.muthukumar at intel.com>
Signed-off-by: Yogesh Marathe <yogesh.marathe at intel.com>
---
src/mesa/drivers/dri/i965/brw_bufmgr.h | 5 +++++
src/mesa/drivers/dri/i965/intel_batchbuffer.c | 24 +++++++++++++++---------
2 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.h b/src/mesa/drivers/dri/i965/brw_bufmgr.h
index 6a6051b..912ffb0 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.h
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.h
@@ -132,6 +132,11 @@ struct brw_bo {
* Boolean of whether this buffer is cache coherent
*/
bool cache_coherent;
+
+ /**
+ * Boolean to check whether bo is available in exec buffer objects list
+ */
+ bool bo_available;
};
#define BO_ALLOC_FOR_RENDER (1<<0)
diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index e2f208a..0814e8b 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -513,10 +513,8 @@ static void
add_exec_bo(struct intel_batchbuffer *batch, struct brw_bo *bo)
{
if (bo != batch->bo) {
- for (int i = 0; i < batch->exec_count; i++) {
- if (batch->exec_bos[i] == bo)
- return;
- }
+ if(brw_batch_references(batch,bo) == true)
+ return;
brw_bo_reference(bo);
}
@@ -548,6 +546,12 @@ add_exec_bo(struct intel_batchbuffer *batch, struct brw_bo *bo)
validation_entry->rsvd2 = 0;
batch->exec_bos[batch->exec_count] = bo;
+
+ /* Marking the current bo as true since this
+ * is added to the exec_bos list
+ */
+ bo->bo_available = true;
+
batch->exec_count++;
batch->aperture_space += bo->size;
}
@@ -592,6 +596,12 @@ execbuffer(int fd,
bo->idle = false;
+ /* Marking the flags as false for all the bo's
+ * in the list to ensure it is added in the next
+ * list of exec buffers
+ */
+ bo->bo_available = false;
+
/* Update brw_bo::offset64 */
if (batch->validation_list[i].offset != bo->offset64) {
DBG("BO %d migrated: 0x%" PRIx64 " -> 0x%llx\n",
@@ -736,11 +746,7 @@ brw_batch_has_aperture_space(struct brw_context *brw, unsigned extra_space)
bool
brw_batch_references(struct intel_batchbuffer *batch, struct brw_bo *bo)
{
- for (int i = 0; i < batch->exec_count; i++) {
- if (batch->exec_bos[i] == bo)
- return true;
- }
- return false;
+ return (bo->bo_available) ? true : false;
}
/* This is the only way buffers get added to the validate list.
--
2.7.4
More information about the mesa-dev
mailing list