Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/wined3d/adapter_vk.c | 41 +++++++++++++++++++++++++--------- dlls/wined3d/context_vk.c | 9 +++++--- dlls/wined3d/wined3d_private.h | 5 +++++ 3 files changed, 42 insertions(+), 13 deletions(-)
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 4e804b60502..0404aa1877b 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -772,12 +772,11 @@ static void *wined3d_bo_vk_map(struct wined3d_bo_vk *bo, struct wined3d_context_
if ((slab = bo->slab)) { - if (!(bo->map_ptr = slab->map_ptr) && !(bo->map_ptr = wined3d_bo_vk_map(&slab->bo, context_vk))) + if (!(bo->map_ptr = wined3d_bo_slab_vk_map(slab, context_vk))) { ERR("Failed to map slab.\n"); return NULL; } - ++slab->map_count; } else if (bo->memory) { @@ -811,21 +810,43 @@ static void wined3d_bo_vk_unmap(struct wined3d_bo_vk *bo, struct wined3d_context
if ((slab = bo->slab)) { - if (--slab->map_count) - return; + wined3d_bo_slab_vk_unmap(slab, context_vk); + return; + }
- wined3d_bo_vk_unmap(&slab->bo, context_vk); - slab->map_ptr = NULL; + if (bo->memory) + { + wined3d_allocator_chunk_vk_unmap(wined3d_allocator_chunk_vk(bo->memory->chunk), context_vk); return; }
vk_info = context_vk->vk_info; device_vk = wined3d_device_vk(context_vk->c.device); + VK_CALL(vkUnmapMemory(device_vk->vk_device, bo->vk_memory)); +}
- if (bo->memory) - wined3d_allocator_chunk_vk_unmap(wined3d_allocator_chunk_vk(bo->memory->chunk), context_vk); - else - VK_CALL(vkUnmapMemory(device_vk->vk_device, bo->vk_memory)); +void *wined3d_bo_slab_vk_map(struct wined3d_bo_slab_vk *slab_vk, struct wined3d_context_vk *context_vk) +{ + TRACE("slab_vk %p, context_vk %p.\n", slab_vk, context_vk); + + if (!slab_vk->map_ptr && !(slab_vk->map_ptr = wined3d_bo_vk_map(&slab_vk->bo, context_vk))) + { + ERR("Failed to map slab.\n"); + return NULL; + } + + ++slab_vk->map_count; + + return slab_vk->map_ptr; +} + +void wined3d_bo_slab_vk_unmap(struct wined3d_bo_slab_vk *slab_vk, struct wined3d_context_vk *context_vk) +{ + if (--slab_vk->map_count) + return; + + wined3d_bo_vk_unmap(&slab_vk->bo, context_vk); + slab_vk->map_ptr = NULL; }
static VkAccessFlags vk_access_mask_from_buffer_usage(VkBufferUsageFlags usage) diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c index bd3dc50ab01..9db363172f1 100644 --- a/dlls/wined3d/context_vk.c +++ b/dlls/wined3d/context_vk.c @@ -797,15 +797,18 @@ void wined3d_context_vk_destroy_bo(struct wined3d_context_vk *context_vk, const { struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device); const struct wined3d_vk_info *vk_info = context_vk->vk_info; + struct wined3d_bo_slab_vk *slab_vk; size_t object_size, idx;
TRACE("context_vk %p, bo %p.\n", context_vk, bo);
- if (bo->slab) + if ((slab_vk = bo->slab)) { - object_size = bo->slab->bo.size / 32; + if (bo->map_ptr) + wined3d_bo_slab_vk_unmap(slab_vk, context_vk); + object_size = slab_vk->bo.size / 32; idx = bo->buffer_offset / object_size; - wined3d_context_vk_destroy_bo_slab_slice(context_vk, bo->slab, idx, bo->command_buffer_id); + wined3d_context_vk_destroy_bo_slab_slice(context_vk, slab_vk, idx, bo->command_buffer_id); return; }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index f48778ee345..0749f95f998 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1633,6 +1633,11 @@ struct wined3d_bo_slab_vk uint32_t map; };
+void *wined3d_bo_slab_vk_map(struct wined3d_bo_slab_vk *slab_vk, + struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN; +void wined3d_bo_slab_vk_unmap(struct wined3d_bo_slab_vk *slab_vk, + struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN; + struct wined3d_bo_address { UINT_PTR buffer_object;