diff options
author | Tapani Pälli <[email protected]> | 2017-08-23 11:25:57 +0300 |
---|---|---|
committer | Tapani Pälli <[email protected]> | 2017-09-12 09:39:29 +0300 |
commit | 086cfa5652ec202f87c14d11e0f6c959d75987d8 (patch) | |
tree | 8d64eee5da48c69e7bddc0b0e60f805800dfba09 /src/intel/vulkan/anv_device.c | |
parent | ab6f874439943837c06d3346385f75145e6d2775 (diff) |
anv: implementation of VK_EXT_debug_report extension
Patch adds required functionality for extension to manage a list of
application provided callbacks and handle debug reporting from driver
and application side.
v2: remove useless helper anv_debug_report_call
add locking around callbacks list
use vk_alloc2, vk_free2
refactor CreateDebugReportCallbackEXT
fix bugs found with crucible testing
v3: provide ANV_FROM_HANDLE and use it
misc fixes for issues Jason found
use vk_find_struct_const for finding ctor_cb
Signed-off-by: Tapani Pälli <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_device.c')
-rw-r--r-- | src/intel/vulkan/anv_device.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 2e0fa19b1aa..1a6ed8c919c 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -446,6 +446,13 @@ VkResult anv_CreateInstance( assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO); + /* Check if user passed a debug report callback to be used during + * Create/Destroy of instance. + */ + const VkDebugReportCallbackCreateInfoEXT *ctor_cb = + vk_find_struct_const(pCreateInfo->pNext, + DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT); + uint32_t client_version; if (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion != 0) { @@ -456,6 +463,17 @@ VkResult anv_CreateInstance( if (VK_MAKE_VERSION(1, 0, 0) > client_version || client_version > VK_MAKE_VERSION(1, 0, 0xfff)) { + + if (ctor_cb && ctor_cb->flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) + ctor_cb->pfnCallback(VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, + VK_NULL_HANDLE, /* No handle available yet. */ + __LINE__, + 0, + "anv", + "incompatible driver version", + ctor_cb->pUserData); + return vk_errorf(VK_ERROR_INCOMPATIBLE_DRIVER, "Client requested version %d.%d.%d", VK_VERSION_MAJOR(client_version), @@ -484,6 +502,20 @@ VkResult anv_CreateInstance( instance->apiVersion = client_version; instance->physicalDeviceCount = -1; + if (pthread_mutex_init(&instance->callbacks_mutex, NULL) != 0) { + 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; + } + _mesa_locale_init(); VG(VALGRIND_CREATE_MEMPOOL(instance, 0, false)); @@ -510,6 +542,8 @@ void anv_DestroyInstance( VG(VALGRIND_DESTROY_MEMPOOL(instance)); + pthread_mutex_destroy(&instance->callbacks_mutex); + _mesa_locale_fini(); vk_free(&instance->alloc, instance); |