Commit f226540e authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Do not use a staging buffer if discarding a mappable buffer in…

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: 's avatarZebediah Figura <z.figura12@gmail.com> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 783c850d
...@@ -1007,6 +1007,7 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context, ...@@ -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; struct wined3d_bo_vk staging_bo, *src_bo, *dst_bo;
VkAccessFlags src_access_mask, dst_access_mask; VkAccessFlags src_access_mask, dst_access_mask;
VkBufferMemoryBarrier vk_barrier[2]; VkBufferMemoryBarrier vk_barrier[2];
DWORD map_flags = WINED3D_MAP_WRITE;
struct wined3d_bo_address staging; struct wined3d_bo_address staging;
VkCommandBuffer vk_command_buffer; VkCommandBuffer vk_command_buffer;
struct wined3d_range range; struct wined3d_range range;
...@@ -1016,6 +1017,9 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context, ...@@ -1016,6 +1017,9 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context,
src_bo = (struct wined3d_bo_vk *)src->buffer_object; src_bo = (struct wined3d_bo_vk *)src->buffer_object;
dst_bo = (struct wined3d_bo_vk *)dst->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 (src_bo && dst_bo)
{ {
if (!(vk_command_buffer = wined3d_context_vk_get_command_buffer(context_vk))) 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, ...@@ -1092,8 +1096,8 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context,
return; return;
} }
if (dst_bo && (dst_bo->command_buffer_id > context_vk->completed_command_buffer_id if (dst_bo && (!(dst_bo->memory_type & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) || (!(map_flags & WINED3D_MAP_DISCARD)
|| !(dst_bo->memory_type & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT))) && 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, if (!(wined3d_context_vk_create_bo(context_vk, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &staging_bo))) VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &staging_bo)))
...@@ -1113,7 +1117,7 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context, ...@@ -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); 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); memcpy(dst_ptr, src_ptr, size);
......
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