From 21baabc6f066b9470b7c7a6c49576c4e33c7ad22 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 26 Jun 2017 17:57:39 -0700 Subject: layers: Don't copy all the image subresources every submit The set of subresources touched by this submission is likely to be very small compared to the complete set we're tracking. It doesn't make any sense to copy this entire hashtable in each submit call. Instead, maintain an overlay table with the submission's modifications in it. Saves approx 12s in an internal workload. --- layers/buffer_validation.cpp | 8 +++++--- layers/buffer_validation.h | 3 ++- layers/core_validation.cpp | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/layers/buffer_validation.cpp b/layers/buffer_validation.cpp index 7739fe08..6f4440b4 100644 --- a/layers/buffer_validation.cpp +++ b/layers/buffer_validation.cpp @@ -2466,13 +2466,15 @@ void PreCallRecordCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_node, // the IMAGE is the same // as the global IMAGE layout bool ValidateCmdBufImageLayouts(layer_data *device_data, GLOBAL_CB_NODE *pCB, - std::unordered_map &imageLayoutMap) { + std::unordered_map const & globalImageLayoutMap, + std::unordered_map & overlayLayoutMap) { bool skip = false; const debug_report_data *report_data = core_validation::GetReportData(device_data); for (auto cb_image_data : pCB->imageLayoutMap) { VkImageLayout imageLayout; - if (FindLayout(imageLayoutMap, cb_image_data.first, imageLayout)) { + if (FindLayout(overlayLayoutMap, cb_image_data.first, imageLayout) || + FindLayout(globalImageLayoutMap, cb_image_data.first, imageLayout)) { if (cb_image_data.second.initialLayout == VK_IMAGE_LAYOUT_UNDEFINED) { // TODO: Set memory invalid which is in mem_tracker currently } else if (imageLayout != cb_image_data.second.initialLayout) { @@ -2495,7 +2497,7 @@ bool ValidateCmdBufImageLayouts(layer_data *device_data, GLOBAL_CB_NODE *pCB, string_VkImageLayout(cb_image_data.second.initialLayout)); } } - SetLayout(imageLayoutMap, cb_image_data.first, cb_image_data.second.layout); + SetLayout(overlayLayoutMap, cb_image_data.first, cb_image_data.second.layout); } } return skip; diff --git a/layers/buffer_validation.h b/layers/buffer_validation.h index 48eacaea..a9b2b385 100644 --- a/layers/buffer_validation.h +++ b/layers/buffer_validation.h @@ -153,7 +153,8 @@ void PreCallRecordCmdBlitImage(layer_data *device_data, GLOBAL_CB_NODE *cb_node, IMAGE_STATE *dst_image_state); bool ValidateCmdBufImageLayouts(layer_data *device_data, GLOBAL_CB_NODE *pCB, - std::unordered_map &imageLayoutMap); + std::unordered_map const &globalImageLayoutMap, + std::unordered_map &overlayLayoutMap); void UpdateCmdBufImageLayouts(layer_data *device_data, GLOBAL_CB_NODE *pCB); diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 046f9c9f..9450278c 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -2633,7 +2633,7 @@ static bool PreCallValidateQueueSubmit(layer_data *dev_data, VkQueue queue, uint unordered_set signaled_semaphores; unordered_set unsignaled_semaphores; vector current_cmds; - unordered_map localImageLayoutMap = dev_data->imageLayoutMap; + unordered_map localImageLayoutMap; // Now verify each individual submit for (uint32_t submit_idx = 0; submit_idx < submitCount; submit_idx++) { const VkSubmitInfo *submit = &pSubmits[submit_idx]; @@ -2674,7 +2674,7 @@ static bool PreCallValidateQueueSubmit(layer_data *dev_data, VkQueue queue, uint for (uint32_t i = 0; i < submit->commandBufferCount; i++) { auto cb_node = GetCBNode(dev_data, submit->pCommandBuffers[i]); if (cb_node) { - skip |= ValidateCmdBufImageLayouts(dev_data, cb_node, localImageLayoutMap); + skip |= ValidateCmdBufImageLayouts(dev_data, cb_node, dev_data->imageLayoutMap, localImageLayoutMap); current_cmds.push_back(submit->pCommandBuffers[i]); skip |= validatePrimaryCommandBufferState( dev_data, cb_node, (int)std::count(current_cmds.begin(), current_cmds.end(), submit->pCommandBuffers[i])); -- cgit v1.2.3