From 49ed7305392d1d97e2cd09192e675aafe3570187 Mon Sep 17 00:00:00 2001 From: Nathaniel Cesario Date: Mon, 13 Feb 2023 16:20:54 -0700 Subject: [PATCH] tests: Check 01912 and 01913 --- tests/vklayertests_others.cpp | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/vklayertests_others.cpp b/tests/vklayertests_others.cpp index 38de1e47ac3..b1f18e4ce0d 100644 --- a/tests/vklayertests_others.cpp +++ b/tests/vklayertests_others.cpp @@ -12834,3 +12834,53 @@ TEST_F(VkLayerTest, InvalidExtEnum) { vk_testing::Sampler sampler(*m_device, sampler_ci); m_errorMonitor->VerifyFound(); } + +TEST_F(VkLayerTest, EndDebugLabelWithNoBegin) { + TEST_DESCRIPTION("Call vkCmdEndDebugUtilsLabelEXT without matching vkCmdBeginDebugUtilsLabelEXT"); + + AddRequiredExtensions(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); + ASSERT_NO_FATAL_FAILURE(InitFramework()); + if (!AreRequiredExtensionsEnabled()) { + GTEST_SKIP() << RequiredExtensionsNotSupported() << " not supported"; + } + ASSERT_NO_FATAL_FAILURE(InitState()); + + auto vkCmdBeginDebugUtilsLabelEXT = reinterpret_cast( + vk::GetDeviceProcAddr(m_device->device(), "vkCmdBeginDebugUtilsLabelEXT")); + ASSERT_NE(vkCmdBeginDebugUtilsLabelEXT, nullptr); + auto vkCmdEndDebugUtilsLabelEXT = + reinterpret_cast(vk::GetDeviceProcAddr(m_device->device(), "vkCmdEndDebugUtilsLabelEXT")); + ASSERT_NE(vkCmdEndDebugUtilsLabelEXT, nullptr); + + vk_testing::Event event(*m_device, LvlInitStruct()); + ASSERT_TRUE(event.initialized()); + + m_commandBuffer->begin(); + vk::CmdSetEvent(m_commandBuffer->handle(), event, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT); + + // First verify there is no error in the valid case + auto label = LvlInitStruct(nullptr, "Test"); + vkCmdBeginDebugUtilsLabelEXT(*m_commandBuffer, &label); + vkCmdEndDebugUtilsLabelEXT(*m_commandBuffer); + + // Now call vkCmdEndDebugUtilsLabelEXT without a corresponding begin + m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01912"); + vkCmdEndDebugUtilsLabelEXT(*m_commandBuffer); + m_errorMonitor->VerifyFound(); + + m_commandBuffer->end(); + + // Now test the same scenario for secondary buffers + auto cb_info = + LvlInitStruct(nullptr, m_commandPool->handle(), VK_COMMAND_BUFFER_LEVEL_SECONDARY, 1u); + vk_testing::CommandBuffer cb(*m_device, cb_info); + cb.begin(); + vkCmdBeginDebugUtilsLabelEXT(cb, &label); + vkCmdEndDebugUtilsLabelEXT(cb); + + m_errorMonitor->SetDesiredFailureMsg(kErrorBit, "VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01913"); + vkCmdEndDebugUtilsLabelEXT(cb); + m_errorMonitor->VerifyFound(); + + cb.end(); +}