[Mesa-dev] [RFC v2 03/22] intel/isl: Add ISL <-> GEM tiling conversion
Louis-Francis Ratté-Boulianne
lfrb at collabora.com
Thu Aug 31 04:23:59 UTC 2017
From: Daniel Stone <daniels at collabora.com>
Add a simple conversion from ISL tiling to GEM BO tiling flags, and use
that instead of hardcoding I915_TILING_X in the ANV WSI.
Signed-off-by: Daniel Stone <daniels at collabora.com>
---
src/intel/isl/isl.c | 28 ++++++++++++++++++++++++++++
src/intel/isl/isl.h | 8 ++++++++
src/intel/vulkan/anv_wsi.c | 6 +++---
3 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
index fd8fcf5e93..8ebe8538fa 100644
--- a/src/intel/isl/isl.c
+++ b/src/intel/isl/isl.c
@@ -27,6 +27,7 @@
#include "genxml/genX_bits.h"
#include <drm_fourcc.h>
+#include <i915_drm.h>
#include "isl.h"
#include "isl_gen4.h"
@@ -107,6 +108,33 @@ isl_tiling_to_drm_format_mod(enum isl_tiling tiling,
unreachable("unknown tiling in isl_tiling_to_drm_format_mod");
}
+bool
+isl_tiling_to_gem_tiling(enum isl_tiling isl, enum isl_aux_usage aux_usage,
+ uint32_t *gem)
+{
+ switch (isl) {
+ case ISL_TILING_LINEAR:
+ *gem = I915_TILING_NONE;
+ return true;
+ case ISL_TILING_X:
+ *gem = I915_TILING_X;
+ return true;
+ case ISL_TILING_Y0:
+ if (aux_usage != ISL_AUX_USAGE_NONE && aux_usage != ISL_AUX_USAGE_CCS_E)
+ return false;
+ *gem = I915_TILING_Y;
+ return true;
+ case ISL_TILING_Yf:
+ case ISL_TILING_Ys:
+ case ISL_TILING_W:
+ case ISL_TILING_HIZ:
+ case ISL_TILING_CCS:
+ return false;
+ }
+
+ unreachable("unknown tiling in isl_tiling_to_gem_tiling");
+}
+
void
isl_device_init(struct isl_device *dev,
const struct gen_device_info *info,
diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index 09b3850ca4..d216b05168 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -1547,6 +1547,14 @@ bool isl_tiling_from_drm_format_mod(uint64_t mod,
uint64_t isl_tiling_to_drm_format_mod(enum isl_tiling tiling,
enum isl_aux_usage aux_usage);
+/**
+ * Map an ISL tiling/aux pair to a GEM tiling enum. If the ISL tiling/aux mode
+ * is not exportable, return false. The output parameters are only written on
+ * success.
+ */
+bool isl_tiling_to_gem_tiling(enum isl_tiling isl, enum isl_aux_usage aux_usage,
+ uint32_t *gem_tiling);
+
static inline bool
isl_tiling_is_any_y(enum isl_tiling tiling)
{
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index 00edb220b2..b86e4f1b4a 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -241,11 +241,11 @@ anv_wsi_image_create(VkDevice device_h,
anv_BindImageMemory(device_h, image_h, memory_h, 0);
struct anv_surface *surface = &image->color_surface;
- assert(surface->isl.tiling == ISL_TILING_X);
-
+ uint32_t gem_tiling = I915_TILING_NONE;
+ isl_tiling_to_gem_tiling(surface->isl.tiling, image->aux_usage, &gem_tiling);
*row_pitch = surface->isl.row_pitch;
int ret = anv_gem_set_tiling(device, memory->bo->gem_handle,
- surface->isl.row_pitch, I915_TILING_X);
+ surface->isl.row_pitch, gem_tiling);
if (ret) {
/* FINISHME: Choose a better error. */
result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
--
2.13.0
More information about the mesa-dev
mailing list