From 8d410e0c982ca526a9ffc0a3e2174c24506f393b Mon Sep 17 00:00:00 2001 From: Marcin Kantoch Date: Thu, 1 Dec 2022 20:37:25 +0100 Subject: [PATCH] Fix tests for VK_EXT_device_address_binding_report Tests for VK_EXT_device_address_binding_report contain several issues: 1. BindingCallbackRecorder is storing references to objects that are destroyed after API call 2. Validation of binding pairs is only matching the first pair, not going thought the whole vector 3. VK_EXT_debug_utils extension is not enabled on the custom instance 4. VkDebugUtilsMessengerEXT is not being created by the test 5. The test uses logical device not created from the custom instance VK-GL-CTS Issue: 4175 Components: Vulkan Affects: dEQP-VK.memory.address_binding_report.* Change-Id: I3952ad89f5e94d62db9edca3a4aba4abdc6d43b8 --- .../vulkan/memory/vktMemoryAddressBindingTests.cpp | 191 +++++++++++++++------ 1 file changed, 137 insertions(+), 54 deletions(-) diff --git a/external/vulkancts/modules/vulkan/memory/vktMemoryAddressBindingTests.cpp b/external/vulkancts/modules/vulkan/memory/vktMemoryAddressBindingTests.cpp index 31a31dd..6ef50a2 100644 --- a/external/vulkancts/modules/vulkan/memory/vktMemoryAddressBindingTests.cpp +++ b/external/vulkancts/modules/vulkan/memory/vktMemoryAddressBindingTests.cpp @@ -63,13 +63,35 @@ using namespace vkt::ExternalMemoryUtil; using de::MovePtr; using de::SharedPtr; +struct BindingData +{ + VkDeviceAddress bindingAddress; + VkDeviceSize size; + VkDeviceAddressBindingTypeEXT bindingType; + uint64_t objectHandle; + + bool operator==(const BindingData& rhs) const + { + if (bindingAddress != rhs.bindingAddress) + return false; + + if (size != rhs.size) + return false; + + if (objectHandle != rhs.objectHandle) + return false; + + return true; + } +}; + class BindingCallbackRecorder { public: BindingCallbackRecorder(void) {} ~BindingCallbackRecorder(void) = default; - typedef std::vector::const_iterator RecordIterator; + typedef std::vector::const_iterator RecordIterator; RecordIterator getRecordsBegin (void) const { @@ -88,7 +110,17 @@ public: void callbackInternal (const VkDebugUtilsMessengerCallbackDataEXT * pCallbackData) { - mRecords.emplace_back(*pCallbackData); + const VkDeviceAddressBindingCallbackDataEXT* bindingCallbackData = static_cast(pCallbackData->pNext); + + const BindingData bindingData = + { + bindingCallbackData->baseAddress, + bindingCallbackData->size, + bindingCallbackData->bindingType, + pCallbackData->pObjects[0].objectHandle + }; + + mRecords.emplace_back(bindingData); } static VKAPI_ATTR VkBool32 VKAPI_CALL callback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData) @@ -103,7 +135,7 @@ public: } private: - typedef std::vector Records; + typedef std::vector Records; Records mRecords; }; @@ -1624,59 +1656,68 @@ tcu::TestCaseGroup* createObjectTestsGroup (tcu::TestContext& testCtx, const cha static deBool validateCallbackRecords (Context& context, const BindingCallbackRecorder& recorder) { tcu::TestLog& log = context.getTestContext().getLog(); - VkDeviceAddress baseAddress = 0; - VkDeviceSize memorySize = 0; - for (auto record = recorder.getRecordsBegin(); record != recorder.getRecordsEnd(); record++) + for (auto bindRecord = recorder.getRecordsBegin(); bindRecord != recorder.getRecordsEnd(); bindRecord++) { - const VkDeviceAddressBindingCallbackDataEXT& bindingData = reinterpret_cast(record->pNext); - - if (bindingData.bindingType == VK_DEVICE_ADDRESS_BINDING_TYPE_BIND_EXT) + if (bindRecord->bindingType == VK_DEVICE_ADDRESS_BINDING_TYPE_BIND_EXT) { - baseAddress = bindingData.baseAddress; - memorySize = bindingData.size; - } - } + bool matchedBoundUnbound = false; - bool matchedBoundUnbound = true; + for (auto pairRecord = bindRecord; pairRecord != recorder.getRecordsEnd(); pairRecord++) + { + if (pairRecord->bindingType == VK_DEVICE_ADDRESS_BINDING_TYPE_UNBIND_EXT) + { + if ((*bindRecord) == (*pairRecord)) + { + log << tcu::TestLog::Message << "Bind/Unbind base adress:" << bindRecord->bindingAddress << tcu::TestLog::EndMessage; + log << tcu::TestLog::Message << "Bind/Unbind size:" << bindRecord->size << tcu::TestLog::EndMessage; + log << tcu::TestLog::Message << "Bind/Unbind object handle:" << bindRecord->objectHandle << tcu::TestLog::EndMessage; + + matchedBoundUnbound = true; + break; + } + } + } - for (auto record = recorder.getRecordsBegin(); record != recorder.getRecordsEnd(); record++) - { - const VkDeviceAddressBindingCallbackDataEXT& bindingData = reinterpret_cast(record->pNext); + if (matchedBoundUnbound == false) + { + log << tcu::TestLog::Message << "Lonely bind base adress:" << bindRecord->bindingAddress << tcu::TestLog::EndMessage; + log << tcu::TestLog::Message << "Lonely bind size:" << bindRecord->size << tcu::TestLog::EndMessage; + log << tcu::TestLog::Message << "Lonely bind object handle:" << bindRecord->objectHandle << tcu::TestLog::EndMessage; - if (bindingData.bindingType == VK_DEVICE_ADDRESS_BINDING_TYPE_UNBIND_EXT) + return false; + } + } + else if (bindRecord->bindingType == VK_DEVICE_ADDRESS_BINDING_TYPE_UNBIND_EXT) { - if (bindingData.baseAddress != baseAddress) + bool matchedBoundUnbound = false; + + for (auto pairRecord = recorder.getRecordsBegin(); pairRecord != bindRecord; pairRecord++) { - log << tcu::TestLog::Message << "Bind base adress:" << baseAddress << " differ from unbound one: " << bindingData.baseAddress << tcu::TestLog::EndMessage; - matchedBoundUnbound = false; - return false; + if (pairRecord->bindingType == VK_DEVICE_ADDRESS_BINDING_TYPE_BIND_EXT) + { + if ((*bindRecord) == (*pairRecord)) + { + matchedBoundUnbound = true; + break; + } + } } - if (bindingData.size != memorySize) + + if (matchedBoundUnbound == false) { - log << tcu::TestLog::Message << "Bind memory size:" << memorySize << " differ from unbound one: " << bindingData.size << tcu::TestLog::EndMessage; - matchedBoundUnbound = false; + log << tcu::TestLog::Message << "Lonely unbind base adress:" << bindRecord->bindingAddress << tcu::TestLog::EndMessage; + log << tcu::TestLog::Message << "Lonely unbind size:" << bindRecord->size << tcu::TestLog::EndMessage; + log << tcu::TestLog::Message << "Lonely unbind object handle:" << bindRecord->objectHandle << tcu::TestLog::EndMessage; + + return false; } } } - return matchedBoundUnbound; + return true; } -struct EnvClone -{ - Unique device; - DeviceDriver vkd; - Environment env; - - EnvClone (const Environment& parent) - : device (Device::create(parent, Device::Resources(parent, Device::Parameters()), Device::Parameters())) - , vkd (parent.vkp, parent.instance, *device) - , env (parent.vkp, parent.vki, parent.instance, parent.physicalDevice, vkd, *device, parent.queueFamilyIndex, parent.programBinaries, parent.commandLine, nullptr) - { - } -}; - static std::vector getInstanceExtensions(const deUint32 instanceVersion) { std::vector instanceExtensions; @@ -1684,38 +1725,80 @@ static std::vector getInstanceExtensions(const deUint32 instanceVer if (!isCoreInstanceExtension(instanceVersion, "VK_KHR_get_physical_device_properties2")) instanceExtensions.push_back("VK_KHR_get_physical_device_properties2"); + if (!isCoreInstanceExtension(instanceVersion, "VK_EXT_debug_utils")) + instanceExtensions.push_back("VK_EXT_debug_utils"); + return instanceExtensions; } template tcu::TestStatus createDestroyObjectTest (Context& context, typename Object::Parameters params) { - BindingCallbackRecorder recorder; - CustomInstance customInstance = createCustomInstanceWithExtensions(context, getInstanceExtensions(context.getUsedApiVersion())); + BindingCallbackRecorder recorder; + VkDebugUtilsMessengerEXT messenger; + + CustomInstance customInstance = createCustomInstanceWithExtensions(context, getInstanceExtensions(context.getUsedApiVersion())); + vk::VkPhysicalDevice physicalDevice = chooseDevice(customInstance.getDriver(), customInstance, context.getTestContext().getCommandLine()); + deUint32 queueFamilyIndex = 0; + + const std::vector queueProps = getPhysicalDeviceQueueFamilyProperties(customInstance.getDriver(), physicalDevice); + + for (size_t queueNdx = 0; queueNdx < queueProps.size(); queueNdx++) + { + if ((queueProps[queueNdx].queueFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT) + { + queueFamilyIndex = (deUint32)queueNdx; + break; + } + } + + Move device = createDeviceWithAdressBindingReport( + context.getTestContext().getCommandLine().isValidationEnabled(), + context.getPlatformInterface(), + customInstance, + customInstance.getDriver(), + physicalDevice, + queueFamilyIndex); + + de::MovePtr deviceInterface = de::MovePtr(new DeviceDriver(context.getPlatformInterface(), customInstance, device.get())); const Environment env (context.getPlatformInterface(), - context.getInstanceInterface(), + customInstance.getDriver(), customInstance, - context.getPhysicalDevice(), - context.getDeviceInterface(), - context.getDevice(), - context.getUniversalQueueFamilyIndex(), + physicalDevice, + *deviceInterface.get(), + device.get(), + queueFamilyIndex, context.getBinaryCollection(), context.getTestContext().getCommandLine(), &recorder); + VkDebugUtilsMessengerCreateInfoEXT debugUtilsMessengerCreateInfo = + { + VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT, + nullptr, + 0, + VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT, + VK_DEBUG_UTILS_MESSAGE_TYPE_DEVICE_ADDRESS_BINDING_BIT_EXT, + recorder.callback, + &recorder + }; + + env.vki.createDebugUtilsMessengerEXT( + customInstance, + &debugUtilsMessengerCreateInfo, + nullptr, + &messenger); - if (std::is_same::value) { const typename Object::Resources res (env, params); Unique obj (Object::create(env, res, params)); } - else - { - const EnvClone envWithCustomDevice (env); - const typename Object::Resources res (envWithCustomDevice.env, params); - Unique obj (Object::create(envWithCustomDevice.env, res, params)); - } + + env.vki.destroyDebugUtilsMessengerEXT( + customInstance, + messenger, + nullptr); if (!validateCallbackRecords(context, recorder)) { -- 2.7.4