[Mesa-dev] [PATCH 09/14] intel/isl: Add ISL tiling -> modifier conversion

Daniel Stone daniels at collabora.com
Fri Jul 21 13:42:12 UTC 2017


Given a tiling mode and an aux usage, return the DRM modifier.

Signed-off-by: Daniel Stone <daniels at collabora.com>
---
 src/intel/isl/isl.h     |  6 +++++-
 src/intel/isl/isl_drm.c | 17 +++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index 92d2ffc31a..eafbdd4c40 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -1516,12 +1516,16 @@ isl_tiling_is_std_y(enum isl_tiling tiling)
 uint32_t
 isl_tiling_to_i915_tiling(enum isl_tiling tiling);
 
-enum isl_tiling 
+enum isl_tiling
 isl_tiling_from_i915_tiling(uint32_t tiling);
 
 const struct isl_drm_modifier_info * ATTRIBUTE_CONST
 isl_drm_modifier_get_info(uint64_t modifier);
 
+uint64_t ATTRIBUTE_CONST
+isl_drm_modifier_from_tiling(enum isl_tiling tiling,
+                             enum isl_aux_usage aux_usage);
+
 struct isl_extent2d ATTRIBUTE_CONST
 isl_get_interleaved_msaa_px_size_sa(uint32_t samples);
 
diff --git a/src/intel/isl/isl_drm.c b/src/intel/isl/isl_drm.c
index ef80e42fdf..3c56131363 100644
--- a/src/intel/isl/isl_drm.c
+++ b/src/intel/isl/isl_drm.c
@@ -30,6 +30,10 @@
 #include "isl.h"
 #include "common/gen_device_info.h"
 
+#ifndef DRM_FORMAT_MOD_INVALID
+#define DRM_FORMAT_MOD_INVALID ((1ULL << 56) - 1)
+#endif
+
 uint32_t
 isl_tiling_to_i915_tiling(enum isl_tiling tiling)
 {
@@ -99,3 +103,16 @@ isl_drm_modifier_get_info(uint64_t modifier)
 
    return NULL;
 }
+
+uint64_t
+isl_drm_modifier_from_tiling(enum isl_tiling tiling,
+                             enum isl_aux_usage aux_usage)
+{
+   for (unsigned i = 0; i < ARRAY_SIZE(modifier_info); i++) {
+      if (modifier_info[i].tiling == tiling &&
+          modifier_info[i].aux_usage == aux_usage)
+         return modifier_info[i].modifier;
+   }
+
+   return DRM_FORMAT_MOD_INVALID;
+}
-- 
2.13.2



More information about the mesa-dev mailing list