Module: wine Branch: master Commit: ef127f12435a43f0f82d8256f93b5823aeee3957 URL: https://gitlab.winehq.org/wine/wine/-/commit/ef127f12435a43f0f82d8256f93b582...
Author: Anton Baskanov baskanov@gmail.com Date: Fri Oct 21 14:22:03 2022 +0700
wined3d: Factor out and expose functions to map/unmap wined3d_streaming_buffer.
---
dlls/wined3d/buffer.c | 31 +++++++++++++++++++++++++------ dlls/wined3d/wined3d.spec | 2 ++ include/wine/wined3d.h | 4 ++++ 3 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 1a953f8e218..fca7f2916b7 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1685,8 +1685,9 @@ static HRESULT wined3d_streaming_buffer_prepare(struct wined3d_device *device, return hr; }
-HRESULT CDECL wined3d_streaming_buffer_upload(struct wined3d_device *device, struct wined3d_streaming_buffer *buffer, - const void *data, unsigned int size, unsigned int stride, unsigned int *ret_pos) +HRESULT CDECL wined3d_streaming_buffer_map(struct wined3d_device *device, + struct wined3d_streaming_buffer *buffer, unsigned int size, unsigned int stride, + unsigned int *ret_pos, void **ret_data) { unsigned int map_flags = WINED3D_MAP_WRITE; struct wined3d_resource *resource; @@ -1695,8 +1696,8 @@ HRESULT CDECL wined3d_streaming_buffer_upload(struct wined3d_device *device, str struct wined3d_box box; HRESULT hr;
- TRACE("device %p, buffer %p, data %p, size %u, stride %u, ret_pos %p.\n", - device, buffer, data, size, stride, ret_pos); + TRACE("device %p, buffer %p, size %u, stride %u, ret_pos %p, ret_data %p.\n", + device, buffer, size, stride, ret_pos, ret_data);
if (FAILED(hr = wined3d_streaming_buffer_prepare(device, buffer, size))) return hr; @@ -1719,10 +1720,28 @@ HRESULT CDECL wined3d_streaming_buffer_upload(struct wined3d_device *device, str wined3d_box_set(&box, pos, 0, pos + size, 1, 0, 1); if (SUCCEEDED(hr = wined3d_resource_map(resource, 0, &map_desc, &box, map_flags))) { - memcpy(map_desc.data, data, size); - wined3d_resource_unmap(resource, 0); *ret_pos = pos; + *ret_data = map_desc.data; buffer->pos = pos + size; } return hr; } + +void CDECL wined3d_streaming_buffer_unmap(struct wined3d_streaming_buffer *buffer) +{ + wined3d_resource_unmap(&buffer->buffer->resource, 0); +} + +HRESULT CDECL wined3d_streaming_buffer_upload(struct wined3d_device *device, struct wined3d_streaming_buffer *buffer, + const void *data, unsigned int size, unsigned int stride, unsigned int *ret_pos) +{ + void *dst_data; + HRESULT hr; + + if (SUCCEEDED(hr = wined3d_streaming_buffer_map(device, buffer, size, stride, ret_pos, &dst_data))) + { + memcpy(dst_data, data, size); + wined3d_streaming_buffer_unmap(buffer); + } + return hr; +} diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index e6126faf838..827ac295ddc 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -260,6 +260,8 @@ @ cdecl wined3d_stateblock_set_vs_consts_f(ptr long long ptr) @ cdecl wined3d_stateblock_set_vs_consts_i(ptr long long ptr)
+@ cdecl wined3d_streaming_buffer_map(ptr ptr long long ptr ptr) +@ cdecl wined3d_streaming_buffer_unmap(ptr) @ cdecl wined3d_streaming_buffer_upload(ptr ptr ptr long long ptr)
@ cdecl wined3d_swapchain_create(ptr ptr ptr ptr ptr ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index a18dcda45be..8ec397b73a5 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2788,6 +2788,10 @@ HRESULT __cdecl wined3d_stateblock_set_vs_consts_f(struct wined3d_stateblock *st HRESULT __cdecl wined3d_stateblock_set_vs_consts_i(struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants);
+HRESULT __cdecl wined3d_streaming_buffer_map(struct wined3d_device *device, + struct wined3d_streaming_buffer *buffer, unsigned int size, unsigned int stride, + unsigned int *ret_pos, void **ret_data); +void __cdecl wined3d_streaming_buffer_unmap(struct wined3d_streaming_buffer *buffer); HRESULT __cdecl wined3d_streaming_buffer_upload(struct wined3d_device *device, struct wined3d_streaming_buffer *buffer, const void *data, unsigned int size, unsigned int stride, unsigned int *pos);