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

Louis-Francis Ratté-Boulianne lfrb at collabora.com
Thu Aug 31 04:24: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 8ebe8538fa..5e911e4f4d 100644
--- a/src/intel/isl/isl.c
+++ b/src/intel/isl/isl.c
@@ -2378,3 +2378,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 d216b05168..c0e0ac8572 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -1957,6 +1957,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