From e5b1bd6ab8f5c1d9bf6a90b7003dc336cbe3cf93 Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Tue, 9 Jan 2018 03:22:56 +0100 Subject: vulkan: move anv VK_EXT_debug_report implementation to common code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For also using it in radv. I moved the remaining stubs back to anv_device.c as they were just trivial. This does not move the vk_errorf/anv_perf_warn or the object type macros, as those depend on anv types and logging. Reviewed-by: Tapani Pälli --- src/intel/vulkan/anv_device.c | 54 +++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 12 deletions(-) (limited to 'src/intel/vulkan/anv_device.c') diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 90fdda66c5b..777abd87578 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -482,6 +482,7 @@ VkResult anv_CreateInstance( VkInstance* pInstance) { struct anv_instance *instance; + VkResult result; assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO); @@ -541,18 +542,10 @@ VkResult anv_CreateInstance( instance->apiVersion = client_version; instance->physicalDeviceCount = -1; - if (pthread_mutex_init(&instance->callbacks_mutex, NULL) != 0) { + result = vk_debug_report_instance_init(&instance->debug_report_callbacks); + if (result != VK_SUCCESS) { vk_free2(&default_alloc, pAllocator, instance); - return vk_error(VK_ERROR_INITIALIZATION_FAILED); - } - - list_inithead(&instance->callbacks); - - /* Store report debug callback to be used during DestroyInstance. */ - if (ctor_cb) { - instance->destroy_debug_cb.flags = ctor_cb->flags; - instance->destroy_debug_cb.callback = ctor_cb->pfnCallback; - instance->destroy_debug_cb.data = ctor_cb->pUserData; + return vk_error(result); } _mesa_locale_init(); @@ -581,7 +574,7 @@ void anv_DestroyInstance( VG(VALGRIND_DESTROY_MEMPOOL(instance)); - pthread_mutex_destroy(&instance->callbacks_mutex); + vk_debug_report_instance_destroy(&instance->debug_report_callbacks); _mesa_locale_fini(); @@ -1066,6 +1059,43 @@ PFN_vkVoidFunction anv_GetDeviceProcAddr( return anv_lookup_entrypoint(&device->info, pName); } +VkResult +anv_CreateDebugReportCallbackEXT(VkInstance _instance, + const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDebugReportCallbackEXT* pCallback) +{ + ANV_FROM_HANDLE(anv_instance, instance, _instance); + return vk_create_debug_report_callback(&instance->debug_report_callbacks, + pCreateInfo, pAllocator, &instance->alloc, + pCallback); +} + +void +anv_DestroyDebugReportCallbackEXT(VkInstance _instance, + VkDebugReportCallbackEXT _callback, + const VkAllocationCallbacks* pAllocator) +{ + ANV_FROM_HANDLE(anv_instance, instance, _instance); + vk_destroy_debug_report_callback(&instance->debug_report_callbacks, + _callback, pAllocator, &instance->alloc); +} + +void +anv_DebugReportMessageEXT(VkInstance _instance, + VkDebugReportFlagsEXT flags, + VkDebugReportObjectTypeEXT objectType, + uint64_t object, + size_t location, + int32_t messageCode, + const char* pLayerPrefix, + const char* pMessage) +{ + ANV_FROM_HANDLE(anv_instance, instance, _instance); + vk_debug_report(&instance->debug_report_callbacks, flags, objectType, + object, location, messageCode, pLayerPrefix, pMessage); +} + static void anv_queue_init(struct anv_device *device, struct anv_queue *queue) { -- cgit v1.2.3