Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6fecdd56 authored by Courtney Goeltzenleuchter's avatar Courtney Goeltzenleuchter Committed by Jesse Hall
Browse files

loader: Only use driver's DebugReport if it has one

Change-Id: Ic020b9d5a95c9ddd20dd4c94fd6e7de050b83f2b
(cherry picked from commit b776ba1c)
parent ca472ab8
Loading
Loading
Loading
Loading
+23 −12
Original line number Diff line number Diff line
@@ -23,11 +23,16 @@ VkResult DebugReportCallbackList::CreateCallback(
    const VkDebugReportCallbackCreateInfoEXT* create_info,
    const VkAllocationCallbacks* allocator,
    VkDebugReportCallbackEXT* callback) {
    VkDebugReportCallbackEXT driver_callback;
    VkResult result = GetDriverDispatch(instance).CreateDebugReportCallbackEXT(
        GetDriverInstance(instance), create_info, allocator, &driver_callback);
    VkDebugReportCallbackEXT driver_callback = VK_NULL_HANDLE;

    if (GetDriverDispatch(instance).CreateDebugReportCallbackEXT) {
        VkResult result =
            GetDriverDispatch(instance).CreateDebugReportCallbackEXT(
                GetDriverInstance(instance), create_info, allocator,
                &driver_callback);
        if (result != VK_SUCCESS)
            return result;
    }

    const VkAllocationCallbacks* alloc =
        allocator ? allocator : GetAllocator(instance);
@@ -35,8 +40,10 @@ VkResult DebugReportCallbackList::CreateCallback(
        alloc->pfnAllocation(alloc->pUserData, sizeof(Node), alignof(Node),
                             VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
    if (!mem) {
        if (GetDriverDispatch(instance).DestroyDebugReportCallbackEXT) {
            GetDriverDispatch(instance).DestroyDebugReportCallbackEXT(
                GetDriverInstance(instance), driver_callback, allocator);
        }
        return VK_ERROR_OUT_OF_HOST_MEMORY;
    }

@@ -61,8 +68,10 @@ void DebugReportCallbackList::DestroyCallback(
    prev->next = node->next;
    lock.unlock();

    if (GetDriverDispatch(instance).DestroyDebugReportCallbackEXT) {
        GetDriverDispatch(instance).DestroyDebugReportCallbackEXT(
            GetDriverInstance(instance), node->driver_callback, allocator);
    }

    const VkAllocationCallbacks* alloc =
        allocator ? allocator : GetAllocator(instance);
@@ -112,9 +121,11 @@ void DebugReportMessageEXT_Bottom(VkInstance instance,
                                  int32_t message_code,
                                  const char* layer_prefix,
                                  const char* message) {
    if (GetDriverDispatch(instance).DebugReportMessageEXT) {
        GetDriverDispatch(instance).DebugReportMessageEXT(
            GetDriverInstance(instance), flags, object_type, object, location,
            message_code, layer_prefix, message);
    }
    GetDebugReportCallbacks(instance).Message(flags, object_type, object,
                                              location, message_code,
                                              layer_prefix, message);
+5 −2
Original line number Diff line number Diff line
@@ -547,11 +547,14 @@ VkResult CreateInstance_Bottom(const VkInstanceCreateInfo* create_info,
                enabled_extensions.set(id);
                continue;
            }
            if (id == kKHR_surface || id == kKHR_android_surface ||
                id == kEXT_debug_report) {
            if (id == kKHR_surface || id == kKHR_android_surface) {
                enabled_extensions.set(id);
                continue;
            }
            // The loader natively supports debug report.
            if (id == kEXT_debug_report) {
                continue;
            }
        }
        bool supported = false;
        for (const auto& layer : instance.active_layers) {