Instead of comparing the requested memory type against what we actually got. For example, we may have gotten coherent memory without having explicitly requested it, in which case wined3d_context_vk_create_slab_bo() would fail to find an existing slab to allocate from.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- This fixes a rather atrocious VRAM leak with some allocation patterns on some configurations. I don't think we have any explicit bug reports about this, but it affects for example the menu in Batman: Arkham Origins.
dlls/wined3d/context_vk.c | 7 ++++--- dlls/wined3d/wined3d_private.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c index f1258842152..66f5109dc87 100644 --- a/dlls/wined3d/context_vk.c +++ b/dlls/wined3d/context_vk.c @@ -371,6 +371,7 @@ static bool wined3d_context_vk_create_slab_bo(struct wined3d_context_vk *context return false; }
+ slab->requested_memory_type = memory_type; if (!wined3d_context_vk_create_bo(context_vk, key.size, usage, memory_type, &slab->bo)) { ERR("Failed to create slab bo.\n"); @@ -625,7 +626,7 @@ static void wined3d_bo_slab_vk_free_slice(struct wined3d_bo_slab_vk *slab,
if (!slab->map) { - key.memory_type = slab->bo.memory_type; + key.memory_type = slab->requested_memory_type; key.usage = slab->bo.usage; key.size = slab->bo.size;
@@ -1677,8 +1678,8 @@ static int wined3d_bo_slab_vk_compare(const void *key, const struct wine_rb_entr const struct wined3d_bo_slab_vk *slab = WINE_RB_ENTRY_VALUE(entry, const struct wined3d_bo_slab_vk, entry); const struct wined3d_bo_slab_vk_key *k = key;
- if (k->memory_type != slab->bo.memory_type) - return k->memory_type - slab->bo.memory_type; + if (k->memory_type != slab->requested_memory_type) + return k->memory_type - slab->requested_memory_type; if (k->usage != slab->bo.usage) return k->usage - slab->bo.usage; return k->size - slab->bo.size; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index cf1a0bb0668..30b21a8225f 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1626,6 +1626,7 @@ struct wined3d_bo_slab_vk { struct wine_rb_entry entry; struct wined3d_bo_slab_vk *next; + VkMemoryPropertyFlags requested_memory_type; struct wined3d_bo_vk bo; unsigned int map_count; void *map_ptr;