[PATCH 4/6] wined3d: Factor out wined3d_buffer_copy_bo_address().
Zebediah Figura
z.figura12 at gmail.com
Thu Jun 17 23:19:37 CDT 2021
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/wined3d/buffer.c | 24 ++++++++++++++++--------
dlls/wined3d/view.c | 10 ++--------
dlls/wined3d/wined3d_private.h | 2 ++
3 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index cbf33df5539..7b8c8904961 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1009,28 +1009,36 @@ static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resou
return WINED3D_OK;
}
+void wined3d_buffer_copy_bo_address(struct wined3d_buffer *dst_buffer, struct wined3d_context *context,
+ unsigned int dst_offset, const struct wined3d_const_bo_address *src_addr, unsigned int size)
+{
+ struct wined3d_bo_address dst_addr;
+ 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);
+ wined3d_buffer_invalidate_range(dst_buffer, ~dst_location, dst_offset, size);
+}
+
void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_offset,
struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size)
{
- struct wined3d_bo_address dst, src;
struct wined3d_context *context;
- DWORD dst_location;
+ struct wined3d_bo_address src;
TRACE("dst_buffer %p, dst_offset %u, src_buffer %p, src_offset %u, size %u.\n",
dst_buffer, dst_offset, src_buffer, src_offset, size);
context = context_acquire(dst_buffer->resource.device, NULL, 0);
- dst_location = wined3d_buffer_get_memory(dst_buffer, context, &dst);
- dst.addr += dst_offset;
-
wined3d_buffer_get_memory(src_buffer, context, &src);
src.addr += src_offset;
- wined3d_context_copy_bo_address(context, &dst, &src, size);
- context_release(context);
+ wined3d_buffer_copy_bo_address(dst_buffer, context, dst_offset, wined3d_const_bo_address(&src), size);
- wined3d_buffer_invalidate_range(dst_buffer, ~dst_location, dst_offset, size);
+ context_release(context);
}
void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_context *context,
diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c
index 67f4b03e9d3..e8c91ec6413 100644
--- a/dlls/wined3d/view.c
+++ b/dlls/wined3d/view.c
@@ -1605,21 +1605,15 @@ void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_v
void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view *view,
struct wined3d_buffer *buffer, unsigned int offset, struct wined3d_context *context)
{
- struct wined3d_bo_address dst, src;
- DWORD dst_location;
+ struct wined3d_const_bo_address src;
if (!view->counter_bo)
return;
- dst_location = wined3d_buffer_get_memory(buffer, context, &dst);
- dst.addr += offset;
-
src.buffer_object = view->counter_bo;
src.addr = NULL;
- wined3d_context_copy_bo_address(context, &dst, &src, sizeof(uint32_t));
-
- wined3d_buffer_invalidate_location(buffer, ~dst_location);
+ wined3d_buffer_copy_bo_address(buffer, context, offset, &src, sizeof(uint32_t));
}
void wined3d_unordered_access_view_gl_update(struct wined3d_unordered_access_view_gl *uav_gl,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 400d20b94b4..da1cf638606 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4899,6 +4899,8 @@ static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resourc
void wined3d_buffer_cleanup(struct wined3d_buffer *buffer) DECLSPEC_HIDDEN;
void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_offset,
struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size) DECLSPEC_HIDDEN;
+void wined3d_buffer_copy_bo_address(struct wined3d_buffer *dst_buffer, struct wined3d_context *context,
+ unsigned int dst_offset, const struct wined3d_const_bo_address *src_addr, unsigned int size) DECLSPEC_HIDDEN;
DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *context,
struct wined3d_bo_address *data) DECLSPEC_HIDDEN;
void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, DWORD location) DECLSPEC_HIDDEN;
--
2.30.2
More information about the wine-devel
mailing list