Skip to content

Commit

Permalink
layers: Add 01912, 01913
Browse files Browse the repository at this point in the history
Check to see that each "EndLabel" has a corresponding "BeginLabel."

Closes #5230.
  • Loading branch information
ncesario-lunarg committed Feb 14, 2023
1 parent 6e6e6b4 commit c2722ca
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
25 changes: 25 additions & 0 deletions layers/core_checks/cmd_buffer_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1677,3 +1677,28 @@ bool CoreChecks::PreCallValidateCmdBindShadingRateImageNV(VkCommandBuffer comman

return skip;
}

void CoreChecks::PostCallRecordCmdBeginDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT *pLabelInfo) {
auto cb_state = GetWrite<CMD_BUFFER_STATE>(commandBuffer);
assert(cb_state);
cb_state->BeginLabel();
}

bool CoreChecks::PreCallValidateCmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer) const {
auto cb_state = GetRead<CMD_BUFFER_STATE>(commandBuffer);
assert(cb_state);
bool skip = false;
if (cb_state->LabelStackDepth() < 1) {
const auto vuid = cb_state->IsPrimary() ? "VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01912"
: "VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01913";
skip |= LogError(commandBuffer, vuid,
"vkCmdEndDebugUtilsLabelEXT() called without a corresponding vkCmdBeginDebugUtilsLabelEXT first");
}
return skip;
}

void CoreChecks::PostCallRecordCmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer) {
auto cb_state = GetWrite<CMD_BUFFER_STATE>(commandBuffer);
assert(cb_state);
cb_state->EndLabel();
}
6 changes: 6 additions & 0 deletions layers/core_checks/core_validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -2226,6 +2226,12 @@ class CoreChecks : public ValidationStateTracker {
bool ValidateDescriptorAddressInfoEXT(VkDevice device, const VkDescriptorAddressInfoEXT* address_info) const;
bool PreCallValidateGetDescriptorEXT(VkDevice device, const VkDescriptorGetInfoEXT* pDescriptorInfo, size_t dataSize,
void* pDescriptor) const override;

// Debug label APIs
void PostCallRecordCmdBeginDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT* pLabelInfo) override;
bool PreCallValidateCmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer) const override;
void PostCallRecordCmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer) override;

#ifdef VK_USE_PLATFORM_METAL_EXT
bool PreCallValidateExportMetalObjectsEXT(VkDevice device, VkExportMetalObjectsInfoEXT* pMetalObjectsInfo) const override;
#endif // VK_USE_PLATFORM_METAL_EXT
Expand Down
8 changes: 8 additions & 0 deletions layers/state_tracker/cmd_buffer_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,17 @@ class CMD_BUFFER_STATE : public REFCOUNTED_NODE {
pipeline_bound = true;
}

bool IsPrimary() const { return createInfo.level == VK_COMMAND_BUFFER_LEVEL_PRIMARY; }
void BeginLabel() { ++label_stack_depth_; }
void EndLabel() { --label_stack_depth_; }
int LabelStackDepth() const { return label_stack_depth_; }

private:
void ResetCBState();

// Keep track of how many CmdBeginDebugUtilsLabelEXT calls have been made without a matching CmdEndDebugUtilsLabelEXT
int label_stack_depth_ = 0;

protected:
void NotifyInvalidate(const BASE_NODE::NodeList &invalid_nodes, bool unlink) override;
void UpdateAttachmentsView(const VkRenderPassBeginInfo *pRenderPassBegin);
Expand Down

0 comments on commit c2722ca

Please sign in to comment.