Skip to content
This repository was archived by the owner on Jul 19, 2018. It is now read-only.

Commit 0797062

Browse files
committed
layers: Use CB invalidation mechanism for VU135.
Makes more sense to use command buffer invalidation to drive this than maintaining parallel logic and only picking this up at draw time. Drops some additional TODOs in around areas that need some more work to make this nice.
1 parent 23c5a20 commit 0797062

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

layers/core_validation.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3258,7 +3258,6 @@ static void resetCB(layer_data *dev_data, const VkCommandBuffer cb) {
32583258
pCB->drawData.clear();
32593259
pCB->currentDrawData.buffers.clear();
32603260
pCB->vertex_buffer_used = false;
3261-
pCB->primaryCommandBuffer = VK_NULL_HANDLE;
32623261
// If secondary, invalidate any primary command buffer that may call us.
32633262
if (pCB->createInfo.level == VK_COMMAND_BUFFER_LEVEL_SECONDARY) {
32643263
invalidateCommandBuffers(dev_data,
@@ -4022,6 +4021,8 @@ static bool validatePrimaryCommandBufferState(layer_data *dev_data, GLOBAL_CB_NO
40224021
// Track in-use for resources off of primary and any secondary CBs
40234022
bool skip = false;
40244023

4024+
// TODO: inline this function into sole caller
4025+
40254026
// If USAGE_SIMULTANEOUS_USE_BIT not set then CB cannot already be executing
40264027
// on device
40274028
skip |= validateCommandBufferSimultaneousUse(dev_data, pCB, current_submit_count);
@@ -4030,17 +4031,6 @@ static bool validatePrimaryCommandBufferState(layer_data *dev_data, GLOBAL_CB_NO
40304031

40314032
for (auto pSubCB : pCB->linkedCommandBuffers) {
40324033
skip |= validateResources(dev_data, pSubCB);
4033-
// TODO: replace with invalidateCommandBuffers() at recording.
4034-
if ((pSubCB->primaryCommandBuffer != pCB->commandBuffer) &&
4035-
!(pSubCB->beginInfo.flags & VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT)) {
4036-
log_msg(
4037-
dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, 0,
4038-
__LINE__, VALIDATION_ERROR_00135, "DS",
4039-
"Commandbuffer 0x%p was submitted with secondary buffer 0x%p but that buffer has subsequently been bound to "
4040-
"primary cmd buffer 0x%p and it does not have VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT set. %s",
4041-
pCB->commandBuffer, pSubCB->commandBuffer, pSubCB->primaryCommandBuffer,
4042-
validation_error_map[VALIDATION_ERROR_00135]);
4043-
}
40444034
}
40454035

40464036
skip |= validateCommandBufferState(dev_data, pCB, "vkQueueSubmit()", current_submit_count, VALIDATION_ERROR_00134);
@@ -9550,6 +9540,12 @@ VKAPI_ATTR void VKAPI_CALL CmdExecuteCommands(VkCommandBuffer commandBuffer, uin
95509540
pCommandBuffers[i], pCB->commandBuffer);
95519541
pCB->beginInfo.flags &= ~VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
95529542
}
9543+
if (pSubCB->linkedCommandBuffers.size()) {
9544+
// TODO: adjust message support so we can report an accurate error message for this.
9545+
invalidateCommandBuffers(dev_data, pSubCB->linkedCommandBuffers,
9546+
{HandleToUint64(pCommandBuffers[i]), kVulkanObjectTypeCommandBuffer});
9547+
// TODO: consistent strategy for removing links.
9548+
}
95539549
}
95549550
if (!pCB->activeQueries.empty() && !dev_data->enabled_features.inheritedQueries) {
95559551
skip |=
@@ -9566,7 +9562,6 @@ VKAPI_ATTR void VKAPI_CALL CmdExecuteCommands(VkCommandBuffer commandBuffer, uin
95669562
for (auto ilm_entry : pSubCB->imageLayoutMap) {
95679563
SetLayout(dev_data, pCB, ilm_entry.first, ilm_entry.second);
95689564
}
9569-
pSubCB->primaryCommandBuffer = pCB->commandBuffer;
95709565
pCB->linkedCommandBuffers.insert(pSubCB);
95719566
pSubCB->linkedCommandBuffers.insert(pCB);
95729567
for (auto &function : pSubCB->queryUpdates) {

layers/core_validation_types.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,6 @@ struct GLOBAL_CB_NODE : public BASE_NODE {
662662
std::vector<DRAW_DATA> drawData;
663663
DRAW_DATA currentDrawData;
664664
bool vertex_buffer_used; // Track for perf warning to make sure any bound vtx buffer used
665-
VkCommandBuffer primaryCommandBuffer;
666665
// Track images and buffers that are updated by this CB at the point of a draw
667666
std::unordered_set<VkImageView> updateImages;
668667
std::unordered_set<VkBuffer> updateBuffers;

0 commit comments

Comments
 (0)