From 4c40aa8440dc37ae3885d616ef3c2fbba63b3c6d Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Tue, 19 Jul 2016 17:39:34 -0600 Subject: layers: Fix image aspect checks Previously validation required DS images to have both DEPTH and STENCIL aspect bits set, but spec only requires that at least one is set. Also, we weren't checking case of depth or stencil only formats, or color format to make sure that correct aspect mask was set. --- layers/core_validation.cpp | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 980b92ee..3c5c87d8 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -8004,14 +8004,39 @@ static bool ValidateBarriers(const char *funcName, VkCommandBuffer cmdBuffer, ui } } if (imageFound) { - if (vk_format_is_depth_and_stencil(format) && - (!(mem_barrier->subresourceRange.aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) || - !(mem_barrier->subresourceRange.aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT))) { - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, - DRAWSTATE_INVALID_BARRIER, "DS", "%s: Image is a depth and stencil format and thus must " - "have both VK_IMAGE_ASPECT_DEPTH_BIT and " - "VK_IMAGE_ASPECT_STENCIL_BIT set.", - funcName); + auto aspect_mask = mem_barrier->subresourceRange.aspectMask; + if (vk_format_is_depth_or_stencil(format)) { + if (vk_format_is_depth_and_stencil(format)) { + if (!(aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) && !(aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT)) { + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, + __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", + "%s: Image is a depth and stencil format and thus must " + "have either one or both of VK_IMAGE_ASPECT_DEPTH_BIT and " + "VK_IMAGE_ASPECT_STENCIL_BIT set.", + funcName); + } + } else if (vk_format_is_depth_only(format)) { + if (!(aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT)) { + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, + __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", "%s: Image is a depth-only format and thus must " + "have VK_IMAGE_ASPECT_DEPTH_BIT set.", + funcName); + } + } else { // stencil-only case + if (!(aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT)) { + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, + __LINE__, DRAWSTATE_INVALID_BARRIER, "DS", "%s: Image is a stencil-only format and thus must " + "have VK_IMAGE_ASPECT_STENCIL_BIT set.", + funcName); + } + } + } else { // image is a color format + if (!(aspect_mask & VK_IMAGE_ASPECT_COLOR_BIT)) { + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, + DRAWSTATE_INVALID_BARRIER, "DS", "%s: Image is a color format and thus must " + "have VK_IMAGE_ASPECT_COLOR_BIT set.", + funcName); + } } int layerCount = (mem_barrier->subresourceRange.layerCount == VK_REMAINING_ARRAY_LAYERS) ? 1 -- cgit v1.2.3