[PATCH] wined3d: Select physical device with highest apiVersion.

Joshua Ashton joshua at froggi.es
Mon Jan 25 10:23:34 CST 2021


This is a bad idea, and having a fixed set of 16 physical devices is 
also a bad idea.

Regards,
- Joshie 🐸✨

On 1/25/21 4:03 PM, Jan Sikorski wrote:
> Signed-off-by: Jan Sikorski <jsikorski at codeweavers.com>
> ---
>   dlls/wined3d/adapter_vk.c | 19 +++++++++++++++----
>   1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c
> index 9a226edc65a..11f7db44370 100644
> --- a/dlls/wined3d/adapter_vk.c
> +++ b/dlls/wined3d/adapter_vk.c
> @@ -1980,8 +1980,8 @@ fail:
>   
>   static VkPhysicalDevice get_vulkan_physical_device(struct wined3d_vk_info *vk_info)
>   {
> -    VkPhysicalDevice physical_devices[1];
> -    uint32_t count;
> +    VkPhysicalDevice physical_devices[16];
> +    uint32_t count, selected = 0, i, best_api_version = 0;
>       VkResult vr;
>   
>       if ((vr = VK_CALL(vkEnumeratePhysicalDevices(vk_info->instance, &count, NULL))) < 0)
> @@ -1998,7 +1998,8 @@ static VkPhysicalDevice get_vulkan_physical_device(struct wined3d_vk_info *vk_in
>       {
>           /* TODO: Create wined3d_adapter for each device. */
>           FIXME("Multiple physical devices available.\n");
> -        count = 1;
> +        if (count > ARRAY_SIZE(physical_devices))
> +            count = ARRAY_SIZE(physical_devices);
>       }
>   
>       if ((vr = VK_CALL(vkEnumeratePhysicalDevices(vk_info->instance, &count, physical_devices))) < 0)
> @@ -2007,7 +2008,17 @@ static VkPhysicalDevice get_vulkan_physical_device(struct wined3d_vk_info *vk_in
>           return VK_NULL_HANDLE;
>       }
>   
> -    return physical_devices[0];
> +    for (i = 0; i < count; ++i)
> +    {
> +        VkPhysicalDeviceProperties properties;
> +        VK_CALL(vkGetPhysicalDeviceProperties(physical_devices[i], &properties));
> +        if (properties.apiVersion > best_api_version) {
> +            selected = i;
> +            best_api_version = properties.apiVersion;
> +        }
> +    }
> +
> +    return physical_devices[selected];
>   }
>   
>   static enum wined3d_display_driver guess_display_driver(enum wined3d_pci_vendor vendor)
> 



More information about the wine-devel mailing list