From: Charles Giessen Date: Mon, 6 May 2024 20:30:17 +0000 (-0500) Subject: Add Create/DestroyDebugReportCallback to test_icd X-Git-Tag: upstream/1.3.296~63 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5bd064f946b40be63d6a9991693be92bbfbb9708;p=platform%2Fupstream%2FVulkan-Loader.git Add Create/DestroyDebugReportCallback to test_icd --- diff --git a/tests/framework/icd/test_icd.cpp b/tests/framework/icd/test_icd.cpp index 60861e9b..e52c1617 100644 --- a/tests/framework/icd/test_icd.cpp +++ b/tests/framework/icd/test_icd.cpp @@ -320,9 +320,16 @@ test_vkEnumeratePhysicalDeviceGroups([[maybe_unused]] VkInstance instance, uint3 VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateDebugUtilsMessengerEXT( [[maybe_unused]] VkInstance instance, [[maybe_unused]] const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, - [[maybe_unused]] const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pMessenger) { + const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pMessenger) { if (nullptr != pMessenger) { - uint64_t fake_msgr_handle = reinterpret_cast(new uint8_t); + uint8_t* new_handle_ptr = nullptr; + if (pAllocator) { + new_handle_ptr = + (uint8_t*)pAllocator->pfnAllocation(pAllocator->pUserData, sizeof(uint8_t*), 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + } else { + new_handle_ptr = new uint8_t; + } + uint64_t fake_msgr_handle = reinterpret_cast(new_handle_ptr); icd.messenger_handles.push_back(fake_msgr_handle); #if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || \ defined(_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) @@ -336,7 +343,7 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateDebugUtilsMessengerEXT( VKAPI_ATTR void VKAPI_CALL test_vkDestroyDebugUtilsMessengerEXT([[maybe_unused]] VkInstance instance, VkDebugUtilsMessengerEXT messenger, - [[maybe_unused]] const VkAllocationCallbacks* pAllocator) { + const VkAllocationCallbacks* pAllocator) { if (messenger != VK_NULL_HANDLE) { uint64_t fake_msgr_handle = (uint64_t)(messenger); auto found_iter = std::find(icd.messenger_handles.begin(), icd.messenger_handles.end(), fake_msgr_handle); @@ -344,7 +351,11 @@ VKAPI_ATTR void VKAPI_CALL test_vkDestroyDebugUtilsMessengerEXT([[maybe_unused]] // Remove it from the list icd.messenger_handles.erase(found_iter); // Delete the handle - delete (uint8_t*)(fake_msgr_handle); + if (pAllocator) { + pAllocator->pfnFree(pAllocator->pUserData, (uint8_t*)fake_msgr_handle); + } else { + delete (uint8_t*)(fake_msgr_handle); + } } else { std::cerr << "Messenger not found during destroy!\n"; abort(); @@ -352,6 +363,53 @@ VKAPI_ATTR void VKAPI_CALL test_vkDestroyDebugUtilsMessengerEXT([[maybe_unused]] } } +// debug report create/destroy + +VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateDebugReportCallbackEXT( + [[maybe_unused]] VkInstance instance, [[maybe_unused]] const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pCallback) { + if (nullptr != pCallback) { + uint8_t* new_handle_ptr = nullptr; + if (pAllocator) { + new_handle_ptr = + (uint8_t*)pAllocator->pfnAllocation(pAllocator->pUserData, sizeof(uint8_t*), 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + } else { + new_handle_ptr = new uint8_t; + } + uint64_t fake_msgr_handle = reinterpret_cast(new_handle_ptr); + icd.callback_handles.push_back(fake_msgr_handle); +#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || \ + defined(_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) + *pCallback = reinterpret_cast(fake_msgr_handle); +#else + *pCallback = fake_msgr_handle; +#endif + } + return VK_SUCCESS; +} + +VKAPI_ATTR void VKAPI_CALL test_vkDestroyDebugReportCallbackEXT([[maybe_unused]] VkInstance instance, + VkDebugReportCallbackEXT callback, + const VkAllocationCallbacks* pAllocator) { + if (callback != VK_NULL_HANDLE) { + uint64_t fake_msgr_handle = (uint64_t)(callback); + auto found_iter = std::find(icd.callback_handles.begin(), icd.callback_handles.end(), fake_msgr_handle); + if (found_iter != icd.callback_handles.end()) { + // Remove it from the list + icd.callback_handles.erase(found_iter); + // Delete the handle + if (pAllocator) { + pAllocator->pfnFree(pAllocator->pUserData, (uint8_t*)fake_msgr_handle); + } else { + delete (uint8_t*)(fake_msgr_handle); + } + } else { + std::cerr << "callback not found during destroy!\n"; + abort(); + } + } +} + // Debug utils & debug marker ext stubs VKAPI_ATTR VkResult VKAPI_CALL test_vkDebugMarkerSetObjectTagEXT(VkDevice dev, const VkDebugMarkerObjectTagInfoEXT* pTagInfo) { if (pTagInfo && pTagInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { @@ -1310,6 +1368,14 @@ PFN_vkVoidFunction get_instance_func_wsi(VkInstance instance, const char* pName) return to_vkVoidFunction(test_vkDestroyDebugUtilsMessengerEXT); } } + if (IsInstanceExtensionEnabled(VK_EXT_DEBUG_MARKER_EXTENSION_NAME)) { + if (string_eq(pName, "vkCreateDebugReportCallbackEXT")) { + return to_vkVoidFunction(test_vkCreateDebugReportCallbackEXT); + } + if (string_eq(pName, "vkDestroyDebugReportCallbackEXT")) { + return to_vkVoidFunction(test_vkDestroyDebugReportCallbackEXT); + } + } PFN_vkVoidFunction ret_phys_dev_wsi = get_physical_device_func_wsi(instance, pName); if (ret_phys_dev_wsi != nullptr) return ret_phys_dev_wsi; diff --git a/tests/framework/icd/test_icd.h b/tests/framework/icd/test_icd.h index 6290af34..7fa135db 100644 --- a/tests/framework/icd/test_icd.h +++ b/tests/framework/icd/test_icd.h @@ -118,6 +118,7 @@ struct TestICD { std::vector> device_handles; std::vector surface_handles; std::vector messenger_handles; + std::vector callback_handles; std::vector swapchain_handles; BUILDER_VALUE(TestICD, bool, can_query_vkEnumerateInstanceVersion, true);