[Mesa-dev] [RFC v2 05/23] isl: Add isl_surf_get_drm_format_mod()

Louis-Francis Ratté-Boulianne lfrb at collabora.com
Fri Jul 14 04:59:03 UTC 2017


From: Chad Versace <chadversary at chromium.org>

---
 src/intel/isl/isl.c | 35 +++++++++++++++++++++++++++++++++++
 src/intel/isl/isl.h | 15 +++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
index 19aa2bac33..a8a074719f 100644
--- a/src/intel/isl/isl.c
+++ b/src/intel/isl/isl.c
@@ -2399,3 +2399,38 @@ isl_surf_get_depth_format(const struct isl_device *dev,
       return 5; /* D16_UNORM */
    }
 }
+
+bool
+isl_surf_get_drm_format_mod(const struct isl_surf *main_surf,
+                            enum isl_aux_usage aux,
+                            uint64_t *mod)
+{
+   if (aux != ISL_AUX_USAGE_NONE) {
+      /* There are no modifiers defined yet for auxiliary surfaces, not even
+       * for CCS.
+       */
+      return false;
+   }
+
+   switch (main_surf->tiling) {
+   case ISL_TILING_LINEAR:
+      *mod = DRM_FORMAT_MOD_LINEAR;
+      break;
+   case ISL_TILING_X:
+      *mod = I915_FORMAT_MOD_X_TILED;
+      break;
+   case ISL_TILING_Y0:
+      *mod = I915_FORMAT_MOD_Y_TILED;
+      break;
+   case ISL_TILING_Yf:
+      *mod = I915_FORMAT_MOD_Yf_TILED;
+      break;
+   case ISL_TILING_Ys:
+   case ISL_TILING_W:
+   case ISL_TILING_HIZ:
+   case ISL_TILING_CCS:
+      return false;
+   }
+
+   return true;
+}
diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index 69140c44a8..9c672507db 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -1862,6 +1862,21 @@ uint32_t
 isl_surf_get_depth_format(const struct isl_device *dev,
                           const struct isl_surf *surf);
 
+/**
+ * The given surface must be a primary surface, not an auxiliary surface;
+ * otherwise behavior is undefined.
+ *
+ * The auxiliary usage must be compatible with the given surface; otherwise
+ * behavior is undefined.
+ *
+ * If no known DRM format modifier applies to the input, then return false.
+ * The output parameter is written only on success.
+ */
+bool ATTRIBUTE_PURE
+isl_surf_get_drm_format_mod(const struct isl_surf *main_surf,
+                            enum isl_aux_usage aux,
+                            uint64_t *mod);
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.13.0



More information about the mesa-dev mailing list