Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/wined3d/adapter_gl.c | 15 +++++++++++++++ dlls/wined3d/adapter_vk.c | 19 +++++++++++++++++++ dlls/wined3d/buffer.c | 5 ++--- dlls/wined3d/directx.c | 14 ++++++++++++++ dlls/wined3d/wined3d_private.h | 11 +++++++++++ 5 files changed, 61 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c index e161f7261b5..ed1022030bc 100644 --- a/dlls/wined3d/adapter_gl.c +++ b/dlls/wined3d/adapter_gl.c @@ -4611,6 +4611,20 @@ static void adapter_gl_unmap_bo_address(struct wined3d_context *context, const s wined3d_context_gl_unmap_bo_address(context_gl, data, binding, range_count, ranges); }
+static void adapter_gl_copy_bo_address(struct wined3d_context *context, + const struct wined3d_bo_address *dst, uint32_t dst_bind_flags, + const struct wined3d_bo_address *src, uint32_t src_bind_flags, size_t size) +{ + struct wined3d_context_gl *context_gl; + GLenum dst_binding, src_binding; + + context_gl = wined3d_context_gl(context); + dst_binding = wined3d_buffer_gl_binding_from_bind_flags(context_gl->gl_info, dst_bind_flags); + src_binding = wined3d_buffer_gl_binding_from_bind_flags(context_gl->gl_info, src_bind_flags); + + wined3d_context_gl_copy_bo_address(context_gl, dst, dst_binding, src, src_binding, size); +} + static HRESULT adapter_gl_create_swapchain(struct wined3d_device *device, struct wined3d_swapchain_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain) { @@ -5095,6 +5109,7 @@ static const struct wined3d_adapter_ops wined3d_adapter_gl_ops = adapter_gl_uninit_3d, adapter_gl_map_bo_address, adapter_gl_unmap_bo_address, + adapter_gl_copy_bo_address, adapter_gl_create_swapchain, adapter_gl_destroy_swapchain, adapter_gl_create_buffer, diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 0d83cf7582c..21163a20949 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -490,6 +490,24 @@ static void adapter_vk_unmap_bo_address(struct wined3d_context *context, const s ERR("Unsupported buffer object %#lx.\n", data->buffer_object); }
+static void adapter_vk_copy_bo_address(struct wined3d_context *context, + const struct wined3d_bo_address *dst, uint32_t dst_bind_flags, + const struct wined3d_bo_address *src, uint32_t src_bind_flags, size_t size) +{ + struct wined3d_map_range range; + void *dst_ptr, *src_ptr; + + src_ptr = adapter_vk_map_bo_address(context, src, size, src_bind_flags, WINED3D_MAP_READ); + dst_ptr = adapter_vk_map_bo_address(context, dst, size, dst_bind_flags, WINED3D_MAP_WRITE); + + memcpy(dst_ptr, src_ptr, size); + + range.offset = 0; + range.size = size; + adapter_vk_unmap_bo_address(context, dst, dst_bind_flags, 1, &range); + adapter_vk_unmap_bo_address(context, src, src_bind_flags, 0, NULL); +} + static HRESULT adapter_vk_create_swapchain(struct wined3d_device *device, struct wined3d_swapchain_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain) { @@ -821,6 +839,7 @@ static const struct wined3d_adapter_ops wined3d_adapter_vk_ops = adapter_vk_uninit_3d, adapter_vk_map_bo_address, adapter_vk_unmap_bo_address, + adapter_vk_copy_bo_address, adapter_vk_create_swapchain, adapter_vk_destroy_swapchain, adapter_vk_create_buffer, diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index b8f985e8e4c..18a0d721178 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1188,9 +1188,8 @@ void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_off src.addr += src_offset;
context = context_acquire(dst_buffer->resource.device, NULL, 0); - wined3d_context_gl_copy_bo_address(wined3d_context_gl(context), - &dst, wined3d_buffer_gl(dst_buffer)->buffer_type_hint, - &src, wined3d_buffer_gl(src_buffer)->buffer_type_hint, size); + wined3d_context_copy_bo_address(context, &dst, dst_buffer->resource.bind_flags, + &src, src_buffer->resource.bind_flags, size); context_release(context);
wined3d_buffer_invalidate_range(dst_buffer, ~dst_location, dst_offset, size); diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 24fab8491a1..92d4766bc57 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -2372,6 +2372,19 @@ static void adapter_no3d_unmap_bo_address(struct wined3d_context *context, const ERR("Unsupported buffer object %#lx.\n", data->buffer_object); }
+static void adapter_no3d_copy_bo_address(struct wined3d_context *context, + const struct wined3d_bo_address *dst, uint32_t dst_bind_flags, + const struct wined3d_bo_address *src, uint32_t src_bind_flags, size_t size) +{ + if (dst->buffer_object) + ERR("Unsupported dst buffer object %#lx.\n", dst->buffer_object); + if (src->buffer_object) + ERR("Unsupported src buffer object %#lx.\n", src->buffer_object); + if (dst->buffer_object || src->buffer_object) + return; + memcpy(dst->addr, src->addr, size); +} + static HRESULT adapter_no3d_create_swapchain(struct wined3d_device *device, struct wined3d_swapchain_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain) { @@ -2626,6 +2639,7 @@ static const struct wined3d_adapter_ops wined3d_adapter_no3d_ops = adapter_no3d_uninit_3d, adapter_no3d_map_bo_address, adapter_no3d_unmap_bo_address, + adapter_no3d_copy_bo_address, adapter_no3d_create_swapchain, adapter_no3d_destroy_swapchain, adapter_no3d_create_buffer, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 648e3f0dee0..5ce23f85f6b 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2821,6 +2821,9 @@ struct wined3d_adapter_ops const struct wined3d_bo_address *data, size_t size, uint32_t bind_flags, uint32_t map_flags); void (*adapter_unmap_bo_address)(struct wined3d_context *context, const struct wined3d_bo_address *data, uint32_t bind_flags, unsigned int range_count, const struct wined3d_map_range *ranges); + void (*adapter_copy_bo_address)(struct wined3d_context *context, + const struct wined3d_bo_address *dst, uint32_t dst_bind_flags, + const struct wined3d_bo_address *src, uint32_t src_bind_flags, size_t size); HRESULT (*adapter_create_swapchain)(struct wined3d_device *device, struct wined3d_swapchain_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain); void (*adapter_destroy_swapchain)(struct wined3d_swapchain *swapchain); @@ -5267,6 +5270,14 @@ static inline void wined3d_context_unmap_bo_address(struct wined3d_context *cont context->device->adapter->adapter_ops->adapter_unmap_bo_address(context, data, bind_flags, range_count, ranges); }
+static inline void wined3d_context_copy_bo_address(struct wined3d_context *context, + const struct wined3d_bo_address *dst, uint32_t dst_bind_flags, + const struct wined3d_bo_address *src, uint32_t src_bind_flags, size_t size) +{ + context->device->adapter->adapter_ops->adapter_copy_bo_address(context, + dst, dst_bind_flags, src, src_bind_flags, size); +} + /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */ #define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"