From edb016ac0535374c1ff3d1a1f32ccf25d03896f2 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 9 Aug 2016 08:17:14 +1200 Subject: layers: Account for read-only depthstencil attachments in ValidateLayout The depth stencil attachment can be DEPTH_STENCIL_READ_ONLY_OPTIMAL. Signed-off-by: Chris Forbes --- layers/core_validation.cpp | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'layers/core_validation.cpp') diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index f3f2e0a9..8eec89f1 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -9062,20 +9062,33 @@ static bool ValidateLayouts(const layer_data *my_data, VkDevice device, const Vk attach_first_use[attach_index] = false; } if ((subpass.pDepthStencilAttachment != NULL) && (subpass.pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED)) { - if (subpass.pDepthStencilAttachment->layout != VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) { - if (subpass.pDepthStencilAttachment->layout == VK_IMAGE_LAYOUT_GENERAL) { - // TODO: Verify Valid Use in spec. I believe this is allowed (valid) but may not be optimal performance - skip |= log_msg(my_data->report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, - (VkDebugReportObjectTypeEXT)0, 0, __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", - "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); - } else { - skip |= - log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, + switch (subpass.pDepthStencilAttachment->layout) { + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: + /* These are ideal. */ + break; + + case VK_IMAGE_LAYOUT_GENERAL: + /* May not be optimal; TODO: reconsider this warning based on + * other constraints? GENERAL can be better than doing a bunch + * of transitions. + */ + skip |= log_msg(my_data->report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", - "Layout for depth attachment is %s but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL.", + "GENERAL layout for depth attachment may not give optimal performance."); + break; + + default: + /* No other layouts are acceptable */ + skip |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, + DRAWSTATE_INVALID_IMAGE_LAYOUT, "DS", + "Layout for depth attachment is %s but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL, " + "DEPTH_STENCIL_READ_ONLY_OPTIMAL or GENERAL.", string_VkImageLayout(subpass.pDepthStencilAttachment->layout)); - } } + auto attach_index = subpass.pDepthStencilAttachment->attachment; if (attach_first_use[attach_index]) { skip |= ValidateLayoutVsAttachmentDescription(my_data->report_data, subpass.pDepthStencilAttachment->layout, -- cgit v1.2.3