wined3d: Fix initial data for non-GPU buffers.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=44655
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-09-06 22:01:58 +02:00 committed by Alexandre Julliard
parent 490c6d548a
commit 3cd28caf17
1 changed files with 23 additions and 6 deletions

View File

@ -1230,6 +1230,28 @@ void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_co
wined3d_buffer_upload_ranges(buffer, context, data, range.offset, 1, &range); wined3d_buffer_upload_ranges(buffer, context, data, range.offset, 1, &range);
} }
static void wined3d_buffer_init_data(struct wined3d_buffer *buffer,
struct wined3d_device *device, const struct wined3d_sub_resource_data *data)
{
struct wined3d_resource *resource = &buffer->resource;
struct wined3d_bo_address bo;
struct wined3d_box box;
if (buffer->flags & WINED3D_BUFFER_USE_BO)
{
wined3d_box_set(&box, 0, 0, resource->size, 1, 0, 1);
wined3d_cs_emit_update_sub_resource(device->cs, resource,
0, &box, data->data, data->row_pitch, data->slice_pitch);
}
else
{
wined3d_buffer_get_memory(buffer, &bo, WINED3D_LOCATION_SYSMEM);
memcpy(bo.addr, data->data, resource->size);
wined3d_buffer_validate_location(buffer, WINED3D_LOCATION_SYSMEM);
wined3d_buffer_invalidate_location(buffer, ~WINED3D_LOCATION_SYSMEM);
}
}
static ULONG buffer_resource_incref(struct wined3d_resource *resource) static ULONG buffer_resource_incref(struct wined3d_resource *resource)
{ {
return wined3d_buffer_incref(buffer_from_resource(resource)); return wined3d_buffer_incref(buffer_from_resource(resource));
@ -1326,7 +1348,6 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
const struct wined3d_format *format = wined3d_get_format(device->adapter, format_id, usage); const struct wined3d_format *format = wined3d_get_format(device->adapter, format_id, usage);
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct wined3d_resource *resource = &buffer->resource; struct wined3d_resource *resource = &buffer->resource;
struct wined3d_box box;
BOOL dynamic_buffer_ok; BOOL dynamic_buffer_ok;
HRESULT hr; HRESULT hr;
@ -1408,11 +1429,7 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
buffer->maps_size = 1; buffer->maps_size = 1;
if (data) if (data)
{ wined3d_buffer_init_data(buffer, device, data);
wined3d_box_set(&box, 0, 0, resource->size, 1, 0, 1);
wined3d_cs_emit_update_sub_resource(device->cs, resource,
0, &box, data->data, data->row_pitch, data->slice_pitch);
}
return WINED3D_OK; return WINED3D_OK;
} }