From a90644606866f8c80885c999135f822ac08433e9 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 | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/vklayertests_others.cpp b/tests/vklayertests_others.cpp index dcdac1cb420..c3d8d3027b6 100644 --- a/tests/vklayertests_others.cpp +++ b/tests/vklayertests_others.cpp @@ -10794,3 +10794,48 @@ 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); + + m_commandBuffer->begin(); + // 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(); +}