vulkan: move anv VK_EXT_debug_report implementation to common code.

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 <tapani.palli@intel.com>
This commit is contained in:
Bas Nieuwenhuizen
2018-01-09 03:22:56 +01:00
parent f69cbb2b53
commit e5b1bd6ab8
9 changed files with 182 additions and 95 deletions

View File

@@ -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)
{