summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2022-04-20 12:57:47 -0400
committerMarge Bot <emma+marge@anholt.net>2022-05-18 02:29:18 +0000
commit1c17502ab38a238efe5d9aa4bc0ff07c967adb80 (patch)
tree1745191bd08bde16b7cfb79300c3a443940a1cc2 /src
parent7e69384af163288d80cd817575419258e496bf21 (diff)
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@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16563>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/zink/zink_resource.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index 0bb1d1c4009..6e4b8076e9d 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