winevulkan: Generate get_vulkan_driver_*_proc_addr() helper functions.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-07-16 15:18:23 +02:00 committed by Alexandre Julliard
parent 0cbbab9dac
commit adb926d5a5
4 changed files with 94 additions and 129 deletions

View File

@ -488,73 +488,11 @@ static const struct vulkan_funcs vulkan_funcs =
macdrv_vkQueuePresentKHR,
};
static void *get_vulkan_driver_device_proc_addr(const struct vulkan_funcs *vulkan_funcs,
const char *name)
{
if (!name || name[0] != 'v' || name[1] != 'k')
return NULL;
name += 2;
if (!strcmp(name, "CreateSwapchainKHR"))
return vulkan_funcs->p_vkCreateSwapchainKHR;
if (!strcmp(name, "DestroySwapchainKHR"))
return vulkan_funcs->p_vkDestroySwapchainKHR;
if (!strcmp(name, "GetDeviceProcAddr"))
return vulkan_funcs->p_vkGetDeviceProcAddr;
if (!strcmp(name, "GetSwapchainImagesKHR"))
return vulkan_funcs->p_vkGetSwapchainImagesKHR;
if (!strcmp(name, "QueuePresentKHR"))
return vulkan_funcs->p_vkQueuePresentKHR;
return NULL;
}
static void *macdrv_get_vk_device_proc_addr(const char *name)
{
return get_vulkan_driver_device_proc_addr(&vulkan_funcs, name);
}
static void *get_vulkan_driver_instance_proc_addr(const struct vulkan_funcs *vulkan_funcs,
VkInstance instance, const char *name)
{
if (!name || name[0] != 'v' || name[1] != 'k')
return NULL;
name += 2;
if (!strcmp(name, "CreateInstance"))
return vulkan_funcs->p_vkCreateInstance;
if (!strcmp(name, "EnumerateInstanceExtensionProperties"))
return vulkan_funcs->p_vkEnumerateInstanceExtensionProperties;
if (!instance)
return NULL;
if (!strcmp(name, "CreateWin32SurfaceKHR"))
return vulkan_funcs->p_vkCreateWin32SurfaceKHR;
if (!strcmp(name, "DestroyInstance"))
return vulkan_funcs->p_vkDestroyInstance;
if (!strcmp(name, "DestroySurfaceKHR"))
return vulkan_funcs->p_vkDestroySurfaceKHR;
if (!strcmp(name, "GetInstanceProcAddr"))
return vulkan_funcs->p_vkGetInstanceProcAddr;
if (!strcmp(name, "GetPhysicalDeviceSurfaceCapabilitiesKHR"))
return vulkan_funcs->p_vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfaceFormatsKHR"))
return vulkan_funcs->p_vkGetPhysicalDeviceSurfaceFormatsKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfacePresentModesKHR"))
return vulkan_funcs->p_vkGetPhysicalDeviceSurfacePresentModesKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfaceSupportKHR"))
return vulkan_funcs->p_vkGetPhysicalDeviceSurfaceSupportKHR;
if (!strcmp(name, "GetPhysicalDeviceWin32PresentationSupportKHR"))
return vulkan_funcs->p_vkGetPhysicalDeviceWin32PresentationSupportKHR;
name -= 2;
return get_vulkan_driver_device_proc_addr(vulkan_funcs, name);
}
static void *macdrv_get_vk_instance_proc_addr(VkInstance instance, const char *name)
{
return get_vulkan_driver_instance_proc_addr(&vulkan_funcs, instance, name);

View File

@ -2235,7 +2235,7 @@ class VkGenerator(object):
f.write(" */\n")
for vk_func in self.registry.funcs.values():
if not vk_func.is_required() or not vk_func.is_driver_func():
if not vk_func.is_driver_func():
continue
pfn = vk_func.pfn()
@ -2246,6 +2246,36 @@ class VkGenerator(object):
f.write("};\n\n")
f.write("extern const struct vulkan_funcs * CDECL __wine_get_vulkan_driver(HDC hdc, UINT version);\n\n")
f.write("static inline void *get_vulkan_driver_device_proc_addr(\n")
f.write(" const struct vulkan_funcs *vulkan_funcs, const char *name)\n{\n")
f.write(" if (!name || name[0] != 'v' || name[1] != 'k') return NULL;\n\n")
f.write(" name += 2;\n\n")
for vk_func in self.registry.funcs.values():
if vk_func.is_driver_func() and vk_func.is_device_func():
f.write(' if (!strcmp(name, "{0}"))\n'.format(vk_func.name[2:]))
f.write(' return vulkan_funcs->p_{0};\n'.format(vk_func.name))
f.write("\n")
f.write(" return NULL;\n}\n\n")
f.write("static inline void *get_vulkan_driver_instance_proc_addr(\n")
f.write(" const struct vulkan_funcs *vulkan_funcs, VkInstance instance, const char *name)\n{\n")
f.write(" if (!name || name[0] != 'v' || name[1] != 'k') return NULL;\n\n")
f.write(" name += 2;\n\n")
for vk_func in self.registry.funcs.values():
if vk_func.is_driver_func() and vk_func.is_global_func() and vk_func.name != "vkGetInstanceProcAddr":
f.write(' if (!strcmp(name, "{0}"))\n'.format(vk_func.name[2:]))
f.write(' return vulkan_funcs->p_{0};\n'.format(vk_func.name))
f.write("\n")
f.write(" if (!instance) return NULL;\n\n")
for vk_func in self.registry.funcs.values():
if vk_func.is_driver_func() and vk_func.is_instance_func():
f.write(' if (!strcmp(name, "{0}"))\n'.format(vk_func.name[2:]))
f.write(' return vulkan_funcs->p_{0};\n'.format(vk_func.name))
f.write("\n")
f.write(" name -= 2;\n\n")
f.write(" return get_vulkan_driver_device_proc_addr(vulkan_funcs, name);\n}\n\n")
f.write("#endif /* __WINE_VULKAN_DRIVER_H */\n")
def generate_vulkan_spec(self, f):

View File

@ -540,77 +540,11 @@ static const struct vulkan_funcs vulkan_funcs =
X11DRV_vkQueuePresentKHR,
};
static void *get_vulkan_driver_device_proc_addr(const struct vulkan_funcs *vulkan_funcs,
const char *name)
{
if (!name || name[0] != 'v' || name[1] != 'k')
return NULL;
name += 2;
if (!strcmp(name, "CreateSwapchainKHR"))
return vulkan_funcs->p_vkCreateSwapchainKHR;
if (!strcmp(name, "DestroySwapchainKHR"))
return vulkan_funcs->p_vkDestroySwapchainKHR;
if (!strcmp(name, "GetDeviceGroupSurfacePresentModesKHR"))
return vulkan_funcs->p_vkGetDeviceGroupSurfacePresentModesKHR;
if (!strcmp(name, "GetDeviceProcAddr"))
return vulkan_funcs->p_vkGetDeviceProcAddr;
if (!strcmp(name, "GetSwapchainImagesKHR"))
return vulkan_funcs->p_vkGetSwapchainImagesKHR;
if (!strcmp(name, "QueuePresentKHR"))
return vulkan_funcs->p_vkQueuePresentKHR;
return NULL;
}
static void *X11DRV_get_vk_device_proc_addr(const char *name)
{
return get_vulkan_driver_device_proc_addr(&vulkan_funcs, name);
}
static void *get_vulkan_driver_instance_proc_addr(const struct vulkan_funcs *vulkan_funcs,
VkInstance instance, const char *name)
{
if (!name || name[0] != 'v' || name[1] != 'k')
return NULL;
name += 2;
if (!strcmp(name, "CreateInstance"))
return vulkan_funcs->p_vkCreateInstance;
if (!strcmp(name, "EnumerateInstanceExtensionProperties"))
return vulkan_funcs->p_vkEnumerateInstanceExtensionProperties;
if (!instance)
return NULL;
if (!strcmp(name, "CreateWin32SurfaceKHR"))
return vulkan_funcs->p_vkCreateWin32SurfaceKHR;
if (!strcmp(name, "DestroyInstance"))
return vulkan_funcs->p_vkDestroyInstance;
if (!strcmp(name, "DestroySurfaceKHR"))
return vulkan_funcs->p_vkDestroySurfaceKHR;
if (!strcmp(name, "GetInstanceProcAddr"))
return vulkan_funcs->p_vkGetInstanceProcAddr;
if (!strcmp(name, "GetPhysicalDevicePresentRectanglesKHR"))
return vulkan_funcs->p_vkGetPhysicalDevicePresentRectanglesKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfaceCapabilitiesKHR"))
return vulkan_funcs->p_vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfaceFormatsKHR"))
return vulkan_funcs->p_vkGetPhysicalDeviceSurfaceFormatsKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfacePresentModesKHR"))
return vulkan_funcs->p_vkGetPhysicalDeviceSurfacePresentModesKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfaceSupportKHR"))
return vulkan_funcs->p_vkGetPhysicalDeviceSurfaceSupportKHR;
if (!strcmp(name, "GetPhysicalDeviceWin32PresentationSupportKHR"))
return vulkan_funcs->p_vkGetPhysicalDeviceWin32PresentationSupportKHR;
name -= 2;
return get_vulkan_driver_device_proc_addr(vulkan_funcs, name);
}
static void *X11DRV_get_vk_instance_proc_addr(VkInstance instance, const char *name)
{
return get_vulkan_driver_instance_proc_addr(&vulkan_funcs, instance, name);

View File

@ -69,4 +69,67 @@ struct vulkan_funcs
extern const struct vulkan_funcs * CDECL __wine_get_vulkan_driver(HDC hdc, UINT version);
static inline void *get_vulkan_driver_device_proc_addr(
const struct vulkan_funcs *vulkan_funcs, const char *name)
{
if (!name || name[0] != 'v' || name[1] != 'k') return NULL;
name += 2;
if (!strcmp(name, "CreateSwapchainKHR"))
return vulkan_funcs->p_vkCreateSwapchainKHR;
if (!strcmp(name, "DestroySwapchainKHR"))
return vulkan_funcs->p_vkDestroySwapchainKHR;
if (!strcmp(name, "GetDeviceGroupSurfacePresentModesKHR"))
return vulkan_funcs->p_vkGetDeviceGroupSurfacePresentModesKHR;
if (!strcmp(name, "GetDeviceProcAddr"))
return vulkan_funcs->p_vkGetDeviceProcAddr;
if (!strcmp(name, "GetSwapchainImagesKHR"))
return vulkan_funcs->p_vkGetSwapchainImagesKHR;
if (!strcmp(name, "QueuePresentKHR"))
return vulkan_funcs->p_vkQueuePresentKHR;
return NULL;
}
static inline void *get_vulkan_driver_instance_proc_addr(
const struct vulkan_funcs *vulkan_funcs, VkInstance instance, const char *name)
{
if (!name || name[0] != 'v' || name[1] != 'k') return NULL;
name += 2;
if (!strcmp(name, "CreateInstance"))
return vulkan_funcs->p_vkCreateInstance;
if (!strcmp(name, "EnumerateInstanceExtensionProperties"))
return vulkan_funcs->p_vkEnumerateInstanceExtensionProperties;
if (!instance) return NULL;
if (!strcmp(name, "CreateWin32SurfaceKHR"))
return vulkan_funcs->p_vkCreateWin32SurfaceKHR;
if (!strcmp(name, "DestroyInstance"))
return vulkan_funcs->p_vkDestroyInstance;
if (!strcmp(name, "DestroySurfaceKHR"))
return vulkan_funcs->p_vkDestroySurfaceKHR;
if (!strcmp(name, "GetInstanceProcAddr"))
return vulkan_funcs->p_vkGetInstanceProcAddr;
if (!strcmp(name, "GetPhysicalDevicePresentRectanglesKHR"))
return vulkan_funcs->p_vkGetPhysicalDevicePresentRectanglesKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfaceCapabilitiesKHR"))
return vulkan_funcs->p_vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfaceFormatsKHR"))
return vulkan_funcs->p_vkGetPhysicalDeviceSurfaceFormatsKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfacePresentModesKHR"))
return vulkan_funcs->p_vkGetPhysicalDeviceSurfacePresentModesKHR;
if (!strcmp(name, "GetPhysicalDeviceSurfaceSupportKHR"))
return vulkan_funcs->p_vkGetPhysicalDeviceSurfaceSupportKHR;
if (!strcmp(name, "GetPhysicalDeviceWin32PresentationSupportKHR"))
return vulkan_funcs->p_vkGetPhysicalDeviceWin32PresentationSupportKHR;
name -= 2;
return get_vulkan_driver_device_proc_addr(vulkan_funcs, name);
}
#endif /* __WINE_VULKAN_DRIVER_H */