From 46d383e0036c8fb281a37ad1c8459cd2c26c7c41 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sun, 3 Mar 2019 22:11:09 +1100 Subject: [PATCH] load/init: add more initial entrypoint trampolines --- load/init.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 11 deletions(-) diff --git a/load/init.cpp b/load/init.cpp index ff44534..f06fcb8 100644 --- a/load/init.cpp +++ b/load/init.cpp @@ -24,27 +24,75 @@ /////////////////////////////////////////////////////////////////////////////// -static VkResult setup_vtables ( - const VkInstanceCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkInstance* pInstance -) { +static void setup_tables (void) +{ static auto libraries = cruft::vk::load::enumerate (); static cruft::vk::load::vendor v (libraries[0]); cruft::vk::load::i_table = &v.itable; cruft::vk::load::v_table = &v.vtable; - - return cruft::vk::load::i_table->vkCreateInstance (pCreateInfo, pAllocator, pInstance); } /////////////////////////////////////////////////////////////////////////////// -static cruft::vk::load::instance_table const initialiser { - .vkCreateInstance = setup_vtables, -}; +static VkResult _vkCreateInstance ( + const VkInstanceCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkInstance* pInstance +) { + setup_tables (); + return cruft::vk::load::i_table->vkCreateInstance (pCreateInfo, pAllocator, pInstance); +} //----------------------------------------------------------------------------- -cruft::vk::load::instance_table const *cruft::vk::load::i_table = &initialiser; +static PFN_vkVoidFunction +_vkGetInstanceProcAddr (VkInstance instance,const char* pName) +{ + setup_tables (); + return cruft::vk::load::i_table->vkGetInstanceProcAddr (instance, pName); +} + +//----------------------------------------------------------------------------- +VkResult _vkEnumerateInstanceExtensionProperties ( + const char* pLayerName, + uint32_t* pPropertyCount, + VkExtensionProperties* pProperties +) { + setup_tables (); + return cruft::vk::load::i_table->vkEnumerateInstanceExtensionProperties ( + pLayerName, + pPropertyCount, + pProperties + ); +} + + +//----------------------------------------------------------------------------- +static cruft::vk::load::instance_table const _initialiser { + .vkCreateInstance = _vkCreateInstance, + .vkGetInstanceProcAddr = _vkGetInstanceProcAddr, + .vkEnumerateInstanceExtensionProperties = _vkEnumerateInstanceExtensionProperties, +}; + + +cruft::vk::load::instance_table const *cruft::vk::load::i_table = &_initialiser; + + +/////////////////////////////////////////////////////////////////////////////// +static void* +_vk_icdGetInstanceProcAddr (VkInstance instance, char const *name) +{ + setup_tables (); + return cruft::vk::load::v_table->vk_icdGetInstanceProcAddr (instance, name); +} + + +/////////////////////////////////////////////////////////////////////////////// +static cruft::vk::load::vendor_table const v_initialiser { + .vk_icdGetInstanceProcAddr = _vk_icdGetInstanceProcAddr, +}; + + +cruft::vk::load::vendor_table const *cruft::vk::load::v_table = &v_initialiser;