[Mesa-dev] [PATCH 3/7] i965: Track when a bo is shared with an external client

Kenneth Graunke kenneth at whitecape.org
Wed Jul 5 20:56:50 UTC 2017


From: Chris Wilson <chris at chris-wilson.co.uk>

If the buffer is being shared with an external client, our own state
tracking may be stale and in some cases we may wish to double check with
the kernel/hw state. At the moment, this is synonymous with not being
reusable, but the semantics between reusable and external are quite
different and we will have more examples of non-reusable buffers in the
near future.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_bufmgr.c | 4 ++++
 src/mesa/drivers/dri/i965/brw_bufmgr.h | 5 +++++
 2 files changed, 9 insertions(+)

Technically this isn't used by anything in this series, but I still
think it's nice to have.  It seems like a question we want to answer
from time to time, and checking bo->external is better than trying
to overload other fields.

diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c
index da12a131526..201bf9dc77f 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -483,6 +483,7 @@ brw_bo_gem_create_from_name(struct brw_bufmgr *bufmgr,
    bo->name = name;
    bo->global_name = handle;
    bo->reusable = false;
+   bo->external = true;
 
    _mesa_hash_table_insert(bufmgr->handle_table, &bo->gem_handle, bo);
    _mesa_hash_table_insert(bufmgr->name_table, &bo->global_name, bo);
@@ -995,6 +996,7 @@ brw_bo_gem_create_from_prime(struct brw_bufmgr *bufmgr, int prime_fd)
 
    bo->name = "prime";
    bo->reusable = false;
+   bo->external = true;
 
    memclear(get_tiling);
    get_tiling.handle = bo->gem_handle;
@@ -1025,6 +1027,7 @@ brw_bo_gem_export_to_prime(struct brw_bo *bo, int *prime_fd)
       return -errno;
 
    bo->reusable = false;
+   bo->external = true;
 
    return 0;
 }
@@ -1046,6 +1049,7 @@ brw_bo_flink(struct brw_bo *bo, uint32_t *name)
       if (!bo->global_name) {
          bo->global_name = flink.name;
          bo->reusable = false;
+         bo->external = true;
 
          _mesa_hash_table_insert(bufmgr->name_table, &bo->global_name, bo);
       }
diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.h b/src/mesa/drivers/dri/i965/brw_bufmgr.h
index 4d671b6aaeb..6a839c4cd39 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.h
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.h
@@ -124,6 +124,11 @@ struct brw_bo {
    bool reusable;
 
    /**
+    * Boolean of whether this buffer has been shared with an external client.
+    */
+   bool external;
+
+   /**
     * Boolean of whether this buffer is cache coherent
     */
    bool cache_coherent;
-- 
2.13.2



More information about the mesa-dev mailing list