Mesa (staging/22.0): zink: add extra validation for resource creation
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri May 20 16:27:30 UTC 2022
Module: Mesa
Branch: staging/22.0
Commit: 220a0578e7afa5c696d773666e4c7c1aad0b5b55
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=220a0578e7afa5c696d773666e4c7c1aad0b5b55
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>
(cherry picked from commit 1c17502ab38a238efe5d9aa4bc0ff07c967adb80)
---
.pick_status.json | 2 +-
src/gallium/drivers/zink/zink_resource.c | 12 +++++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 3e432644118..e0fe88496d5 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1036,7 +1036,7 @@
"description": "zink: add extra validation for resource creation",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"because_sha": null
},
{
diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index 6ca1040560c..2a887bef570 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -223,7 +223,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