[PATCH v2 1/2] wined3d: Negiotiate less specific memory types on allocation failure.

Henri Verbeet hverbeet at gmail.com
Tue Aug 3 09:46:51 CDT 2021


On Fri, 30 Jul 2021 at 17:09, Jan Sikorski <jsikorski at codeweavers.com> wrote:
> @@ -1410,14 +1411,22 @@ static BOOL wined3d_buffer_vk_create_buffer_object(struct wined3d_buffer_vk *buf
>          FIXME("Ignoring some bind flags %#x.\n", bind_flags);
>
>      memory_type = 0;
> +    if (!(resource->usage & WINED3DUSAGE_DYNAMIC))
> +        memory_type |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
>      if (resource->access & WINED3D_RESOURCE_ACCESS_MAP_R)
>          memory_type |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
>      else if (resource->access & WINED3D_RESOURCE_ACCESS_MAP_W)
>          memory_type |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
> -    else if (!(resource->usage & WINED3DUSAGE_DYNAMIC))
> -        memory_type |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
>
> -    if (!(wined3d_context_vk_create_bo(context_vk, resource->size, usage, memory_type, &buffer_vk->bo)))
> +    success = wined3d_context_vk_create_bo(context_vk, resource->size, usage, memory_type, &buffer_vk->bo);
> +    if (!success && memory_type & VK_MEMORY_PROPERTY_HOST_CACHED_BIT)
> +        success = wined3d_context_vk_create_bo(context_vk, resource->size, usage,
> +                memory_type & ~VK_MEMORY_PROPERTY_HOST_CACHED_BIT, &buffer_vk->bo);
> +    if (!success && memory_type & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
> +        success = wined3d_context_vk_create_bo(context_vk, resource->size, usage,
> +                memory_type & ~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &buffer_vk->bo);
> +
> +    if (!success)
>      {
>          WARN("Failed to create Vulkan buffer.\n");
>          return FALSE;

I think this works, but it still feels a little unfortunate. The nice
thing about the vkd3d approach (using a list of acceptable memory
types) is that it would allow the failover to be mostly handled in
wined3d_context_vk_create_bo(), while at the same time making it very
clear which memory types are tried.



More information about the wine-devel mailing list