From adb926d5a5032130d55e4d39316efdb11cc1fe1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Mon, 16 Jul 2018 15:18:23 +0200 Subject: [PATCH] winevulkan: Generate get_vulkan_driver_*_proc_addr() helper functions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Alexandre Julliard --- dlls/winemac.drv/vulkan.c | 62 --------------------------------- dlls/winevulkan/make_vulkan | 32 ++++++++++++++++- dlls/winex11.drv/vulkan.c | 66 ------------------------------------ include/wine/vulkan_driver.h | 63 ++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 129 deletions(-) diff --git a/dlls/winemac.drv/vulkan.c b/dlls/winemac.drv/vulkan.c index 3f704544c86..b1211dff544 100644 --- a/dlls/winemac.drv/vulkan.c +++ b/dlls/winemac.drv/vulkan.c @@ -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); diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan index 7ab92dc940b..a7dc040a6de 100755 --- a/dlls/winevulkan/make_vulkan +++ b/dlls/winevulkan/make_vulkan @@ -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): diff --git a/dlls/winex11.drv/vulkan.c b/dlls/winex11.drv/vulkan.c index e0d576b144f..f9eea74d1bd 100644 --- a/dlls/winex11.drv/vulkan.c +++ b/dlls/winex11.drv/vulkan.c @@ -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); diff --git a/include/wine/vulkan_driver.h b/include/wine/vulkan_driver.h index d009f12832f..a5bc50325c7 100644 --- a/include/wine/vulkan_driver.h +++ b/include/wine/vulkan_driver.h @@ -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 */