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

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

vulkan: pass hal_extensions to InitDriverTable

We only need hal_extensions to initialize the driver tables.  There is no
need to save it in driver::{Instance,Device}Data.

Change-Id: I56ebc0ee9c5bc5e543e7a84412b03b842bd8ced5
parent a0a4e0ee
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ bool InitDispatchTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc) {
#ifndef LIBVULKAN_DRIVER_GEN_H
#define LIBVULKAN_DRIVER_GEN_H

#include <bitset>
#include <vulkan/vulkan.h>
#include <vulkan/vk_android_native_buffer.h>

@@ -194,8 +195,10 @@ struct DeviceDriverTable {
const ProcHook* GetProcHook(const char* name);
ProcHook::Extension GetProcHookExtension(const char* name);

bool InitDriverTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc);
bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc);
bool InitDriverTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc,
                     const std::bitset<ProcHook::EXTENSION_COUNT> &extensions);
bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
                     const std::bitset<ProcHook::EXTENSION_COUNT> &extensions);

»} // namespace driver
»} // namespace vulkan
@@ -273,7 +276,8 @@ ProcHook::Extension GetProcHookExtension(const char* name) {

{{Macro "driver.C++.DefineInitProcExtMacro"}}

bool InitDriverTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc)
bool InitDriverTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc,
                     const std::bitset<ProcHook::EXTENSION_COUNT> &extensions)
{
    auto& data = GetData(instance);
    bool success = true;
@@ -289,7 +293,8 @@ bool InitDriverTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc)
    return success;
}

bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc)
bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc,
                     const std::bitset<ProcHook::EXTENSION_COUNT> &extensions)
{
    auto& data = GetData(dev);
    bool success = true;
@@ -699,7 +704,7 @@ VK_KHR_swapchain
*/}}
{{define "driver.C++.DefineInitProcExtMacro"}}
  #define INIT_PROC_EXT(ext, obj, proc) do {                    \
      if (data.hal_extensions[ProcHook::ext])           \
      if (extensions[ProcHook::ext])                            \
        INIT_PROC(obj, proc);                                   \
  } while(0)
{{end}}
+4 −4
Original line number Diff line number Diff line
@@ -616,7 +616,6 @@ VkResult CreateInstance(const VkInstanceCreateInfo* pCreateInfo,
        return VK_ERROR_OUT_OF_HOST_MEMORY;

    data->hook_extensions |= wrapper.GetHookExtensions();
    data->hal_extensions |= wrapper.GetHalExtensions();

    // call into the driver
    VkInstance instance;
@@ -630,7 +629,8 @@ VkResult CreateInstance(const VkInstanceCreateInfo* pCreateInfo,

    // initialize InstanceDriverTable
    if (!SetData(instance, *data) ||
        !InitDriverTable(instance, g_hwdevice->GetInstanceProcAddr)) {
        !InitDriverTable(instance, g_hwdevice->GetInstanceProcAddr,
                         wrapper.GetHalExtensions())) {
        data->driver.DestroyInstance = reinterpret_cast<PFN_vkDestroyInstance>(
            g_hwdevice->GetInstanceProcAddr(instance, "vkDestroyInstance"));
        if (data->driver.DestroyInstance)
@@ -687,7 +687,6 @@ VkResult CreateDevice(VkPhysicalDevice physicalDevice,
        return VK_ERROR_OUT_OF_HOST_MEMORY;

    data->hook_extensions |= wrapper.GetHookExtensions();
    data->hal_extensions |= wrapper.GetHalExtensions();

    // call into the driver
    VkDevice dev;
@@ -701,7 +700,8 @@ VkResult CreateDevice(VkPhysicalDevice physicalDevice,

    // initialize DeviceDriverTable
    if (!SetData(dev, *data) ||
        !InitDriverTable(dev, instance_data.get_device_proc_addr)) {
        !InitDriverTable(dev, instance_data.get_device_proc_addr,
                         wrapper.GetHalExtensions())) {
        data->driver.DestroyDevice = reinterpret_cast<PFN_vkDestroyDevice>(
            instance_data.get_device_proc_addr(dev, "vkDestroyDevice"));
        if (data->driver.DestroyDevice)
+0 −4
Original line number Diff line number Diff line
@@ -74,7 +74,6 @@ struct InstanceData {
          driver(),
          get_device_proc_addr(nullptr) {
        hook_extensions.set(ProcHook::EXTENSION_CORE);
        hal_extensions.set(ProcHook::EXTENSION_CORE);
    }

    api::InstanceData opaque_api_data;
@@ -82,7 +81,6 @@ struct InstanceData {
    const VkAllocationCallbacks allocator;

    std::bitset<ProcHook::EXTENSION_COUNT> hook_extensions;
    std::bitset<ProcHook::EXTENSION_COUNT> hal_extensions;

    InstanceDriverTable driver;
    PFN_vkGetDeviceProcAddr get_device_proc_addr;
@@ -94,7 +92,6 @@ struct DeviceData {
    DeviceData(const VkAllocationCallbacks& alloc)
        : opaque_api_data(), allocator(alloc), driver() {
        hook_extensions.set(ProcHook::EXTENSION_CORE);
        hal_extensions.set(ProcHook::EXTENSION_CORE);
    }

    api::DeviceData opaque_api_data;
@@ -102,7 +99,6 @@ struct DeviceData {
    const VkAllocationCallbacks allocator;

    std::bitset<ProcHook::EXTENSION_COUNT> hook_extensions;
    std::bitset<ProcHook::EXTENSION_COUNT> hal_extensions;

    DeviceDriverTable driver;
};
+10 −6
Original line number Diff line number Diff line
@@ -383,11 +383,13 @@ ProcHook::Extension GetProcHookExtension(const char* name) {

#define INIT_PROC_EXT(ext, obj, proc)  \
    do {                               \
        if (data.hal_extensions[ProcHook::ext]) \
        if (extensions[ProcHook::ext]) \
            INIT_PROC(obj, proc);      \
    } while (0)

bool InitDriverTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc) {
bool InitDriverTable(VkInstance instance,
                     PFN_vkGetInstanceProcAddr get_proc,
                     const std::bitset<ProcHook::EXTENSION_COUNT>& extensions) {
    auto& data = GetData(instance);
    bool success = true;

@@ -406,7 +408,9 @@ bool InitDriverTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc) {
    return success;
}

bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc) {
bool InitDriverTable(VkDevice dev,
                     PFN_vkGetDeviceProcAddr get_proc,
                     const std::bitset<ProcHook::EXTENSION_COUNT>& extensions) {
    auto& data = GetData(dev);
    bool success = true;

+7 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#ifndef LIBVULKAN_DRIVER_GEN_H
#define LIBVULKAN_DRIVER_GEN_H

#include <bitset>
#include <vulkan/vulkan.h>
#include <vulkan/vk_android_native_buffer.h>

@@ -83,8 +84,12 @@ struct DeviceDriverTable {
const ProcHook* GetProcHook(const char* name);
ProcHook::Extension GetProcHookExtension(const char* name);

bool InitDriverTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc);
bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc);
bool InitDriverTable(VkInstance instance,
                     PFN_vkGetInstanceProcAddr get_proc,
                     const std::bitset<ProcHook::EXTENSION_COUNT>& extensions);
bool InitDriverTable(VkDevice dev,
                     PFN_vkGetDeviceProcAddr get_proc,
                     const std::bitset<ProcHook::EXTENSION_COUNT>& extensions);

}  // namespace driver
}  // namespace vulkan