For a bit there, we had a bug in i965 where it ignored the tiling of the
modifier and used the one from the BO instead.  At one point, we though
this was best fixed by setting a tiling from Vulkan.  However, we've
decided that i965 was just doing the wrong thing and have fixed it as of
50485723523d2948a44570ba110f02f726f86a54.

The old assumptions also affected the solution we used for legacy
scanout in Vulkan.  Instead of treating it specially, we just treated it
like a modifier like we do in GL.  This commit goes back to making it
it's own thing so that it's clear in the driver when we're using
modifiers and when we're using legacy paths.
---
 src/intel/vulkan/anv_device.c  | 19 ++++---------------
 src/intel/vulkan/anv_image.c   | 27 ++++++++-------------------
 src/intel/vulkan/anv_private.h |  6 ++----
 3 files changed, 14 insertions(+), 38 deletions(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 86c1bdc..30f4159 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -1835,21 +1835,10 @@ VkResult anv_AllocateMemory(
       if (dedicated_info && dedicated_info->image != VK_NULL_HANDLE) {
          ANV_FROM_HANDLE(anv_image, image, dedicated_info->image);
 
-         /* For images using modifiers, we require a dedicated allocation
-          * and we set the BO tiling to match the tiling of the underlying
-          * modifier.  This is a bit unfortunate as this is completely
-          * pointless for Vulkan.  However, GL needs to be able to map things
-          * so it needs the tiling to be set.  The only way to do this in a
-          * non-racy way is to set the tiling in the creator of the BO so that
-          * makes it our job.
-          *
-          * One of these days, once the GL driver learns to not map things
-          * through the GTT in random places, we can drop this and start
-          * allowing multiple modified images in the same BO.
+         /* For legacy scanout images, no tiling information is passed along
+          * directly.  Instead, consumers pull the tiling from BO.
           */
-         if (image->drm_format_mod != DRM_FORMAT_MOD_INVALID) {
-            assert(isl_drm_modifier_get_info(image->drm_format_mod)->tiling ==
-                   image->planes[0].surface.isl.tiling);
+         if (image->legacy_scanout) {
             const uint32_t i915_tiling =
                isl_tiling_to_i915_tiling(image->planes[0].surface.isl.tiling);
             int ret = anv_gem_set_tiling(device, mem->bo->gem_handle,
@@ -2217,7 +2206,7 @@ void anv_GetImageMemoryRequirements2KHR(
       switch (ext->sType) {
       case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR: {
          VkMemoryDedicatedRequirementsKHR *requirements = (void *)ext;
-         if (image->drm_format_mod != DRM_FORMAT_MOD_INVALID) {
+         if (image->legacy_scanout) {
             /* Require a dedicated allocation for images with modifiers.
              *
              * See also anv_AllocateMemory.
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index a297cc4..355aff0 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -93,7 +93,8 @@ choose_isl_surf_usage(VkImageCreateFlags vk_create_flags,
 
 static isl_tiling_flags_t
 choose_isl_tiling_flags(const struct anv_image_create_info *anv_info,
-                        const struct isl_drm_modifier_info *isl_mod_info)
+                        const struct isl_drm_modifier_info *isl_mod_info,
+                        bool legacy_scanout)
 {
    const VkImageCreateInfo *base_info = anv_info->vk_info;
    isl_tiling_flags_t flags = 0;
@@ -112,6 +113,9 @@ choose_isl_tiling_flags(const struct anv_image_create_info 
*anv_info,
    if (anv_info->isl_tiling_flags)
       flags &= anv_info->isl_tiling_flags;
 
+   if (legacy_scanout)
+      flags &= ISL_TILING_LINEAR_BIT | ISL_TILING_X_BIT;
+
    if (isl_mod_info)
       flags &= 1 << isl_mod_info->tiling;
 
@@ -504,19 +508,6 @@ make_surface(const struct anv_device *dev,
    return VK_SUCCESS;
 }
 
-static const struct isl_drm_modifier_info *
-get_legacy_scanout_drm_format_mod(VkImageTiling tiling)
-{
-   switch (tiling) {
-   case VK_IMAGE_TILING_OPTIMAL:
-      return isl_drm_modifier_get_info(I915_FORMAT_MOD_X_TILED);
-   case VK_IMAGE_TILING_LINEAR:
-      return isl_drm_modifier_get_info(DRM_FORMAT_MOD_LINEAR);
-   default:
-      unreachable("bad VkImageTiling");
-   }
-}
-
 VkResult
 anv_image_create(VkDevice _device,
                  const struct anv_image_create_info *create_info,
@@ -533,8 +524,6 @@ anv_image_create(VkDevice _device,
 
    const struct wsi_image_create_info *wsi_info =
       vk_find_struct_const(pCreateInfo->pNext, WSI_IMAGE_CREATE_INFO_MESA);
-   if (wsi_info && wsi_info->scanout)
-      isl_mod_info = get_legacy_scanout_drm_format_mod(pCreateInfo->tiling);
 
    anv_assert(pCreateInfo->mipLevels > 0);
    anv_assert(pCreateInfo->arrayLayers > 0);
@@ -559,14 +548,14 @@ anv_image_create(VkDevice _device,
    image->usage = pCreateInfo->usage;
    image->tiling = pCreateInfo->tiling;
    image->disjoint = pCreateInfo->flags & VK_IMAGE_CREATE_DISJOINT_BIT_KHR;
-   image->drm_format_mod = isl_mod_info ? isl_mod_info->modifier :
-                                          DRM_FORMAT_MOD_INVALID;
+   image->legacy_scanout = wsi_info && wsi_info->scanout;
 
    const struct anv_format *format = anv_get_format(image->vk_format);
    assert(format != NULL);
 
    const isl_tiling_flags_t isl_tiling_flags =
-      choose_isl_tiling_flags(create_info, isl_mod_info);
+      choose_isl_tiling_flags(create_info, isl_mod_info,
+                              image->legacy_scanout);
 
    image->n_planes = format->n_planes;
 
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index d38dd9e..3b12ead 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -2392,10 +2392,8 @@ struct anv_image {
    VkImageUsageFlags usage; /**< Superset of VkImageCreateInfo::usage. */
    VkImageTiling tiling; /** VkImageCreateInfo::tiling */
 
-   /**
-    * DRM format modifier for this image or DRM_FORMAT_MOD_INVALID.
-    */
-   uint64_t drm_format_mod;
+   /** True if this is a legacy scanout image */
+   bool legacy_scanout;
 
    VkDeviceSize size;
    uint32_t alignment;
-- 
2.5.0.400.gff86faf

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to