iris: Make an iris_bo_is_external() helper and use it in a few places
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 20 May 2021 17:53:39 +0000 (10:53 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 2 Jun 2021 21:18:00 +0000 (21:18 +0000)
I'd like to start tracking "imported" vs. "exported" for objects,
rather than a blanket "external" flag.  Instead of directly checking
bo->external, use a new helper that will eventually be "imported or
exported".

Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10941>

src/gallium/drivers/iris/iris_bufmgr.c
src/gallium/drivers/iris/iris_bufmgr.h
src/gallium/drivers/iris/iris_resource.h

index 1c731a4..c1e0a3d 100644 (file)
@@ -211,7 +211,7 @@ find_and_ref_external_bo(struct hash_table *ht, unsigned int key)
    struct iris_bo *bo = entry ? entry->data : NULL;
 
    if (bo) {
-      assert(bo->external);
+      assert(iris_bo_is_external(bo));
       assert(!bo->reusable);
 
       /* Being non-reusable, the BO cannot be in the cache lists, but it
@@ -762,7 +762,7 @@ bo_close(struct iris_bo *bo)
 {
    struct iris_bufmgr *bufmgr = bo->bufmgr;
 
-   if (bo->external) {
+   if (iris_bo_is_external(bo)) {
       struct hash_entry *entry;
 
       if (bo->global_name) {
@@ -1297,7 +1297,7 @@ iris_bo_wait(struct iris_bo *bo, int64_t timeout_ns)
    struct iris_bufmgr *bufmgr = bo->bufmgr;
 
    /* If we know it's idle, don't bother with the kernel round trip */
-   if (bo->idle && !bo->external)
+   if (bo->idle && !iris_bo_is_external(bo))
       return 0;
 
    struct drm_i915_gem_wait wait = {
index 0b098b7..057ba88 100644 (file)
@@ -343,6 +343,15 @@ void iris_bufmgr_unref(struct iris_bufmgr *bufmgr);
 int iris_bo_flink(struct iris_bo *bo, uint32_t *name);
 
 /**
+ * Is this buffer shared with external clients (imported or exported)?
+ */
+static inline bool
+iris_bo_is_external(const struct iris_bo *bo)
+{
+   return bo->external;
+}
+
+/**
  * Make a BO externally accessible.
  *
  * \param bo Buffer to make external
index c8ec0b9..967ec03 100644 (file)
@@ -307,7 +307,7 @@ iris_mocs(const struct iris_bo *bo,
           const struct isl_device *dev,
           isl_surf_usage_flags_t usage)
 {
-   return isl_mocs(dev, usage, bo && bo->external);
+   return isl_mocs(dev, usage, bo && iris_bo_is_external(bo));
 }
 
 struct iris_format_info iris_format_for_usage(const struct intel_device_info *,