Commit b4e109f2 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Unmap the slab if needed in wined3d_context_vk_destroy_bo().

parent 9992d710
......@@ -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,23 +810,45 @@ static void wined3d_bo_vk_unmap(struct wined3d_bo_vk *bo, struct wined3d_context
if ((slab = bo->slab))
{
if (--slab->map_count)
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);
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)
{
VkAccessFlags flags = 0;
......
......@@ -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;
}
......
......@@ -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;
......
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