Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/buffer.c | 12 ++++++++++++ dlls/wined3d/wined3d_private.h | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 902ab720396..bb8f9753468 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -37,6 +37,18 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); #define VB_MAXFULLCONVERSIONS 5 /* Number of full conversions before we stop converting */ #define VB_RESETFULLCONVS 20 /* Reset full conversion counts after that number of draws */
+struct wined3d_buffer_ops +{ + BOOL (*buffer_prepare_location)(struct wined3d_buffer *buffer, + struct wined3d_context *context, unsigned int location); + void (*buffer_unload_location)(struct wined3d_buffer *buffer, + struct wined3d_context *context, unsigned int location); + void (*buffer_upload_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, const void *data, + unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges); + void (*buffer_download_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, void *data, + unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges); +}; + static void wined3d_buffer_evict_sysmem(struct wined3d_buffer *buffer) { if (buffer->flags & WINED3D_BUFFER_PIN_SYSMEM) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index d0e4f0cdfaf..51a7c2ffb10 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -5122,18 +5122,6 @@ enum wined3d_buffer_conversion_type CONV_POSITIONT, };
-struct wined3d_buffer_ops -{ - BOOL (*buffer_prepare_location)(struct wined3d_buffer *buffer, - struct wined3d_context *context, unsigned int location); - void (*buffer_unload_location)(struct wined3d_buffer *buffer, - struct wined3d_context *context, unsigned int location); - void (*buffer_upload_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, const void *data, - unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges); - void (*buffer_download_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, void *data, - unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges); -}; - struct wined3d_buffer { struct wined3d_resource resource;
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/adapter_gl.c | 5 +- dlls/wined3d/adapter_vk.c | 84 ++++++++++++++++++++-------------- dlls/wined3d/buffer.c | 27 ++++------- dlls/wined3d/context_gl.c | 39 ++++++++++------ dlls/wined3d/directx.c | 9 +++- dlls/wined3d/texture.c | 6 ++- dlls/wined3d/view.c | 10 +++- dlls/wined3d/wined3d_private.h | 14 ++++-- 8 files changed, 114 insertions(+), 80 deletions(-)
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c index e903c67b56a..2e31d140dd5 100644 --- a/dlls/wined3d/adapter_gl.c +++ b/dlls/wined3d/adapter_gl.c @@ -4597,9 +4597,10 @@ static void adapter_gl_unmap_bo_address(struct wined3d_context *context, }
static void adapter_gl_copy_bo_address(struct wined3d_context *context, - const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) + const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, + unsigned int range_count, const struct wined3d_range *ranges) { - wined3d_context_gl_copy_bo_address(wined3d_context_gl(context), dst, src, size); + wined3d_context_gl_copy_bo_address(wined3d_context_gl(context), dst, src, range_count, ranges); }
static void adapter_gl_flush_bo_address(struct wined3d_context *context, diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 239cd7cca8d..9b9b399a810 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -1095,7 +1095,8 @@ static void adapter_vk_unmap_bo_address(struct wined3d_context *context, }
void adapter_vk_copy_bo_address(struct wined3d_context *context, - const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) + const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, + unsigned int range_count, const struct wined3d_range *ranges) { struct wined3d_context_vk *context_vk = wined3d_context_vk(context); const struct wined3d_vk_info *vk_info = context_vk->vk_info; @@ -1103,16 +1104,18 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context, VkAccessFlags src_access_mask, dst_access_mask; VkBufferMemoryBarrier vk_barrier[2]; DWORD map_flags = WINED3D_MAP_WRITE; + const struct wined3d_range *range; struct wined3d_bo_address staging; VkCommandBuffer vk_command_buffer; - struct wined3d_range range; - void *dst_ptr, *src_ptr; + uint8_t *dst_ptr, *src_ptr; VkBufferCopy region; + size_t size = 0; + unsigned int i;
src_bo = src->buffer_object ? wined3d_bo_vk(src->buffer_object) : NULL; dst_bo = dst->buffer_object ? wined3d_bo_vk(dst->buffer_object) : NULL;
- if (dst_bo && !dst->addr && size == dst_bo->size) + if (dst_bo && !dst->addr && !ranges->offset && ranges->size == dst_bo->size) map_flags |= WINED3D_MAP_DISCARD;
if (src_bo && dst_bo) @@ -1128,43 +1131,52 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context, src_access_mask = vk_access_mask_from_buffer_usage(src_bo->usage); dst_access_mask = vk_access_mask_from_buffer_usage(dst_bo->usage);
- region.srcOffset = src_bo->b.buffer_offset + (uintptr_t)src->addr; - region.dstOffset = dst_bo->b.buffer_offset + (uintptr_t)dst->addr; - region.size = size; - vk_barrier[0].sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; vk_barrier[0].pNext = NULL; - vk_barrier[0].srcAccessMask = src_access_mask; - vk_barrier[0].dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; vk_barrier[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; vk_barrier[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; vk_barrier[0].buffer = src_bo->vk_buffer; - vk_barrier[0].offset = region.srcOffset; - vk_barrier[0].size = region.size;
vk_barrier[1].sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; vk_barrier[1].pNext = NULL; - vk_barrier[1].srcAccessMask = dst_access_mask; - vk_barrier[1].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; vk_barrier[1].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; vk_barrier[1].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; vk_barrier[1].buffer = dst_bo->vk_buffer; - vk_barrier[1].offset = region.dstOffset; - vk_barrier[1].size = region.size;
- VK_CALL(vkCmdPipelineBarrier(vk_command_buffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, - VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 2, vk_barrier, 0, NULL)); + for (i = 0; i < range_count; ++i) + { + range = &ranges[i];
- VK_CALL(vkCmdCopyBuffer(vk_command_buffer, src_bo->vk_buffer, dst_bo->vk_buffer, 1, ®ion)); + region.srcOffset = src_bo->b.buffer_offset + (uintptr_t)src->addr + range->offset; + region.dstOffset = dst_bo->b.buffer_offset + (uintptr_t)dst->addr + range->offset; + region.size = range->size;
- vk_barrier[0].srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; - vk_barrier[0].dstAccessMask = src_access_mask; + vk_barrier[0].offset = region.srcOffset; + vk_barrier[0].size = region.size;
- vk_barrier[1].srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - vk_barrier[1].dstAccessMask = dst_access_mask; + vk_barrier[1].offset = region.dstOffset; + vk_barrier[1].size = region.size;
- VK_CALL(vkCmdPipelineBarrier(vk_command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, - VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 2, vk_barrier, 0, NULL)); + vk_barrier[0].srcAccessMask = src_access_mask; + vk_barrier[0].dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; + + vk_barrier[1].srcAccessMask = dst_access_mask; + vk_barrier[1].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + + VK_CALL(vkCmdPipelineBarrier(vk_command_buffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, + VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 2, vk_barrier, 0, NULL)); + + VK_CALL(vkCmdCopyBuffer(vk_command_buffer, src_bo->vk_buffer, dst_bo->vk_buffer, 1, ®ion)); + + vk_barrier[0].srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; + vk_barrier[0].dstAccessMask = src_access_mask; + + vk_barrier[1].srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + vk_barrier[1].dstAccessMask = dst_access_mask; + + VK_CALL(vkCmdPipelineBarrier(vk_command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 2, vk_barrier, 0, NULL)); + }
wined3d_context_vk_reference_bo(context_vk, src_bo); wined3d_context_vk_reference_bo(context_vk, dst_bo); @@ -1174,7 +1186,7 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context,
if (src_bo && !(src_bo->memory_type & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) { - if (!(wined3d_context_vk_create_bo(context_vk, size, VK_BUFFER_USAGE_TRANSFER_DST_BIT, + if (!(wined3d_context_vk_create_bo(context_vk, src_bo->size, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &staging_bo))) { ERR("Failed to create staging bo.\n"); @@ -1183,8 +1195,8 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context,
staging.buffer_object = &staging_bo.b; staging.addr = NULL; - adapter_vk_copy_bo_address(context, &staging, src, size); - adapter_vk_copy_bo_address(context, dst, &staging, size); + adapter_vk_copy_bo_address(context, &staging, src, range_count, ranges); + adapter_vk_copy_bo_address(context, dst, &staging, range_count, ranges);
wined3d_context_vk_destroy_bo(context_vk, &staging_bo);
@@ -1194,7 +1206,7 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context, 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, + if (!(wined3d_context_vk_create_bo(context_vk, dst_bo->size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &staging_bo))) { ERR("Failed to create staging bo.\n"); @@ -1203,22 +1215,24 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context,
staging.buffer_object = &staging_bo.b; staging.addr = NULL; - adapter_vk_copy_bo_address(context, &staging, src, size); - adapter_vk_copy_bo_address(context, dst, &staging, size); + adapter_vk_copy_bo_address(context, &staging, src, range_count, ranges); + adapter_vk_copy_bo_address(context, dst, &staging, range_count, ranges);
wined3d_context_vk_destroy_bo(context_vk, &staging_bo);
return; }
+ for (i = 0; i < range_count; ++i) + size = max(size, ranges[i].offset + ranges[i].size); + src_ptr = adapter_vk_map_bo_address(context, src, size, WINED3D_MAP_READ); dst_ptr = adapter_vk_map_bo_address(context, dst, size, map_flags);
- memcpy(dst_ptr, src_ptr, size); + for (i = 0; i < range_count; ++i) + memcpy(dst_ptr + ranges[i].offset, src_ptr + ranges[i].offset, ranges[i].size);
- range.offset = 0; - range.size = size; - adapter_vk_unmap_bo_address(context, dst, 1, &range); + adapter_vk_unmap_bo_address(context, dst, range_count, ranges); adapter_vk_unmap_bo_address(context, src, 0, NULL); }
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index bb8f9753468..cc5b7bf6c33 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1128,12 +1128,15 @@ void wined3d_buffer_copy_bo_address(struct wined3d_buffer *dst_buffer, struct wi unsigned int dst_offset, const struct wined3d_const_bo_address *src_addr, unsigned int size) { struct wined3d_bo_address dst_addr; + struct wined3d_range range; DWORD dst_location;
dst_location = wined3d_buffer_get_memory(dst_buffer, context, &dst_addr); dst_addr.addr += dst_offset;
- wined3d_context_copy_bo_address(context, &dst_addr, (const struct wined3d_bo_address *)src_addr, size); + range.offset = 0; + range.size = size; + wined3d_context_copy_bo_address(context, &dst_addr, (const struct wined3d_bo_address *)src_addr, 1, &range); wined3d_buffer_invalidate_range(dst_buffer, ~dst_location, dst_offset, size); }
@@ -1426,16 +1429,11 @@ static void wined3d_buffer_gl_upload_ranges(struct wined3d_buffer *buffer, struc buffer, context, data, data_offset, range_count, ranges);
dst.buffer_object = buffer->buffer_object; + dst.addr = 0; src.buffer_object = NULL; + src.addr = (uint8_t *)data - data_offset;
- while (range_count--) - { - const struct wined3d_range *range = &ranges[range_count]; - - src.addr = (uint8_t *)data + range->offset - data_offset; - dst.addr = (void *)(uintptr_t)range->offset; - wined3d_context_copy_bo_address(context, &dst, &src, range->size); - } + wined3d_context_copy_bo_address(context, &dst, &src, range_count, ranges); }
/* Context activation is done by the caller. */ @@ -1644,15 +1642,8 @@ static void wined3d_buffer_vk_upload_ranges(struct wined3d_buffer *buffer, struc && dst_bo->command_buffer_id > context_vk->completed_command_buffer_id)) { src.buffer_object = 0; - while (range_count--) - { - range = &ranges[range_count]; - - src.addr = (uint8_t *)data + range->offset - data_offset; - dst.addr = (void *)(uintptr_t)range->offset; - wined3d_context_copy_bo_address(context, &dst, &src, range->size); - } - + src.addr = (uint8_t *)data - data_offset; + wined3d_context_copy_bo_address(context, &dst, &src, range_count, ranges); return; }
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 23bac4de133..77e0379ee61 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -3057,12 +3057,13 @@ void wined3d_context_gl_flush_bo_address(struct wined3d_context_gl *context_gl, }
void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl, - const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) + const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, + unsigned int range_count, const struct wined3d_range *ranges) { const struct wined3d_gl_info *gl_info; struct wined3d_bo_gl *src_bo, *dst_bo; - struct wined3d_range range; BYTE *dst_ptr, *src_ptr; + unsigned int i;
gl_info = context_gl->gl_info; src_bo = src->buffer_object ? wined3d_bo_gl(src->buffer_object) : NULL; @@ -3074,9 +3075,11 @@ void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl, { GL_EXTCALL(glBindBuffer(GL_COPY_READ_BUFFER, src_bo->id)); GL_EXTCALL(glBindBuffer(GL_COPY_WRITE_BUFFER, dst_bo->id)); - GL_EXTCALL(glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, - src_bo->b.buffer_offset + (GLintptr)src->addr, - dst_bo->b.buffer_offset + (GLintptr)dst->addr, size)); + + for (i = 0; i < range_count; ++i) + GL_EXTCALL(glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, + src_bo->b.buffer_offset + (GLintptr)src->addr + ranges[i].offset, + dst_bo->b.buffer_offset + (GLintptr)dst->addr + ranges[i].offset, ranges[i].size)); checkGLcall("direct buffer copy");
wined3d_context_gl_reference_bo(context_gl, src_bo); @@ -3084,21 +3087,25 @@ void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl, } else { - src_ptr = wined3d_context_gl_map_bo_address(context_gl, src, size, WINED3D_MAP_READ); - dst_ptr = wined3d_context_gl_map_bo_address(context_gl, dst, size, WINED3D_MAP_WRITE); + src_ptr = wined3d_context_gl_map_bo_address(context_gl, src, + src_bo->size - (uintptr_t)src->addr, WINED3D_MAP_READ); + dst_ptr = wined3d_context_gl_map_bo_address(context_gl, dst, + dst_bo->size - (uintptr_t)dst->addr, WINED3D_MAP_WRITE);
- memcpy(dst_ptr, src_ptr, size); + for (i = 0; i < range_count; ++i) + memcpy(dst_ptr + ranges[i].offset, src_ptr + ranges[i].offset, ranges[i].size);
- range.offset = 0; - range.size = size; - wined3d_context_gl_unmap_bo_address(context_gl, dst, 1, &range); + wined3d_context_gl_unmap_bo_address(context_gl, dst, range_count, ranges); wined3d_context_gl_unmap_bo_address(context_gl, src, 0, NULL); } } else if (!dst_bo && src_bo) { wined3d_context_gl_bind_bo(context_gl, src_bo->binding, src_bo->id); - GL_EXTCALL(glGetBufferSubData(src_bo->binding, src_bo->b.buffer_offset + (GLintptr)src->addr, size, dst->addr)); + for (i = 0; i < range_count; ++i) + GL_EXTCALL(glGetBufferSubData(src_bo->binding, + src_bo->b.buffer_offset + (GLintptr)src->addr + ranges[i].offset, + ranges[i].size, dst->addr + ranges[i].offset)); checkGLcall("buffer download");
wined3d_context_gl_reference_bo(context_gl, src_bo); @@ -3106,14 +3113,18 @@ void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl, else if (dst_bo && !src_bo) { wined3d_context_gl_bind_bo(context_gl, dst_bo->binding, dst_bo->id); - GL_EXTCALL(glBufferSubData(dst_bo->binding, dst_bo->b.buffer_offset + (GLintptr)dst->addr, size, src->addr)); + for (i = 0; i < range_count; ++i) + GL_EXTCALL(glBufferSubData(dst_bo->binding, + dst_bo->b.buffer_offset + (GLintptr)dst->addr + ranges[i].offset, + ranges[i].size, src->addr + ranges[i].offset)); checkGLcall("buffer upload");
wined3d_context_gl_reference_bo(context_gl, dst_bo); } else { - memcpy(dst->addr, src->addr, size); + for (i = 0; i < range_count; ++i) + memcpy(dst->addr + ranges[i].offset, src->addr + ranges[i].offset, ranges[i].size); } }
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 36ca1be5b79..3f9ccfb0670 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -2804,15 +2804,20 @@ static void adapter_no3d_unmap_bo_address(struct wined3d_context *context, }
static void adapter_no3d_copy_bo_address(struct wined3d_context *context, - const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) + const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, + unsigned int range_count, const struct wined3d_range *ranges) { + unsigned int i; + if (dst->buffer_object) ERR("Unsupported dst buffer object %p.\n", dst->buffer_object); if (src->buffer_object) ERR("Unsupported src buffer object %p.\n", src->buffer_object); if (dst->buffer_object || src->buffer_object) return; - memcpy(dst->addr, src->addr, size); + + for (i = 0; i < range_count; ++i) + memcpy(dst->addr + ranges[i].offset, src->addr + ranges[i].offset, ranges[i].size); }
static void adapter_no3d_flush_bo_address(struct wined3d_context *context, diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 34d76249084..e1f20887840 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -798,14 +798,16 @@ BOOL wined3d_texture_load_location(struct wined3d_texture *texture,
if ((location & wined3d_texture_sysmem_locations) && (current & wined3d_texture_sysmem_locations)) { - unsigned int size = texture->sub_resources[sub_resource_idx].size; struct wined3d_bo_address source, destination; + struct wined3d_range range;
if (!wined3d_texture_prepare_location(texture, sub_resource_idx, context, location)) return FALSE; wined3d_texture_get_memory(texture, sub_resource_idx, &source, current); wined3d_texture_get_memory(texture, sub_resource_idx, &destination, location); - wined3d_context_copy_bo_address(context, &destination, &source, size); + range.offset = 0; + range.size = texture->sub_resources[sub_resource_idx].size; + wined3d_context_copy_bo_address(context, &destination, &source, 1, &range); ret = TRUE; } else diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index 3b113a940a3..4483a21a6d0 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -1616,6 +1616,7 @@ void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_v { struct wined3d_bo_address dst, src; struct wined3d_context *context; + struct wined3d_range range;
if (!view->counter_bo) return; @@ -1628,7 +1629,9 @@ void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_v dst.buffer_object = view->counter_bo; dst.addr = NULL;
- wined3d_context_copy_bo_address(context, &dst, &src, sizeof(uint32_t)); + range.offset = 0; + range.size = sizeof(value); + wined3d_context_copy_bo_address(context, &dst, &src, 1, &range);
context_release(context); } @@ -1914,6 +1917,7 @@ void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view struct wined3d_bo_vk constants_bo; VkWriteDescriptorSet vk_writes[2]; VkBufferView vk_buffer_view; + struct wined3d_range range; VkMemoryBarrier vk_barrier; VkPipeline vk_pipeline; DWORD uav_location; @@ -2111,7 +2115,9 @@ void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view cb_destination_address.buffer_object = &constants_bo.b; cb_destination_address.addr = 0;
- adapter_vk_copy_bo_address(&context_vk->c, &cb_destination_address, &cb_source_address, sizeof(constants)); + range.offset = 0; + range.size = sizeof(constants); + adapter_vk_copy_bo_address(&context_vk->c, &cb_destination_address, &cb_source_address, 1, &range);
buffer_info.buffer = constants_bo.vk_buffer; buffer_info.range = constants_bo.size; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 51a7c2ffb10..cfd1d98d6ad 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2380,7 +2380,8 @@ void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl, GLenum target, GLuint name) DECLSPEC_HIDDEN; void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl *context_gl, GLenum target) DECLSPEC_HIDDEN; void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl, - const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) DECLSPEC_HIDDEN; + const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, + unsigned int range_count, const struct wined3d_range *ranges) DECLSPEC_HIDDEN; bool wined3d_context_gl_create_bo(struct wined3d_context_gl *context_gl, GLsizeiptr size, GLenum binding, GLenum usage, bool coherent, GLbitfield flags, struct wined3d_bo_gl *bo) DECLSPEC_HIDDEN; void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN; @@ -3412,7 +3413,8 @@ struct wined3d_adapter_ops void (*adapter_unmap_bo_address)(struct wined3d_context *context, const struct wined3d_bo_address *data, unsigned int range_count, const struct wined3d_range *ranges); void (*adapter_copy_bo_address)(struct wined3d_context *context, - const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size); + const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, + unsigned int range_count, const struct wined3d_range *ranges); void (*adapter_flush_bo_address)(struct wined3d_context *context, const struct wined3d_const_bo_address *data, size_t size); bool (*adapter_alloc_bo)(struct wined3d_device *device, struct wined3d_resource *resource, @@ -3555,7 +3557,8 @@ struct wined3d_adapter *wined3d_adapter_vk_create(unsigned int ordinal, unsigned int wined3d_adapter_vk_get_memory_type_index(const struct wined3d_adapter_vk *adapter_vk, uint32_t memory_type_mask, VkMemoryPropertyFlags flags) DECLSPEC_HIDDEN; void adapter_vk_copy_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *dst, - const struct wined3d_bo_address *src, size_t size) DECLSPEC_HIDDEN; + const struct wined3d_bo_address *src, + unsigned int range_count, const struct wined3d_range *ranges) DECLSPEC_HIDDEN;
struct wined3d_caps_gl_ctx { @@ -6400,9 +6403,10 @@ static inline void wined3d_context_unmap_bo_address(struct wined3d_context *cont }
static inline void wined3d_context_copy_bo_address(struct wined3d_context *context, - const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) + const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, + unsigned int range_count, const struct wined3d_range *ranges) { - context->device->adapter->adapter_ops->adapter_copy_bo_address(context, dst, src, size); + context->device->adapter->adapter_ops->adapter_copy_bo_address(context, dst, src, range_count, ranges); }
static inline void wined3d_context_flush_bo_address(struct wined3d_context *context,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/buffer.c | 92 ++++++------------------------------------- 1 file changed, 13 insertions(+), 79 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index cc5b7bf6c33..bc6d9a67d6e 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -43,8 +43,6 @@ struct wined3d_buffer_ops struct wined3d_context *context, unsigned int location); void (*buffer_unload_location)(struct wined3d_buffer *buffer, struct wined3d_context *context, unsigned int location); - void (*buffer_upload_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, const void *data, - unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges); void (*buffer_download_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges); }; @@ -516,6 +514,7 @@ ULONG CDECL wined3d_buffer_incref(struct wined3d_buffer *buffer) static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined3d_context *context) { unsigned int i, j, range_idx, start, end, vertex_count; + struct wined3d_bo_address src, dst; BYTE *data;
if (!wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_SYSMEM)) @@ -564,8 +563,11 @@ static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined } }
- buffer->buffer_ops->buffer_upload_ranges(buffer, context, - data, 0, buffer->modified_areas, buffer->maps); + dst.buffer_object = buffer->buffer_object; + dst.addr = NULL; + src.buffer_object = NULL; + src.addr = data; + wined3d_context_copy_bo_address(context, &dst, &src, buffer->modified_areas, buffer->maps);
heap_free(data); } @@ -585,6 +587,7 @@ static void wined3d_buffer_unload_location(struct wined3d_buffer *buffer, BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, struct wined3d_context *context, DWORD location) { + struct wined3d_bo_address src, dst; struct wined3d_range range;
TRACE("buffer %p, context %p, location %s.\n", @@ -641,9 +644,13 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, memset(buffer->resource.heap_memory, 0, buffer->resource.size); }
+ dst.buffer_object = buffer->buffer_object; + dst.addr = NULL; + src.buffer_object = NULL; + src.addr = buffer->resource.heap_memory; + if (!buffer->conversion_map) - buffer->buffer_ops->buffer_upload_ranges(buffer, context, - buffer->resource.heap_memory, 0, buffer->modified_areas, buffer->maps); + wined3d_context_copy_bo_address(context, &dst, &src, buffer->modified_areas, buffer->maps); else buffer_conversion_upload(buffer, context); break; @@ -1344,12 +1351,6 @@ static void wined3d_buffer_no3d_unload_location(struct wined3d_buffer *buffer, TRACE("buffer %p, context %p, location %s.\n", buffer, context, wined3d_debug_location(location)); }
-static void wined3d_buffer_no3d_upload_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, - const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) -{ - FIXME("Not implemented.\n"); -} - static void wined3d_buffer_no3d_download_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) { @@ -1360,7 +1361,6 @@ static const struct wined3d_buffer_ops wined3d_buffer_no3d_ops = { wined3d_buffer_no3d_prepare_location, wined3d_buffer_no3d_unload_location, - wined3d_buffer_no3d_upload_ranges, wined3d_buffer_no3d_download_ranges, };
@@ -1419,23 +1419,6 @@ static void wined3d_buffer_gl_unload_location(struct wined3d_buffer *buffer, } }
-/* Context activation is done by the caller. */ -static void wined3d_buffer_gl_upload_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, - const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) -{ - struct wined3d_bo_address src, dst; - - TRACE("buffer %p, context %p, data %p, data_offset %u, range_count %u, ranges %p.\n", - buffer, context, data, data_offset, range_count, ranges); - - dst.buffer_object = buffer->buffer_object; - dst.addr = 0; - src.buffer_object = NULL; - src.addr = (uint8_t *)data - data_offset; - - wined3d_context_copy_bo_address(context, &dst, &src, range_count, ranges); -} - /* Context activation is done by the caller. */ static void wined3d_buffer_gl_download_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) @@ -1464,7 +1447,6 @@ static const struct wined3d_buffer_ops wined3d_buffer_gl_ops = { wined3d_buffer_gl_prepare_location, wined3d_buffer_gl_unload_location, - wined3d_buffer_gl_upload_ranges, wined3d_buffer_gl_download_ranges, };
@@ -1615,53 +1597,6 @@ static void wined3d_buffer_vk_unload_location(struct wined3d_buffer *buffer, } }
-static void wined3d_buffer_vk_upload_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, - const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) -{ - struct wined3d_context_vk *context_vk = wined3d_context_vk(context); - struct wined3d_resource *resource = &buffer->resource; - struct wined3d_bo_address src, dst; - const struct wined3d_range *range; - struct wined3d_bo_vk *dst_bo; - unsigned int i = range_count; - uint32_t flags; - void *map_ptr; - - if (!range_count) - return; - - dst.buffer_object = buffer->buffer_object; - dst.addr = NULL; - - flags = WINED3D_MAP_WRITE; - if (!ranges->offset && ranges->size == resource->size) - flags |= WINED3D_MAP_DISCARD; - - dst_bo = wined3d_bo_vk(buffer->buffer_object); - if (!(dst_bo->memory_type & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) || (!(flags & WINED3D_MAP_DISCARD) - && dst_bo->command_buffer_id > context_vk->completed_command_buffer_id)) - { - src.buffer_object = 0; - src.addr = (uint8_t *)data - data_offset; - wined3d_context_copy_bo_address(context, &dst, &src, range_count, ranges); - return; - } - - if (!(map_ptr = wined3d_context_map_bo_address(context, &dst, resource->size, flags))) - { - FIXME("Failed to map buffer.\n"); - return; - } - - while (i--) - { - range = &ranges[i]; - memcpy((uint8_t *)map_ptr + range->offset, (uint8_t *)data + range->offset - data_offset, range->size); - } - - wined3d_context_unmap_bo_address(context, &dst, range_count, ranges); -} - static void wined3d_buffer_vk_download_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) { @@ -1672,7 +1607,6 @@ static const struct wined3d_buffer_ops wined3d_buffer_vk_ops = { wined3d_buffer_vk_prepare_location, wined3d_buffer_vk_unload_location, - wined3d_buffer_vk_upload_ranges, wined3d_buffer_vk_download_ranges, };
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/buffer.c | 56 ++++--------------------------------------- 1 file changed, 5 insertions(+), 51 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index bc6d9a67d6e..cab93ccc4e3 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -43,8 +43,6 @@ struct wined3d_buffer_ops struct wined3d_context *context, unsigned int location); void (*buffer_unload_location)(struct wined3d_buffer *buffer, struct wined3d_context *context, unsigned int location); - void (*buffer_download_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, void *data, - unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges); };
static void wined3d_buffer_evict_sysmem(struct wined3d_buffer *buffer) @@ -139,14 +137,6 @@ void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, DWORD loc wined3d_buffer_invalidate_range(buffer, location, 0, 0); }
-/* Context activation is done by the caller. */ -static void wined3d_buffer_gl_bind(struct wined3d_buffer_gl *buffer_gl, struct wined3d_context_gl *context_gl) -{ - const struct wined3d_bo_gl *bo_gl = wined3d_bo_gl(buffer_gl->b.buffer_object); - - wined3d_context_gl_bind_bo(context_gl, bo_gl->binding, bo_gl->id); -} - static GLenum wined3d_buffer_gl_binding_from_bind_flags(const struct wined3d_gl_info *gl_info, uint32_t bind_flags) { if (!bind_flags) @@ -628,10 +618,13 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, } else { + dst.buffer_object = NULL; + dst.addr = buffer->resource.heap_memory; + src.buffer_object = buffer->buffer_object; + src.addr = NULL; range.offset = 0; range.size = buffer->resource.size; - buffer->buffer_ops->buffer_download_ranges(buffer, context, - buffer->resource.heap_memory, 0, 1, &range); + wined3d_context_copy_bo_address(context, &dst, &src, 1, &range); } break;
@@ -1351,17 +1344,10 @@ static void wined3d_buffer_no3d_unload_location(struct wined3d_buffer *buffer, TRACE("buffer %p, context %p, location %s.\n", buffer, context, wined3d_debug_location(location)); }
-static void wined3d_buffer_no3d_download_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, - void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) -{ - FIXME("Not implemented.\n"); -} - static const struct wined3d_buffer_ops wined3d_buffer_no3d_ops = { wined3d_buffer_no3d_prepare_location, wined3d_buffer_no3d_unload_location, - wined3d_buffer_no3d_download_ranges, };
HRESULT wined3d_buffer_no3d_init(struct wined3d_buffer *buffer_no3d, struct wined3d_device *device, @@ -1419,35 +1405,10 @@ static void wined3d_buffer_gl_unload_location(struct wined3d_buffer *buffer, } }
-/* Context activation is done by the caller. */ -static void wined3d_buffer_gl_download_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, - void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) -{ - struct wined3d_context_gl *context_gl = wined3d_context_gl(context); - struct wined3d_bo_gl *bo_gl = wined3d_bo_gl(buffer->buffer_object); - struct wined3d_buffer_gl *buffer_gl = wined3d_buffer_gl(buffer); - const struct wined3d_gl_info *gl_info = context_gl->gl_info; - const struct wined3d_range *range; - - TRACE("buffer %p, context %p, data %p, data_offset %u, range_count %u, ranges %p.\n", - buffer, context, data, data_offset, range_count, ranges); - - wined3d_buffer_gl_bind(buffer_gl, context_gl); - - while (range_count--) - { - range = &ranges[range_count]; - GL_EXTCALL(glGetBufferSubData(bo_gl->binding, bo_gl->b.buffer_offset + range->offset, - range->size, (BYTE *)data + range->offset - data_offset)); - } - checkGLcall("buffer download"); -} - static const struct wined3d_buffer_ops wined3d_buffer_gl_ops = { wined3d_buffer_gl_prepare_location, wined3d_buffer_gl_unload_location, - wined3d_buffer_gl_download_ranges, };
HRESULT wined3d_buffer_gl_init(struct wined3d_buffer_gl *buffer_gl, struct wined3d_device *device, @@ -1597,17 +1558,10 @@ static void wined3d_buffer_vk_unload_location(struct wined3d_buffer *buffer, } }
-static void wined3d_buffer_vk_download_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, - void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) -{ - FIXME("Not implemented.\n"); -} - static const struct wined3d_buffer_ops wined3d_buffer_vk_ops = { wined3d_buffer_vk_prepare_location, wined3d_buffer_vk_unload_location, - wined3d_buffer_vk_download_ranges, };
HRESULT wined3d_buffer_vk_init(struct wined3d_buffer_vk *buffer_vk, struct wined3d_device *device,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com