From 00e4c054c2db54f3976689cad0588e5d15f06ac1 Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Mon, 12 Mar 2018 11:26:39 -0600 Subject: layers:Check secondary command buffer renderArea Fixes #2480 Fixes #1501 Add delayed function call to verify secondary command buffer renderArea against vkCmdClearAttachments() rects at vkCmdExecuteCommands() time. Updated the lambda function container for delayed secondary command buffer checks to include a reference to the primary command buffer. Add lambda call at vkCmdClearAttachments() for secondary command buffer and pass in primary command buffer reference so that area restriction can be appropriately checked at vkCmdExecuteCommands() time when renderArea of renderPass is known. --- layers/buffer_validation.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'layers/buffer_validation.cpp') diff --git a/layers/buffer_validation.cpp b/layers/buffer_validation.cpp index 52974e91..ac332d8b 100644 --- a/layers/buffer_validation.cpp +++ b/layers/buffer_validation.cpp @@ -2198,14 +2198,27 @@ bool PreCallValidateCmdClearAttachments(layer_data *device_data, VkCommandBuffer for (uint32_t j = 0; j < rectCount; j++) { // The rectangular region specified by a given element of pRects must be contained within the render area of // the current render pass instance - // TODO: This check should be moved to CmdExecuteCommands or QueueSubmit to cover secondary CB cases - if ((cb_node->createInfo.level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) && - (false == ContainsRect(cb_node->activeRenderPassBeginInfo.renderArea, pRects[j].rect))) { - skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + if (cb_node->createInfo.level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) { + if (false == ContainsRect(cb_node->activeRenderPassBeginInfo.renderArea, pRects[j].rect)) { + skip |= + log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_18600020, "DS", "vkCmdClearAttachments(): The area defined by pRects[%d] is not contained in the area of " "the current render pass instance. %s", j, validation_error_map[VALIDATION_ERROR_18600020]); + } + } else { + cb_node->cmd_execute_commands_functions.emplace_back([=](GLOBAL_CB_NODE *prim_cb, VkFramebuffer fb) { + if (false == ContainsRect(prim_cb->activeRenderPassBeginInfo.renderArea, pRects[j].rect)) { + return log_msg( + report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + HandleToUint64(commandBuffer), __LINE__, VALIDATION_ERROR_18600020, "DS", + "vkCmdClearAttachments(): The area defined by pRects[%d] is not contained in the area of " + "the current render pass instance. %s", + j, validation_error_map[VALIDATION_ERROR_18600020]); + } + return false; + }); } // The layers specified by a given element of pRects must be contained within every attachment that // pAttachments refers to -- cgit v1.2.3