layers:Add image checks for DS image being cleared
authorTobin Ehlis <tobine@google.com>
Thu, 30 Nov 2017 20:47:11 +0000 (13:47 -0700)
committerTobin Ehlis <tobine@google.com>
Wed, 6 Dec 2017 16:25:20 +0000 (09:25 -0700)
Adding checks for two new VUIDs related to vkCmdClearDepthStencilImage
function. Making sure that the image being cleared supports use as a
transfer destination and that the image was created with the usage bit
VK_IMAGE_USAGE_TRANSFER_DST_BIT.

layers/buffer_validation.cpp
layers/vk_validation_error_database.txt

index 77314a2..d69917b 100644 (file)
@@ -1100,6 +1100,26 @@ bool PreCallValidateCmdClearDepthStencilImage(layer_data *device_data, VkCommand
                             HandleToUint64(image), __LINE__, VALIDATION_ERROR_18a0001c, "IMAGE", "%s. %s", str,
                             validation_error_map[VALIDATION_ERROR_18a0001c]);
         }
+        if (VK_IMAGE_USAGE_TRANSFER_DST_BIT != (VK_IMAGE_USAGE_TRANSFER_DST_BIT & image_state->createInfo.usage)) {
+            char const str[] =
+                "vkCmdClearDepthStencilImage() called with an image that was not created with the VK_IMAGE_USAGE_TRANSFER_DST_BIT "
+                "set.";
+            skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
+                            HandleToUint64(image), __LINE__, VALIDATION_ERROR_18a00012, "IMAGE", "%s. %s", str,
+                            validation_error_map[VALIDATION_ERROR_18a00012]);
+        }
+        VkFormatProperties props = GetFormatProperties(device_data, image_state->createInfo.format);
+        VkImageTiling tiling = image_state->createInfo.tiling;
+        VkFormatFeatureFlags flags = (tiling == VK_IMAGE_TILING_LINEAR ? props.linearTilingFeatures : props.optimalTilingFeatures);
+        if ((GetDeviceExtensions(device_data)->vk_khr_maintenance1) &&
+            (VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR != (flags & VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR))) {
+            skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
+                            HandleToUint64(image), __LINE__, VALIDATION_ERROR_18a00010, "IMAGE",
+                            "vkCmdClearDepthStencilImage() called with an image of format %s and tiling %s that does not support "
+                            "VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR. %s",
+                            string_VkFormat(image_state->createInfo.format), string_VkImageTiling(image_state->createInfo.tiling),
+                            validation_error_map[VALIDATION_ERROR_18a00010]);
+        }
     }
     return skip;
 }
index 441aa54..40c6f38 100644 (file)
@@ -1852,8 +1852,8 @@ VALIDATION_ERROR_18810e01~^~Y~^~Unknown~^~vkCmdClearColorImage~^~VUID-vkCmdClear
 VALIDATION_ERROR_18820601~^~Y~^~Unknown~^~vkCmdClearColorImage~^~VUID-vkCmdClearColorImage-pRanges-parameter~^~core~^~The spec valid usage text states 'pRanges must be a valid pointer to an array of rangeCount valid VkImageSubresourceRange structures' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdClearColorImage-pRanges-parameter)~^~implicit
 VALIDATION_ERROR_1882a41b~^~Y~^~Unknown~^~vkCmdClearColorImage~^~VUID-vkCmdClearColorImage-rangeCount-arraylength~^~core~^~The spec valid usage text states 'rangeCount must be greater than 0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdClearColorImage-rangeCount-arraylength)~^~implicit
 VALIDATION_ERROR_18a00009~^~Y~^~Unknown~^~vkCmdClearDepthStencilImage~^~VUID-vkCmdClearDepthStencilImage-commonparent~^~core~^~The spec valid usage text states 'Both of commandBuffer, and image must have been created, allocated, or retrieved from the same VkDevice' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdClearDepthStencilImage-commonparent)~^~implicit
-VALIDATION_ERROR_18a00010~^~N~^~Unknown~^~vkCmdClearDepthStencilImage~^~VUID-vkCmdClearDepthStencilImage-image-00008~^~(VK_KHR_maintenance1)~^~The spec valid usage text states 'image must use a format that supports VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR, which is indicated by VkFormatProperties::linearTilingFeatures (for linearly tiled images) or VkFormatProperties::optimalTilingFeatures (for optimally tiled images) - as returned by vkGetPhysicalDeviceFormatProperties' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdClearDepthStencilImage-image-00008)~^~
-VALIDATION_ERROR_18a00012~^~N~^~Unknown~^~vkCmdClearDepthStencilImage~^~VUID-vkCmdClearDepthStencilImage-image-00009~^~core~^~The spec valid usage text states 'image must have been created with VK_IMAGE_USAGE_TRANSFER_DST_BIT usage flag' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdClearDepthStencilImage-image-00009)~^~
+VALIDATION_ERROR_18a00010~^~Y~^~Unknown~^~vkCmdClearDepthStencilImage~^~VUID-vkCmdClearDepthStencilImage-image-00008~^~(VK_KHR_maintenance1)~^~The spec valid usage text states 'image must use a format that supports VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR, which is indicated by VkFormatProperties::linearTilingFeatures (for linearly tiled images) or VkFormatProperties::optimalTilingFeatures (for optimally tiled images) - as returned by vkGetPhysicalDeviceFormatProperties' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdClearDepthStencilImage-image-00008)~^~
+VALIDATION_ERROR_18a00012~^~Y~^~Unknown~^~vkCmdClearDepthStencilImage~^~VUID-vkCmdClearDepthStencilImage-image-00009~^~core~^~The spec valid usage text states 'image must have been created with VK_IMAGE_USAGE_TRANSFER_DST_BIT usage flag' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdClearDepthStencilImage-image-00009)~^~
 VALIDATION_ERROR_18a00014~^~Y~^~Unknown~^~vkCmdClearDepthStencilImage~^~VUID-vkCmdClearDepthStencilImage-image-00010~^~core~^~The spec valid usage text states 'If image is non-sparse then it must be bound completely and contiguously to a single VkDeviceMemory object' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdClearDepthStencilImage-image-00010)~^~
 VALIDATION_ERROR_18a00016~^~Y~^~InvalidImageLayout~^~vkCmdClearDepthStencilImage~^~VUID-vkCmdClearDepthStencilImage-imageLayout-00011~^~core~^~The spec valid usage text states 'imageLayout must specify the layout of the image subresource ranges of image specified in pRanges at the time this command is executed on a VkDevice' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdClearDepthStencilImage-imageLayout-00011)~^~
 VALIDATION_ERROR_18a00017~^~Y~^~Unknown~^~vkCmdClearDepthStencilImage~^~VUID-vkCmdClearDepthStencilImage-renderpass~^~core~^~The spec valid usage text states 'This command must only be called outside of a render pass instance' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdClearDepthStencilImage-renderpass)~^~implicit