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

Commit 4a6a9164 authored by Chia-I Wu's avatar Chia-I Wu
Browse files

vulkan: use driver::GetData everywhere

Move away from the one-liners defined in loader.cpp.

Change-Id: I73c39cbe21aa3b2079f67590bb40f0cd55563f84
parent 62262237
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -219,7 +219,6 @@ bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc);
#include <log/log.h>

#include "driver.h"
#include "loader.h"

namespace vulkan {«
namespace driver {«
+22 −24
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

#include "loader.h"
#include "driver.h"

namespace vulkan {
namespace driver {
@@ -26,24 +26,22 @@ VkResult DebugReportCallbackList::CreateCallback(
    VkDebugReportCallbackEXT* callback) {
    VkDebugReportCallbackEXT driver_callback = VK_NULL_HANDLE;

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

    const VkAllocationCallbacks* alloc =
        allocator ? allocator : GetAllocator(instance);
        allocator ? allocator : &GetData(instance).allocator;
    void* mem =
        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);
        if (GetData(instance).driver.DestroyDebugReportCallbackEXT) {
            GetData(instance).driver.DestroyDebugReportCallbackEXT(
                instance, driver_callback, allocator);
        }
        return VK_ERROR_OUT_OF_HOST_MEMORY;
    }
@@ -69,13 +67,13 @@ void DebugReportCallbackList::DestroyCallback(
    prev->next = node->next;
    lock.unlock();

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

    const VkAllocationCallbacks* alloc =
        allocator ? allocator : GetAllocator(instance);
        allocator ? allocator : &GetData(instance).allocator;
    alloc->pfnFree(alloc->pUserData, node);
}

@@ -101,7 +99,7 @@ VkResult CreateDebugReportCallbackEXT(
    const VkDebugReportCallbackCreateInfoEXT* create_info,
    const VkAllocationCallbacks* allocator,
    VkDebugReportCallbackEXT* callback) {
    return GetDebugReportCallbacks(instance).CreateCallback(
    return GetData(instance).debug_report_callbacks.CreateCallback(
        instance, create_info, allocator, callback);
}

@@ -109,8 +107,8 @@ void DestroyDebugReportCallbackEXT(VkInstance instance,
                                   VkDebugReportCallbackEXT callback,
                                   const VkAllocationCallbacks* allocator) {
    if (callback)
        GetDebugReportCallbacks(instance).DestroyCallback(instance, callback,
                                                          allocator);
        GetData(instance).debug_report_callbacks.DestroyCallback(
            instance, callback, allocator);
}

void DebugReportMessageEXT(VkInstance instance,
@@ -121,12 +119,12 @@ void DebugReportMessageEXT(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);
    if (GetData(instance).driver.DebugReportMessageEXT) {
        GetData(instance).driver.DebugReportMessageEXT(
            instance, flags, object_type, object, location, message_code,
            layer_prefix, message);
    }
    GetDebugReportCallbacks(instance).Message(flags, object_type, object,
    GetData(instance).debug_report_callbacks.Message(flags, object_type, object,
                                                     location, message_code,
                                                     layer_prefix, message);
}
+0 −1
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@
#include <sys/prctl.h>

#include "driver.h"
#include "loader.h"

// #define ENABLE_ALLOC_CALLSTACKS 1
#if ENABLE_ALLOC_CALLSTACKS
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "api_gen.h"
#include "driver_gen.h"
#include "debug_report.h"
#include "swapchain.h"

namespace vulkan {

+0 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
#include <log/log.h>

#include "driver.h"
#include "loader.h"

namespace vulkan {
namespace driver {
Loading