Mesa (staging/22.1): zink: add extra validation for resource creation

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 18 02:46:09 UTC 2022


Module: Mesa
Branch: staging/22.1
Commit: 73c79f3cc14c629beb4ffeac01559d5c29cc2925
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=73c79f3cc14c629beb4ffeac01559d5c29cc2925

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Wed Apr 20 12:57:47 2022 -0400

zink: add extra validation for resource creation

check image params against driver's returned limits to avoid
failing later

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16563>

---

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

diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index 8c80e75f147..e9c3fb249ed 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -227,7 +227,17 @@ check_ici(struct zink_screen *screen, VkImageCreateInfo *ici, uint64_t modifier)
    } else
       ret = VKSCR(GetPhysicalDeviceImageFormatProperties)(screen->pdev, ici->format, ici->imageType,
                                                    ici->tiling, ici->usage, ici->flags, &image_props);
-   return ret == VK_SUCCESS;
+   if (ret != VK_SUCCESS)
+      return false;
+   if (ici->extent.depth > image_props.maxExtent.depth ||
+       ici->extent.height > image_props.maxExtent.height ||
+       ici->extent.width > image_props.maxExtent.width)
+      return false;
+   if (ici->mipLevels > image_props.maxMipLevels)
+      return false;
+   if (ici->arrayLayers > image_props.maxArrayLayers)
+      return false;
+   return true;
 }
 
 static VkImageUsageFlags



More information about the mesa-commit mailing list