Commit 4ab041c3 authored by Roderick Colenbrander's avatar Roderick Colenbrander Committed by Alexandre Julliard

winevulkan: Load instance functions.

parent 203c5a8f
......@@ -1035,17 +1035,41 @@ class VkGenerator(object):
# Generate prototypes for device and instance functions requiring a custom implementation.
f.write("/* Functions for which we have custom implementations outside of the thunks. */\n")
for vk_func in self.registry.funcs.values():
if not vk_func.is_required() or vk_func.is_global_func() or vk_func.needs_thunk():
continue
f.write("{0};\n".format(vk_func.prototype("WINAPI", prefix="wine_", postfix="DECLSPEC_HIDDEN")))
f.write("\n")
f.write("/* For use by vkInstance and children */\n")
f.write("struct vulkan_instance_funcs\n{\n")
for vk_func in self.registry.instance_funcs:
if not vk_func.is_required():
continue
if vk_func.is_global_func():
if not vk_func.needs_dispatch() or vk_func.is_driver_func():
LOGGER.debug("skipping {0} in vulkan_instance_funcs".format(vk_func.name))
continue
if vk_func.needs_thunk():
f.write(" {0};\n".format(vk_func.pfn(conv=False)))
f.write("};\n\n")
f.write("#define ALL_VK_INSTANCE_FUNCS() \\\n")
first = True
for vk_func in self.registry.instance_funcs:
if not vk_func.is_required():
continue
f.write("{0};\n".format(vk_func.prototype("WINAPI", prefix="wine_", postfix="DECLSPEC_HIDDEN")))
f.write("\n")
if not vk_func.needs_dispatch() or vk_func.is_driver_func():
LOGGER.debug("skipping {0} in ALL_VK_INSTANCE_FUNCS".format(vk_func.name))
continue
if first:
f.write(" USE_VK_FUNC({0})".format(vk_func.name))
first = False
else:
f.write("\\\n USE_VK_FUNC({0})".format(vk_func.name))
f.write("\n\n")
f.write("#endif /* __WINE_VULKAN_THUNKS_H */\n")
......
......@@ -99,6 +99,15 @@ static VkResult WINAPI wine_vkCreateInstance(const VkInstanceCreateInfo *create_
goto err;
}
/* Load all instance functions we are aware of. Note the loader takes care
* of any filtering for extensions which were not requested, but which the
* ICD may support.
*/
#define USE_VK_FUNC(name) \
object->funcs.p_##name = (void*)vk_funcs->p_vkGetInstanceProcAddr(object->instance, #name);
ALL_VK_INSTANCE_FUNCS()
#undef USE_VK_FUNC
*instance = object;
TRACE("Done, instance=%p native_instance=%p\n", object, object->instance);
return VK_SUCCESS;
......
......@@ -51,6 +51,7 @@ struct wine_vk_base
struct VkInstance_T
{
struct wine_vk_base base;
struct vulkan_instance_funcs funcs;
VkInstance instance; /* native instance */
};
......
......@@ -9,4 +9,33 @@ void *wine_vk_get_instance_proc_addr(const char *name) DECLSPEC_HIDDEN;
/* Functions for which we have custom implementations outside of the thunks. */
void WINAPI wine_vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) DECLSPEC_HIDDEN;
/* For use by vkInstance and children */
struct vulkan_instance_funcs
{
VkResult (*p_vkCreateDevice)(VkPhysicalDevice, const VkDeviceCreateInfo *, const VkAllocationCallbacks *, VkDevice *);
VkResult (*p_vkEnumerateDeviceExtensionProperties)(VkPhysicalDevice, const char *, uint32_t *, VkExtensionProperties *);
VkResult (*p_vkEnumerateDeviceLayerProperties)(VkPhysicalDevice, uint32_t *, VkLayerProperties *);
VkResult (*p_vkEnumeratePhysicalDevices)(VkInstance, uint32_t *, VkPhysicalDevice *);
void (*p_vkGetPhysicalDeviceFeatures)(VkPhysicalDevice, VkPhysicalDeviceFeatures *);
void (*p_vkGetPhysicalDeviceFormatProperties)(VkPhysicalDevice, VkFormat, VkFormatProperties *);
VkResult (*p_vkGetPhysicalDeviceImageFormatProperties)(VkPhysicalDevice, VkFormat, VkImageType, VkImageTiling, VkImageUsageFlags, VkImageCreateFlags, VkImageFormatProperties *);
void (*p_vkGetPhysicalDeviceMemoryProperties)(VkPhysicalDevice, VkPhysicalDeviceMemoryProperties *);
void (*p_vkGetPhysicalDeviceProperties)(VkPhysicalDevice, VkPhysicalDeviceProperties *);
void (*p_vkGetPhysicalDeviceQueueFamilyProperties)(VkPhysicalDevice, uint32_t *, VkQueueFamilyProperties *);
void (*p_vkGetPhysicalDeviceSparseImageFormatProperties)(VkPhysicalDevice, VkFormat, VkImageType, VkSampleCountFlagBits, VkImageUsageFlags, VkImageTiling, uint32_t *, VkSparseImageFormatProperties *);
};
#define ALL_VK_INSTANCE_FUNCS() \
USE_VK_FUNC(vkCreateDevice)\
USE_VK_FUNC(vkEnumerateDeviceExtensionProperties)\
USE_VK_FUNC(vkEnumerateDeviceLayerProperties)\
USE_VK_FUNC(vkEnumeratePhysicalDevices)\
USE_VK_FUNC(vkGetPhysicalDeviceFeatures)\
USE_VK_FUNC(vkGetPhysicalDeviceFormatProperties)\
USE_VK_FUNC(vkGetPhysicalDeviceImageFormatProperties)\
USE_VK_FUNC(vkGetPhysicalDeviceMemoryProperties)\
USE_VK_FUNC(vkGetPhysicalDeviceProperties)\
USE_VK_FUNC(vkGetPhysicalDeviceQueueFamilyProperties)\
USE_VK_FUNC(vkGetPhysicalDeviceSparseImageFormatProperties)
#endif /* __WINE_VULKAN_THUNKS_H */
......@@ -36,6 +36,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
static VkResult (*pvkCreateInstance)(const VkInstanceCreateInfo *, const VkAllocationCallbacks *, VkInstance *);
static void (*pvkDestroyInstance)(VkInstance, const VkAllocationCallbacks *);
static void * (*pvkGetInstanceProcAddr)(VkInstance, const char *);
static BOOL wine_vk_init(void)
{
......@@ -50,6 +51,7 @@ static BOOL wine_vk_init(void)
#define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(vulkan_handle, #f, NULL, 0)) == NULL) return FALSE;
LOAD_FUNCPTR(vkCreateInstance)
LOAD_FUNCPTR(vkDestroyInstance)
LOAD_FUNCPTR(vkGetInstanceProcAddr)
#undef LOAD_FUNCPTR
return TRUE;
......@@ -116,8 +118,8 @@ static VkResult X11DRV_vkEnumerateInstanceExtensionProperties(const char *layer_
static void * X11DRV_vkGetInstanceProcAddr(VkInstance instance, const char *name)
{
FIXME("stub: %p, %s\n", instance, debugstr_a(name));
return NULL;
TRACE("%p, %s\n", instance, debugstr_a(name));
return pvkGetInstanceProcAddr(instance, name);
}
static const struct vulkan_funcs vulkan_funcs =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment