aboutsummaryrefslogtreecommitdiff
path: root/layers/image.cpp
diff options
context:
space:
mode:
authorMark Young <marky@lunarg.com>2016-04-11 14:26:49 -0600
committerTobin Ehlis <tobine@google.com>2016-04-14 16:43:21 -0600
commit7072544c6bd521acecf71434758cfa6a8a7aada0 (patch)
tree8e7d554a8a20235a323654a2ba2f5dfdc22eaa0c /layers/image.cpp
parentdcab5c002f0494a9651022c7d0c03bc2e91ce76e (diff)
downloadusermoji-7072544c6bd521acecf71434758cfa6a8a7aada0.tar.xz
layers: Fix lx474 by adding image extent = 0 validation check.
Check only the valid dimensions for the imageType provided in the create info. Change-Id: I11d484caf1085b7b0ae4a402453b5fdcadd7b67d
Diffstat (limited to 'layers/image.cpp')
-rw-r--r--layers/image.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/layers/image.cpp b/layers/image.cpp
index d1334c84..e71aa9de 100644
--- a/layers/image.cpp
+++ b/layers/image.cpp
@@ -299,6 +299,36 @@ vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, const VkAll
VkDeviceSize imageGranularity = device_data->physicalDeviceProperties.limits.bufferImageGranularity;
imageGranularity = imageGranularity == 1 ? 0 : imageGranularity;
+ // Make sure all required dimension are non-zero at least.
+ bool failedMinSize = false;
+ switch (pCreateInfo->imageType) {
+ case VK_IMAGE_TYPE_3D:
+ if (pCreateInfo->extent.depth == 0) {
+ failedMinSize = true;
+ }
+ // Intentional fall-through
+ case VK_IMAGE_TYPE_2D:
+ if (pCreateInfo->extent.height == 0) {
+ failedMinSize = true;
+ }
+ // Intentional fall-through
+ case VK_IMAGE_TYPE_1D:
+ if (pCreateInfo->extent.width == 0) {
+ failedMinSize = true;
+ }
+ break;
+ default:
+ break;
+ }
+ if (failedMinSize) {
+ skipCall |=
+ log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
+ (uint64_t)pImage, __LINE__, IMAGE_INVALID_FORMAT_LIMITS_VIOLATION, "Image",
+ "CreateImage extents is 0 for at least one required dimension for image of type %d: "
+ "Width = %d Height = %d Depth = %d.",
+ pCreateInfo->imageType, pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth);
+ }
+
if ((pCreateInfo->extent.depth > ImageFormatProperties.maxExtent.depth) ||
(pCreateInfo->extent.width > ImageFormatProperties.maxExtent.width) ||
(pCreateInfo->extent.height > ImageFormatProperties.maxExtent.height)) {