Commit ef127f12 authored by Anton Baskanov's avatar Anton Baskanov Committed by Alexandre Julliard

wined3d: Factor out and expose functions to map/unmap wined3d_streaming_buffer.

parent e0f32f53
...@@ -1685,8 +1685,9 @@ static HRESULT wined3d_streaming_buffer_prepare(struct wined3d_device *device, ...@@ -1685,8 +1685,9 @@ static HRESULT wined3d_streaming_buffer_prepare(struct wined3d_device *device,
return hr; return hr;
} }
HRESULT CDECL wined3d_streaming_buffer_upload(struct wined3d_device *device, struct wined3d_streaming_buffer *buffer, HRESULT CDECL wined3d_streaming_buffer_map(struct wined3d_device *device,
const void *data, unsigned int size, unsigned int stride, unsigned int *ret_pos) 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; unsigned int map_flags = WINED3D_MAP_WRITE;
struct wined3d_resource *resource; struct wined3d_resource *resource;
...@@ -1695,8 +1696,8 @@ HRESULT CDECL wined3d_streaming_buffer_upload(struct wined3d_device *device, str ...@@ -1695,8 +1696,8 @@ HRESULT CDECL wined3d_streaming_buffer_upload(struct wined3d_device *device, str
struct wined3d_box box; struct wined3d_box box;
HRESULT hr; HRESULT hr;
TRACE("device %p, buffer %p, data %p, size %u, stride %u, ret_pos %p.\n", TRACE("device %p, buffer %p, size %u, stride %u, ret_pos %p, ret_data %p.\n",
device, buffer, data, size, stride, ret_pos); device, buffer, size, stride, ret_pos, ret_data);
if (FAILED(hr = wined3d_streaming_buffer_prepare(device, buffer, size))) if (FAILED(hr = wined3d_streaming_buffer_prepare(device, buffer, size)))
return hr; return hr;
...@@ -1719,10 +1720,28 @@ HRESULT CDECL wined3d_streaming_buffer_upload(struct wined3d_device *device, str ...@@ -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); wined3d_box_set(&box, pos, 0, pos + size, 1, 0, 1);
if (SUCCEEDED(hr = wined3d_resource_map(resource, 0, &map_desc, &box, map_flags))) 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_pos = pos;
*ret_data = map_desc.data;
buffer->pos = pos + size; buffer->pos = pos + size;
} }
return hr; 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;
}
...@@ -260,6 +260,8 @@ ...@@ -260,6 +260,8 @@
@ cdecl wined3d_stateblock_set_vs_consts_f(ptr long long ptr) @ cdecl wined3d_stateblock_set_vs_consts_f(ptr long long ptr)
@ cdecl wined3d_stateblock_set_vs_consts_i(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_streaming_buffer_upload(ptr ptr ptr long long ptr)
@ cdecl wined3d_swapchain_create(ptr ptr ptr ptr ptr ptr) @ cdecl wined3d_swapchain_create(ptr ptr ptr ptr ptr ptr)
......
...@@ -2788,6 +2788,10 @@ HRESULT __cdecl wined3d_stateblock_set_vs_consts_f(struct wined3d_stateblock *st ...@@ -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, HRESULT __cdecl wined3d_stateblock_set_vs_consts_i(struct wined3d_stateblock *stateblock,
unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants); 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, 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); const void *data, unsigned int size, unsigned int stride, unsigned int *pos);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment