load: remove global i_table
This commit is contained in:
parent
d4ff9cbc7a
commit
e531875ad6
@ -29,57 +29,10 @@ static void setup_tables (void)
|
|||||||
static auto libraries = cruft::vk::load::enumerate ();
|
static auto libraries = cruft::vk::load::enumerate ();
|
||||||
static cruft::vk::load::vendor v (libraries[0]);
|
static cruft::vk::load::vendor v (libraries[0]);
|
||||||
|
|
||||||
cruft::vk::load::i_table = &v.itable;
|
|
||||||
cruft::vk::load::v_table = &v.vtable;
|
cruft::vk::load::v_table = &v.vtable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
static VkResult _vkCreateInstance (
|
|
||||||
const VkInstanceCreateInfo* pCreateInfo,
|
|
||||||
const VkAllocationCallbacks* pAllocator,
|
|
||||||
VkInstance* pInstance
|
|
||||||
) {
|
|
||||||
setup_tables ();
|
|
||||||
return cruft::vk::load::i_table->vkCreateInstance (pCreateInfo, pAllocator, pInstance);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
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*
|
static void*
|
||||||
_vk_icdGetInstanceProcAddr (VkInstance instance, char const *name)
|
_vk_icdGetInstanceProcAddr (VkInstance instance, char const *name)
|
||||||
|
@ -838,7 +838,6 @@ def write_load(dst: TextIO, q: List[Type], reg: Registry):
|
|||||||
dst.write("""
|
dst.write("""
|
||||||
struct vendor_table;
|
struct vendor_table;
|
||||||
extern cruft::vk::load::vendor_table const *v_table [[gnu::visibility("default")]];
|
extern cruft::vk::load::vendor_table const *v_table [[gnu::visibility("default")]];
|
||||||
extern cruft::vk::load::instance_table const *i_table [[gnu::visibility("default")]];
|
|
||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
|
|
||||||
@ -866,7 +865,8 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry):
|
|||||||
implementations = {
|
implementations = {
|
||||||
'vkCreateInstance': """
|
'vkCreateInstance': """
|
||||||
auto res = std::make_unique<indirect<VkInstance,cruft::vk::load::instance_table>> ();
|
auto res = std::make_unique<indirect<VkInstance,cruft::vk::load::instance_table>> ();
|
||||||
auto err = cruft::vk::load::i_table->vkCreateInstance (pCreateInfo, pAllocator, &res->handle);
|
auto ptr = (decltype(vkCreateInstance)*) (cruft::vk::load::v_table->vk_icdGetInstanceProcAddr (nullptr, "vkCreateInstance"));
|
||||||
|
auto err = (*ptr) (pCreateInfo, pAllocator, &res->handle);
|
||||||
if (err != VK_SUCCESS)
|
if (err != VK_SUCCESS)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@ -944,10 +944,6 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry):
|
|||||||
for obj in (i for i in q if isinstance(i, Command)):
|
for obj in (i for i in q if isinstance(i, Command)):
|
||||||
first_arg = reg.types[obj.params[0].type]
|
first_arg = reg.types[obj.params[0].type]
|
||||||
|
|
||||||
instance_forward = f"""
|
|
||||||
return cruft::vk::load::i_table->{obj.name} ({", ".join(p.name for p in obj.params)});
|
|
||||||
"""
|
|
||||||
|
|
||||||
if obj.is_instance(reg):
|
if obj.is_instance(reg):
|
||||||
table = 'instance'
|
table = 'instance'
|
||||||
elif obj.is_device(reg):
|
elif obj.is_device(reg):
|
||||||
@ -964,12 +960,8 @@ def write_dispatch(dst: TextIO, q: List[Type], reg: Registry):
|
|||||||
|
|
||||||
if obj.is_instance(reg) and obj.params[0].type not in ['VkInstance', 'VkPhysicalDevice']:
|
if obj.is_instance(reg) and obj.params[0].type not in ['VkInstance', 'VkPhysicalDevice']:
|
||||||
forwarding = f"""
|
forwarding = f"""
|
||||||
if (::cruft::vk::load::i_table->{obj.name})
|
|
||||||
return ::cruft::vk::load::i_table->{obj.name} ({', '.join (i.name for i in obj.params)});
|
|
||||||
else {{
|
|
||||||
auto ptr= cruft::vk::load::v_table->vk_icdGetInstanceProcAddr (nullptr, "{obj.name}");
|
auto ptr= cruft::vk::load::v_table->vk_icdGetInstanceProcAddr (nullptr, "{obj.name}");
|
||||||
return ((decltype({obj.name})*) (ptr)) ({', '.join (i.name for i in obj.params)});
|
return ((decltype({obj.name})*) (ptr)) ({', '.join (i.name for i in obj.params)});
|
||||||
}}
|
|
||||||
"""
|
"""
|
||||||
else:
|
else:
|
||||||
forwarding = f"""
|
forwarding = f"""
|
||||||
|
Loading…
Reference in New Issue
Block a user