Mesa (main): anv,vulkan: Add a vk_image::wsi_legacy_scanout bit

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Aug 17 21:47:45 UTC 2021


Module: Mesa
Branch: main
Commit: 3ed4ddf076359518462a32cc4325a9a4d1802aa1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3ed4ddf076359518462a32cc4325a9a4d1802aa1

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Thu Jul 22 16:24:59 2021 -0500

anv,vulkan: Add a vk_image::wsi_legacy_scanout bit

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12023>

---

 src/intel/vulkan/anv_device.c  | 2 +-
 src/intel/vulkan/anv_image.c   | 9 ++-------
 src/intel/vulkan/anv_private.h | 9 ---------
 src/vulkan/util/vk_image.c     | 5 +++++
 src/vulkan/util/vk_image.h     | 3 +++
 5 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index ac7063e4f6b..52df97b73c7 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -4076,7 +4076,7 @@ VkResult anv_AllocateMemory(
       /* Some legacy (non-modifiers) consumers need the tiling to be set on
        * the BO.  In this case, we have a dedicated allocation.
        */
-      if (image->needs_set_tiling) {
+      if (image->vk.wsi_legacy_scanout) {
          const uint32_t i915_tiling =
             isl_tiling_to_i915_tiling(image->planes[0].primary_surface.isl.tiling);
          int ret = anv_gem_set_tiling(device, mem->bo->gem_handle,
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 96f4dee8b59..5d85bbbf4dd 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -1272,9 +1272,6 @@ anv_image_create(VkDevice _device,
    image->vk.stencil_usage =
       anv_image_create_usage(pCreateInfo, image->vk.stencil_usage);
 
-   const struct wsi_image_create_info *wsi_info =
-      vk_find_struct_const(pCreateInfo->pNext, WSI_IMAGE_CREATE_INFO_MESA);
-
    if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
       mod_explicit_info =
          vk_find_struct_const(pCreateInfo->pNext,
@@ -1295,8 +1292,6 @@ anv_image_create(VkDevice _device,
       image->vk.drm_format_mod = isl_mod_info->modifier;
    }
 
-   image->needs_set_tiling = wsi_info && wsi_info->scanout;
-
    for (int i = 0; i < ANV_IMAGE_MEMORY_BINDING_END; ++i) {
       image->bindings[i] = (struct anv_image_binding) {
          .memory_range = { .binding = i },
@@ -1323,7 +1318,7 @@ anv_image_create(VkDevice _device,
 
    const isl_tiling_flags_t isl_tiling_flags =
       choose_isl_tiling_flags(&device->info, create_info, isl_mod_info,
-                              image->needs_set_tiling);
+                              image->vk.wsi_legacy_scanout);
 
    const VkImageFormatListCreateInfoKHR *fmt_list =
       vk_find_struct_const(pCreateInfo->pNext,
@@ -1612,7 +1607,7 @@ void anv_GetImageMemoryRequirements2(
       switch (ext->sType) {
       case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS: {
          VkMemoryDedicatedRequirements *requirements = (void *)ext;
-         if (image->needs_set_tiling || image->from_ahb) {
+         if (image->vk.wsi_legacy_scanout || image->from_ahb) {
             /* If we need to set the tiling for external consumers, we need a
              * dedicated allocation.
              *
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 0ff036bef4a..8eafbbfdb3f 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -3952,15 +3952,6 @@ struct anv_image {
 
    uint32_t n_planes;
 
-   /** True if this is needs to be bound to an appropriately tiled BO.
-    *
-    * When not using modifiers, consumers such as X11, Wayland, and KMS need
-    * the tiling passed via I915_GEM_SET_TILING.  When exporting these buffers
-    * we require a dedicated allocation so that we can know to allocate a
-    * tiled buffer.
-    */
-   bool needs_set_tiling;
-
    /**
     * Image has multi-planar format and was created with
     * VK_IMAGE_CREATE_DISJOINT_BIT.
diff --git a/src/vulkan/util/vk_image.c b/src/vulkan/util/vk_image.c
index e583459f564..7323885178b 100644
--- a/src/vulkan/util/vk_image.c
+++ b/src/vulkan/util/vk_image.c
@@ -34,6 +34,7 @@
 #include "vk_device.h"
 #include "vk_format.h"
 #include "vk_util.h"
+#include "vulkan/wsi/wsi_common.h"
 
 static VkExtent3D
 sanitize_image_extent(const VkImageType imageType,
@@ -100,6 +101,10 @@ vk_image_init(struct vk_device *device,
    else
       image->external_handle_types = 0;
 
+   const struct wsi_image_create_info *wsi_info =
+      vk_find_struct_const(pCreateInfo->pNext, WSI_IMAGE_CREATE_INFO_MESA);
+   image->wsi_legacy_scanout = wsi_info && wsi_info->scanout;
+
 #ifndef _WIN32
    image->drm_format_mod = ((1ULL << 56) - 1) /* DRM_FORMAT_MOD_INVALID */;
 #endif
diff --git a/src/vulkan/util/vk_image.h b/src/vulkan/util/vk_image.h
index 5ff55377aef..beb26064775 100644
--- a/src/vulkan/util/vk_image.h
+++ b/src/vulkan/util/vk_image.h
@@ -53,6 +53,9 @@ struct vk_image {
    /* VK_KHR_external_memory */
    VkExternalMemoryHandleTypeFlags external_handle_types;
 
+   /* wsi_image_create_info::scanout */
+   bool wsi_legacy_scanout;
+
 #ifndef _WIN32
    /* VK_EXT_drm_format_modifier
     *



More information about the mesa-commit mailing list