Mesa (main): zink: limit images we mark as cube-compatible

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 7 11:58:41 UTC 2021


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

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Sat May 29 09:51:29 2021 +0200

zink: limit images we mark as cube-compatible

The Vulkan spec says the following:

> If imageType is VK_IMAGE_TYPE_2D and flags contains
> VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, extent.width and extent.height
> must be equal and arrayLayers must be greater than or equal to 6

This makes a lot of sense, as these are also requirements for being able
to create cubemaps from them in the first place.

Let's thread a bit more careful, and only set this bit in these cases.
This matters in the new case of setting this flag on 2D array textures.
In the other cases, this should already be the case.

I haven't seen this trigger any issues, I just realized this while
reading the Vulkan-spec.

Fixes: 1887ff2ebb7 ("zink: mark 2d-arrays as cube-compatible")
Reviewed-by: Hoe Hao Cheng <haochengho12907 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11081>

---

 src/gallium/drivers/zink/zink_resource.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index 1e811f6703d..9bb38273dbf 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -388,7 +388,9 @@ create_ici(struct zink_screen *screen, const struct pipe_resource *templ, unsign
 
    if (templ->target == PIPE_TEXTURE_CUBE ||
        templ->target == PIPE_TEXTURE_CUBE_ARRAY ||
-       templ->target == PIPE_TEXTURE_2D_ARRAY) {
+       (templ->target == PIPE_TEXTURE_2D_ARRAY &&
+        ici.extent.width == ici.extent.height &&
+        ici.arrayLayers >= 6)) {
       VkImageFormatProperties props;
       if (vkGetPhysicalDeviceImageFormatProperties(screen->pdev, ici.format,
                                                    ici.imageType, ici.tiling,



More information about the mesa-commit mailing list