From f226540ee254ff1da61705a2eea320b7ef01d639 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Fri, 18 Jun 2021 11:13:28 -0500 Subject: [PATCH] wined3d: Do not use a staging buffer if discarding a mappable buffer in adapter_vk_copy_bo_address(). As in wined3d_buffer_vk_upload_ranges(). Signed-off-by: Zebediah Figura Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/adapter_vk.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 9f36ee39080..850e2a6dfdb 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -1007,6 +1007,7 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context, struct wined3d_bo_vk staging_bo, *src_bo, *dst_bo; VkAccessFlags src_access_mask, dst_access_mask; VkBufferMemoryBarrier vk_barrier[2]; + DWORD map_flags = WINED3D_MAP_WRITE; struct wined3d_bo_address staging; VkCommandBuffer vk_command_buffer; struct wined3d_range range; @@ -1016,6 +1017,9 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context, src_bo = (struct wined3d_bo_vk *)src->buffer_object; dst_bo = (struct wined3d_bo_vk *)dst->buffer_object; + if (dst_bo && !dst->addr && size == dst_bo->size) + map_flags |= WINED3D_MAP_DISCARD; + if (src_bo && dst_bo) { if (!(vk_command_buffer = wined3d_context_vk_get_command_buffer(context_vk))) @@ -1092,8 +1096,8 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context, return; } - if (dst_bo && (dst_bo->command_buffer_id > context_vk->completed_command_buffer_id - || !(dst_bo->memory_type & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT))) + if (dst_bo && (!(dst_bo->memory_type & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) || (!(map_flags & WINED3D_MAP_DISCARD) + && dst_bo->command_buffer_id > context_vk->completed_command_buffer_id))) { if (!(wined3d_context_vk_create_bo(context_vk, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &staging_bo))) @@ -1113,7 +1117,7 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context, } src_ptr = adapter_vk_map_bo_address(context, src, size, WINED3D_MAP_READ); - dst_ptr = adapter_vk_map_bo_address(context, dst, size, WINED3D_MAP_WRITE); + dst_ptr = adapter_vk_map_bo_address(context, dst, size, map_flags); memcpy(dst_ptr, src_ptr, size);