layers:Capture rect by value to validate 2nd cb
authorTobin Ehlis <tobine@google.com>
Tue, 17 Apr 2018 22:14:26 +0000 (16:14 -0600)
committerTobin Ehlis <tobine@google.com>
Wed, 18 Apr 2018 12:25:15 +0000 (06:25 -0600)
Fixes #2587

The lambda function was only capturing the pRect pointer by value so
the underlying rect value could still be changed between when the
command was submitted to a secondary CB and when the rect was validated
at CmdExecuteCommands() time.

Copy the actual rect value so that it can't change.

layers/buffer_validation.cpp

index 7be395e..99b3fa0 100644 (file)
@@ -2198,8 +2198,10 @@ bool PreCallValidateCmdClearAttachments(layer_data *device_data, VkCommandBuffer
                                         j);
                         }
                     } else {
+                        const auto local_rect =
+                            pRects[j].rect;  // local copy of rect captured by value below to preserve original contents
                         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)) {
+                            if (false == ContainsRect(prim_cb->activeRenderPassBeginInfo.renderArea, local_rect)) {
                                 return log_msg(
                                     report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
                                     HandleToUint64(commandBuffer), VALIDATION_ERROR_18600020,