aboutsummaryrefslogtreecommitdiff
path: root/layers/core_validation.cpp
diff options
context:
space:
mode:
authorChris Forbes <chrisforbes@google.com>2017-05-18 15:52:12 -0700
committerChris Forbes <chrisf@ijw.co.nz>2017-05-18 19:08:01 -0700
commitbd5ab535a0ada8182f8c2645fd1a0c92bec09431 (patch)
tree6d3c2405fa83f0bcf384015b1889d8e6e3803cee /layers/core_validation.cpp
parent57f953b7e623241e89248a0c39b549808a41c034 (diff)
downloadusermoji-bd5ab535a0ada8182f8c2645fd1a0c92bec09431.tar.xz
layers: Track linked command buffers in both directions
This is required for us to do proper invalidation.
Diffstat (limited to 'layers/core_validation.cpp')
-rw-r--r--layers/core_validation.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 8e5d6c07..06165048 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -3252,7 +3252,18 @@ static void resetCB(layer_data *dev_data, const VkCommandBuffer cb) {
pCB->currentDrawData.buffers.clear();
pCB->vertex_buffer_used = false;
pCB->primaryCommandBuffer = VK_NULL_HANDLE;
- pCB->secondaryCommandBuffers.clear();
+ // If secondary, invalidate any primary command buffer that may call us.
+ if (pCB->createInfo.level == VK_COMMAND_BUFFER_LEVEL_SECONDARY) {
+ invalidateCommandBuffers(dev_data,
+ pCB->linkedCommandBuffers,
+ {HandleToUint64(cb), kVulkanObjectTypeCommandBuffer});
+ }
+
+ // Remove reverse command buffer links.
+ for (auto pSubCB : pCB->linkedCommandBuffers) {
+ pSubCB->linkedCommandBuffers.erase(pCB);
+ }
+ pCB->linkedCommandBuffers.clear();
pCB->updateImages.clear();
pCB->updateBuffers.clear();
clear_cmd_buf_and_mem_references(dev_data, pCB);
@@ -4010,8 +4021,9 @@ static bool validatePrimaryCommandBufferState(layer_data *dev_data, GLOBAL_CB_NO
skip |= validateResources(dev_data, pCB);
- for (auto pSubCB : pCB->secondaryCommandBuffers) {
+ for (auto pSubCB : pCB->linkedCommandBuffers) {
skip |= validateResources(dev_data, pSubCB);
+ // TODO: replace with invalidateCommandBuffers() at recording.
if ((pSubCB->primaryCommandBuffer != pCB->commandBuffer) &&
!(pSubCB->beginInfo.flags & VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT)) {
log_msg(
@@ -4095,12 +4107,12 @@ static void PostCallRecordQueueSubmit(layer_data *dev_data, VkQueue queue, uint3
auto cb_node = GetCBNode(dev_data, submit->pCommandBuffers[i]);
if (cb_node) {
cbs.push_back(submit->pCommandBuffers[i]);
- for (auto secondaryCmdBuffer : cb_node->secondaryCommandBuffers) {
+ for (auto secondaryCmdBuffer : cb_node->linkedCommandBuffers) {
cbs.push_back(secondaryCmdBuffer->commandBuffer);
}
UpdateCmdBufImageLayouts(dev_data, cb_node);
incrementResources(dev_data, cb_node);
- for (auto secondaryCmdBuffer : cb_node->secondaryCommandBuffers) {
+ for (auto secondaryCmdBuffer : cb_node->linkedCommandBuffers) {
incrementResources(dev_data, secondaryCmdBuffer);
}
}
@@ -9559,7 +9571,8 @@ VKAPI_ATTR void VKAPI_CALL CmdExecuteCommands(VkCommandBuffer commandBuffer, uin
SetLayout(dev_data, pCB, ilm_entry.first, ilm_entry.second);
}
pSubCB->primaryCommandBuffer = pCB->commandBuffer;
- pCB->secondaryCommandBuffers.insert(pSubCB);
+ pCB->linkedCommandBuffers.insert(pSubCB);
+ pSubCB->linkedCommandBuffers.insert(pCB);
for (auto &function : pSubCB->queryUpdates) {
pCB->queryUpdates.push_back(function);
}