[Mesa-dev] [PATCH 14/70] i965: Add a simple utility function to wrap drm_intel_bo_flink()

Chris Wilson chris at chris-wilson.co.uk
Fri Aug 7 13:13:18 PDT 2015


Just to reduce some later churn, pull out the flink wrapper.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 src/mesa/drivers/dri/i965/brw_batch.h    |  7 +++++++
 src/mesa/drivers/dri/i965/brw_context.c  | 11 +++++------
 src/mesa/drivers/dri/i965/intel_screen.c |  6 ++----
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_batch.h b/src/mesa/drivers/dri/i965/brw_batch.h
index 5745aa4..31f39b4 100644
--- a/src/mesa/drivers/dri/i965/brw_batch.h
+++ b/src/mesa/drivers/dri/i965/brw_batch.h
@@ -78,6 +78,13 @@ inline static void brw_bo_put(brw_bo *bo)
       drm_intel_bo_unreference(bo);
 }
 
+inline static uint32_t brw_bo_flink(brw_bo *bo)
+{
+   uint32_t name = 0;
+   drm_intel_bo_flink(bo, &name);
+   return name;
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 583ce7f..f8add33 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -1361,12 +1361,11 @@ intel_process_dri2_buffer(struct brw_context *brw,
 
    uint32_t old_name = 0;
    if (last_mt) {
-       /* The bo already has a name because the miptree was created by a
-	* previous call to intel_process_dri2_buffer(). If a bo already has a
-	* name, then drm_intel_bo_flink() is a low-cost getter.  It does not
-	* create a new name.
-	*/
-      drm_intel_bo_flink(last_mt->bo, &old_name);
+      /* The bo already has a name because the miptree was created by a
+       * previous call to intel_process_dri2_buffer(). If a bo already has a
+       * name, then flink is a low-cost getter. It does not create a new name.
+       */
+      old_name = brw_bo_flink(last_mt->bo);
    }
 
    if (old_name == buffer->name)
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index b8e96be..c84f495 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -559,7 +559,7 @@ intel_query_image(__DRIimage *image, int attrib, int *value)
       *value = image->bo->handle;
       return true;
    case __DRI_IMAGE_ATTRIB_NAME:
-      return !drm_intel_bo_flink(image->bo, (uint32_t *) value);
+      return drm_intel_bo_flink(image->bo, (uint32_t *) value) == 0;
    case __DRI_IMAGE_ATTRIB_FORMAT:
       *value = image->dri_format;
       return true;
@@ -575,9 +575,7 @@ intel_query_image(__DRIimage *image, int attrib, int *value)
       *value = image->planar_format->components;
       return true;
    case __DRI_IMAGE_ATTRIB_FD:
-      if (drm_intel_bo_gem_export_to_prime(image->bo, value) == 0)
-         return true;
-      return false;
+      return drm_intel_bo_gem_export_to_prime(image->bo, value) == 0;
    case __DRI_IMAGE_ATTRIB_FOURCC:
       if (intel_lookup_fourcc(image->dri_format, value))
          return true;
-- 
2.5.0



More information about the mesa-dev mailing list