From 1b16a606f7c26090971a9c9cf061999a30e72f0e Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 8 Nov 2021 16:34:44 -0600 Subject: [PATCH] wined3d: Introduce a wined3d_buffer_update_sub_resource() helper. Signed-off-by: Zebediah Figura Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/buffer.c | 9 +++++++++ dlls/wined3d/cs.c | 9 ++------- dlls/wined3d/wined3d_private.h | 2 ++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index be4d095eba0..2bdfff7c1b0 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1093,6 +1093,15 @@ void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_off context_release(context); } +void wined3d_buffer_update_sub_resource(struct wined3d_buffer *buffer, struct wined3d_context *context, + const struct upload_bo *upload_bo, unsigned int offset, unsigned int size) +{ + if (upload_bo->addr.buffer_object && upload_bo->addr.buffer_object == (uintptr_t)buffer->buffer_object) + wined3d_context_flush_bo_address(context, &upload_bo->addr, size); + else + wined3d_buffer_copy_bo_address(buffer, context, offset, &upload_bo->addr, size); +} + static void wined3d_buffer_init_data(struct wined3d_buffer *buffer, struct wined3d_device *device, const struct wined3d_sub_resource_data *data) { diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index e1e9c8e1857..9f79479ce8f 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -2742,13 +2742,8 @@ static void wined3d_cs_exec_update_sub_resource(struct wined3d_cs *cs, const voi if (resource->type == WINED3D_RTYPE_BUFFER) { - struct wined3d_buffer *buffer = buffer_from_resource(resource); - size_t size = box->right - box->left; - - if (op->bo.addr.buffer_object && op->bo.addr.buffer_object == (uintptr_t)buffer->buffer_object) - wined3d_context_flush_bo_address(context, &op->bo.addr, size); - else - wined3d_buffer_copy_bo_address(buffer, context, box->left, &op->bo.addr, size); + wined3d_buffer_update_sub_resource(buffer_from_resource(resource), + context, &op->bo, box->left, box->right - box->left); goto done; } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 63fea9da0e7..2880a5c6b90 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -5072,6 +5072,8 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context) DECLSPEC_HIDDEN; BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer, struct wined3d_context *context, unsigned int location) DECLSPEC_HIDDEN; +void wined3d_buffer_update_sub_resource(struct wined3d_buffer *buffer, struct wined3d_context *context, + const struct upload_bo *upload_bo, unsigned int offset, unsigned int size) DECLSPEC_HIDDEN; HRESULT wined3d_buffer_no3d_init(struct wined3d_buffer *buffer_no3d, struct wined3d_device *device, const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,