Commit 88da78ef authored by Georg Lehmann's avatar Georg Lehmann Committed by Alexandre Julliard

winevulkan: Generate a separate physical device dispatch table.

parent 683c2cbb
......@@ -585,7 +585,7 @@ class VkFunction(object):
def is_device_func(self):
# If none of the other, it must be a device function
return not self.is_global_func() and not self.is_instance_func()
return not self.is_global_func() and not self.is_instance_func() and not self.is_phys_dev_func()
def is_driver_func(self):
""" Returns if function is part of Wine driver interface. """
......@@ -602,8 +602,14 @@ class VkFunction(object):
return True
def is_instance_func(self):
# Instance functions are passed VkInstance or VkPhysicalDevice.
if self.params[0].type in ["VkInstance", "VkPhysicalDevice"]:
# Instance functions are passed VkInstance.
if self.params[0].type == "VkInstance":
return True
return False
def is_phys_dev_func(self):
# Physical device functions are passed VkPhysicalDevice.
if self.params[0].type == "VkPhysicalDevice":
return True
return False
......@@ -2271,6 +2277,14 @@ class VkGenerator(object):
f.write(" {{\"{0}\", &{1}{0}}},\n".format(vk_func.name, prefix))
f.write("};\n\n")
f.write("static const struct vulkan_func vk_phys_dev_dispatch_table[] =\n{\n")
for vk_func in self.registry.phys_dev_funcs:
if not vk_func.is_required():
continue
f.write(" {{\"{0}\", &{1}{0}}},\n".format(vk_func.name, prefix))
f.write("};\n\n")
f.write("static const struct vulkan_func vk_instance_dispatch_table[] =\n{\n")
for vk_func in self.registry.instance_funcs:
if not vk_func.is_required():
......@@ -2293,6 +2307,20 @@ class VkGenerator(object):
f.write(" return NULL;\n")
f.write("}\n\n")
f.write("void *wine_vk_get_phys_dev_proc_addr(const char *name)\n")
f.write("{\n")
f.write(" unsigned int i;\n")
f.write(" for (i = 0; i < ARRAY_SIZE(vk_phys_dev_dispatch_table); i++)\n")
f.write(" {\n")
f.write(" if (strcmp(vk_phys_dev_dispatch_table[i].name, name) == 0)\n")
f.write(" {\n")
f.write(" TRACE(\"Found name=%s in physical device table\\n\", debugstr_a(name));\n")
f.write(" return vk_phys_dev_dispatch_table[i].func;\n")
f.write(" }\n")
f.write(" }\n")
f.write(" return NULL;\n")
f.write("}\n\n")
f.write("void *wine_vk_get_instance_proc_addr(const char *name)\n")
f.write("{\n")
f.write(" unsigned int i;\n")
......@@ -2435,7 +2463,7 @@ class VkGenerator(object):
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:
for vk_func in self.registry.instance_funcs + self.registry.phys_dev_funcs:
if not vk_func.is_required():
continue
......@@ -2472,7 +2500,7 @@ class VkGenerator(object):
f.write("#define ALL_VK_INSTANCE_FUNCS() \\\n")
first = True
for vk_func in self.registry.instance_funcs:
for vk_func in self.registry.instance_funcs + self.registry.phys_dev_funcs:
if not vk_func.is_required():
continue
......@@ -2636,7 +2664,7 @@ class VkGenerator(object):
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():
if vk_func.is_driver_func() and (vk_func.is_instance_func() or vk_func.is_phys_dev_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")
......@@ -2837,21 +2865,26 @@ class VkRegistry(object):
funcs[func.name] = func
# To make life easy for the code generation, separate all function
# calls out in the 3 types of Vulkan functions: device, global and instance.
# calls out in the 4 types of Vulkan functions:
# device, global, physical device and instance.
device_funcs = []
global_funcs = []
phys_dev_funcs = []
instance_funcs = []
for func in funcs.values():
if func.is_device_func():
device_funcs.append(func)
elif func.is_global_func():
global_funcs.append(func)
elif func.is_phys_dev_func():
phys_dev_funcs.append(func)
else:
instance_funcs.append(func)
# Sort function lists by name and store them.
self.device_funcs = sorted(device_funcs, key=lambda func: func.name)
self.global_funcs = sorted(global_funcs, key=lambda func: func.name)
self.phys_dev_funcs = sorted(phys_dev_funcs, key=lambda func: func.name)
self.instance_funcs = sorted(instance_funcs, key=lambda func: func.name)
# The funcs dictionary is used as a convenient way to lookup function
......
......@@ -1164,7 +1164,8 @@ PFN_vkVoidFunction WINAPI wine_vkGetDeviceProcAddr(VkDevice device, const char *
* https://github.com/KhronosGroup/Vulkan-Docs/issues/655
*/
if (device->quirks & WINEVULKAN_QUIRK_GET_DEVICE_PROC_ADDR
&& (func = wine_vk_get_instance_proc_addr(name)))
&& ((func = wine_vk_get_instance_proc_addr(name))
|| (func = wine_vk_get_phys_dev_proc_addr(name))))
{
WARN("Returning instance function %s.\n", debugstr_a(name));
return func;
......@@ -1227,6 +1228,9 @@ PFN_vkVoidFunction WINAPI wine_vkGetInstanceProcAddr(VkInstance instance, const
func = wine_vk_get_instance_proc_addr(name);
if (func) return func;
func = wine_vk_get_phys_dev_proc_addr(name);
if (func) return func;
/* vkGetInstanceProcAddr also loads any children of instance, so device functions as well. */
func = wine_vk_get_device_proc_addr(name);
if (func) return func;
......
......@@ -232,6 +232,7 @@ static inline VkSurfaceKHR wine_surface_to_handle(struct wine_surface *surface)
}
void *wine_vk_get_device_proc_addr(const char *name) DECLSPEC_HIDDEN;
void *wine_vk_get_phys_dev_proc_addr(const char *name) DECLSPEC_HIDDEN;
void *wine_vk_get_instance_proc_addr(const char *name) DECLSPEC_HIDDEN;
BOOL wine_vk_device_extension_supported(const char *name) DECLSPEC_HIDDEN;
......
......@@ -7276,23 +7276,12 @@ static const struct vulkan_func vk_device_dispatch_table[] =
{"vkWriteAccelerationStructuresPropertiesKHR", &wine_vkWriteAccelerationStructuresPropertiesKHR},
};
static const struct vulkan_func vk_instance_dispatch_table[] =
static const struct vulkan_func vk_phys_dev_dispatch_table[] =
{
{"vkCreateDebugReportCallbackEXT", &wine_vkCreateDebugReportCallbackEXT},
{"vkCreateDebugUtilsMessengerEXT", &wine_vkCreateDebugUtilsMessengerEXT},
{"vkCreateDevice", &wine_vkCreateDevice},
{"vkCreateWin32SurfaceKHR", &wine_vkCreateWin32SurfaceKHR},
{"vkDebugReportMessageEXT", &wine_vkDebugReportMessageEXT},
{"vkDestroyDebugReportCallbackEXT", &wine_vkDestroyDebugReportCallbackEXT},
{"vkDestroyDebugUtilsMessengerEXT", &wine_vkDestroyDebugUtilsMessengerEXT},
{"vkDestroyInstance", &wine_vkDestroyInstance},
{"vkDestroySurfaceKHR", &wine_vkDestroySurfaceKHR},
{"vkEnumerateDeviceExtensionProperties", &wine_vkEnumerateDeviceExtensionProperties},
{"vkEnumerateDeviceLayerProperties", &wine_vkEnumerateDeviceLayerProperties},
{"vkEnumeratePhysicalDeviceGroups", &wine_vkEnumeratePhysicalDeviceGroups},
{"vkEnumeratePhysicalDeviceGroupsKHR", &wine_vkEnumeratePhysicalDeviceGroupsKHR},
{"vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR", &wine_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR},
{"vkEnumeratePhysicalDevices", &wine_vkEnumeratePhysicalDevices},
{"vkGetPhysicalDeviceCalibrateableTimeDomainsEXT", &wine_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT},
{"vkGetPhysicalDeviceCooperativeMatrixPropertiesNV", &wine_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV},
{"vkGetPhysicalDeviceExternalBufferProperties", &wine_vkGetPhysicalDeviceExternalBufferProperties},
......@@ -7335,6 +7324,21 @@ static const struct vulkan_func vk_instance_dispatch_table[] =
{"vkGetPhysicalDeviceSurfaceSupportKHR", &wine_vkGetPhysicalDeviceSurfaceSupportKHR},
{"vkGetPhysicalDeviceToolPropertiesEXT", &wine_vkGetPhysicalDeviceToolPropertiesEXT},
{"vkGetPhysicalDeviceWin32PresentationSupportKHR", &wine_vkGetPhysicalDeviceWin32PresentationSupportKHR},
};
static const struct vulkan_func vk_instance_dispatch_table[] =
{
{"vkCreateDebugReportCallbackEXT", &wine_vkCreateDebugReportCallbackEXT},
{"vkCreateDebugUtilsMessengerEXT", &wine_vkCreateDebugUtilsMessengerEXT},
{"vkCreateWin32SurfaceKHR", &wine_vkCreateWin32SurfaceKHR},
{"vkDebugReportMessageEXT", &wine_vkDebugReportMessageEXT},
{"vkDestroyDebugReportCallbackEXT", &wine_vkDestroyDebugReportCallbackEXT},
{"vkDestroyDebugUtilsMessengerEXT", &wine_vkDestroyDebugUtilsMessengerEXT},
{"vkDestroyInstance", &wine_vkDestroyInstance},
{"vkDestroySurfaceKHR", &wine_vkDestroySurfaceKHR},
{"vkEnumeratePhysicalDeviceGroups", &wine_vkEnumeratePhysicalDeviceGroups},
{"vkEnumeratePhysicalDeviceGroupsKHR", &wine_vkEnumeratePhysicalDeviceGroupsKHR},
{"vkEnumeratePhysicalDevices", &wine_vkEnumeratePhysicalDevices},
{"vkSubmitDebugUtilsMessageEXT", &wine_vkSubmitDebugUtilsMessageEXT},
};
......@@ -7352,6 +7356,20 @@ void *wine_vk_get_device_proc_addr(const char *name)
return NULL;
}
void *wine_vk_get_phys_dev_proc_addr(const char *name)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(vk_phys_dev_dispatch_table); i++)
{
if (strcmp(vk_phys_dev_dispatch_table[i].name, name) == 0)
{
TRACE("Found name=%s in physical device table\n", debugstr_a(name));
return vk_phys_dev_dispatch_table[i].func;
}
}
return NULL;
}
void *wine_vk_get_instance_proc_addr(const char *name)
{
unsigned int i;
......
......@@ -2036,18 +2036,23 @@ struct vulkan_instance_funcs
{
VkResult (*p_vkCreateDebugReportCallbackEXT)(VkInstance, const VkDebugReportCallbackCreateInfoEXT *, const VkAllocationCallbacks *, VkDebugReportCallbackEXT *);
VkResult (*p_vkCreateDebugUtilsMessengerEXT)(VkInstance, const VkDebugUtilsMessengerCreateInfoEXT *, const VkAllocationCallbacks *, VkDebugUtilsMessengerEXT *);
VkResult (*p_vkCreateDevice)(VkPhysicalDevice, const VkDeviceCreateInfo *, const VkAllocationCallbacks *, VkDevice *);
VkResult (*p_vkCreateWin32SurfaceKHR)(VkInstance, const VkWin32SurfaceCreateInfoKHR *, const VkAllocationCallbacks *, VkSurfaceKHR *);
void (*p_vkDebugReportMessageEXT)(VkInstance, VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char *, const char *);
void (*p_vkDestroyDebugReportCallbackEXT)(VkInstance, VkDebugReportCallbackEXT, const VkAllocationCallbacks *);
void (*p_vkDestroyDebugUtilsMessengerEXT)(VkInstance, VkDebugUtilsMessengerEXT, const VkAllocationCallbacks *);
void (*p_vkDestroySurfaceKHR)(VkInstance, VkSurfaceKHR, const VkAllocationCallbacks *);
VkResult (*p_vkEnumerateDeviceExtensionProperties)(VkPhysicalDevice, const char *, uint32_t *, VkExtensionProperties *);
VkResult (*p_vkEnumerateDeviceLayerProperties)(VkPhysicalDevice, uint32_t *, VkLayerProperties *);
VkResult (*p_vkEnumeratePhysicalDeviceGroups)(VkInstance, uint32_t *, VkPhysicalDeviceGroupProperties *);
VkResult (*p_vkEnumeratePhysicalDeviceGroupsKHR)(VkInstance, uint32_t *, VkPhysicalDeviceGroupProperties *);
VkResult (*p_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR)(VkPhysicalDevice, uint32_t, uint32_t *, VkPerformanceCounterKHR *, VkPerformanceCounterDescriptionKHR *);
VkResult (*p_vkEnumeratePhysicalDevices)(VkInstance, uint32_t *, VkPhysicalDevice *);
#if defined(USE_STRUCT_CONVERSION)
void (*p_vkSubmitDebugUtilsMessageEXT)(VkInstance, VkDebugUtilsMessageSeverityFlagBitsEXT, VkDebugUtilsMessageTypeFlagsEXT, const VkDebugUtilsMessengerCallbackDataEXT_host *);
#else
void (*p_vkSubmitDebugUtilsMessageEXT)(VkInstance, VkDebugUtilsMessageSeverityFlagBitsEXT, VkDebugUtilsMessageTypeFlagsEXT, const VkDebugUtilsMessengerCallbackDataEXT *);
#endif
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_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR)(VkPhysicalDevice, uint32_t, uint32_t *, VkPerformanceCounterKHR *, VkPerformanceCounterDescriptionKHR *);
VkResult (*p_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT)(VkPhysicalDevice, uint32_t *, VkTimeDomainEXT *);
VkResult (*p_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV)(VkPhysicalDevice, uint32_t *, VkCooperativeMatrixPropertiesNV *);
void (*p_vkGetPhysicalDeviceFeatures)(VkPhysicalDevice, VkPhysicalDeviceFeatures *);
......@@ -2128,11 +2133,6 @@ struct vulkan_instance_funcs
VkResult (*p_vkGetPhysicalDeviceSurfaceSupportKHR)(VkPhysicalDevice, uint32_t, VkSurfaceKHR, VkBool32 *);
VkResult (*p_vkGetPhysicalDeviceToolPropertiesEXT)(VkPhysicalDevice, uint32_t *, VkPhysicalDeviceToolPropertiesEXT *);
VkBool32 (*p_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice, uint32_t);
#if defined(USE_STRUCT_CONVERSION)
void (*p_vkSubmitDebugUtilsMessageEXT)(VkInstance, VkDebugUtilsMessageSeverityFlagBitsEXT, VkDebugUtilsMessageTypeFlagsEXT, const VkDebugUtilsMessengerCallbackDataEXT_host *);
#else
void (*p_vkSubmitDebugUtilsMessageEXT)(VkInstance, VkDebugUtilsMessageSeverityFlagBitsEXT, VkDebugUtilsMessageTypeFlagsEXT, const VkDebugUtilsMessengerCallbackDataEXT *);
#endif
};
#define ALL_VK_DEVICE_FUNCS() \
......@@ -2464,18 +2464,19 @@ struct vulkan_instance_funcs
#define ALL_VK_INSTANCE_FUNCS() \
USE_VK_FUNC(vkCreateDebugReportCallbackEXT) \
USE_VK_FUNC(vkCreateDebugUtilsMessengerEXT) \
USE_VK_FUNC(vkCreateDevice) \
USE_VK_FUNC(vkCreateWin32SurfaceKHR) \
USE_VK_FUNC(vkDebugReportMessageEXT) \
USE_VK_FUNC(vkDestroyDebugReportCallbackEXT) \
USE_VK_FUNC(vkDestroyDebugUtilsMessengerEXT) \
USE_VK_FUNC(vkDestroySurfaceKHR) \
USE_VK_FUNC(vkEnumerateDeviceExtensionProperties) \
USE_VK_FUNC(vkEnumerateDeviceLayerProperties) \
USE_VK_FUNC(vkEnumeratePhysicalDeviceGroups) \
USE_VK_FUNC(vkEnumeratePhysicalDeviceGroupsKHR) \
USE_VK_FUNC(vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR) \
USE_VK_FUNC(vkEnumeratePhysicalDevices) \
USE_VK_FUNC(vkSubmitDebugUtilsMessageEXT) \
USE_VK_FUNC(vkCreateDevice) \
USE_VK_FUNC(vkEnumerateDeviceExtensionProperties) \
USE_VK_FUNC(vkEnumerateDeviceLayerProperties) \
USE_VK_FUNC(vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR) \
USE_VK_FUNC(vkGetPhysicalDeviceCalibrateableTimeDomainsEXT) \
USE_VK_FUNC(vkGetPhysicalDeviceCooperativeMatrixPropertiesNV) \
USE_VK_FUNC(vkGetPhysicalDeviceFeatures) \
......@@ -2511,7 +2512,6 @@ struct vulkan_instance_funcs
USE_VK_FUNC(vkGetPhysicalDeviceSurfacePresentModesKHR) \
USE_VK_FUNC(vkGetPhysicalDeviceSurfaceSupportKHR) \
USE_VK_FUNC(vkGetPhysicalDeviceToolPropertiesEXT) \
USE_VK_FUNC(vkGetPhysicalDeviceWin32PresentationSupportKHR) \
USE_VK_FUNC(vkSubmitDebugUtilsMessageEXT)
USE_VK_FUNC(vkGetPhysicalDeviceWin32PresentationSupportKHR)
#endif /* __WINE_VULKAN_THUNKS_H */
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