wined3d: Implement wined3d_buffer_upload_data() on top of wined3d_buffer_upload_ranges().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2017-01-31 15:47:12 +01:00 committed by Alexandre Julliard
parent 160ad4570e
commit e2dbbec1af
3 changed files with 22 additions and 23 deletions

View file

@ -532,7 +532,7 @@ ULONG CDECL wined3d_buffer_incref(struct wined3d_buffer *buffer)
/* Context activation is done by the caller. */
static void wined3d_buffer_upload_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context,
const void *data, unsigned int range_count, const struct wined3d_map_range *ranges)
const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_map_range *range;
@ -543,7 +543,7 @@ static void wined3d_buffer_upload_ranges(struct wined3d_buffer *buffer, struct w
{
range = &ranges[range_count];
GL_EXTCALL(glBufferSubData(buffer->buffer_type_hint,
range->offset, range->size, (BYTE *)data + range->offset));
range->offset, range->size, (BYTE *)data + range->offset - data_offset));
}
checkGLcall("glBufferSubData");
}
@ -599,7 +599,7 @@ static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined
}
}
wined3d_buffer_upload_ranges(buffer, context, data, buffer->modified_areas, buffer->maps);
wined3d_buffer_upload_ranges(buffer, context, data, 0, buffer->modified_areas, buffer->maps);
HeapFree(GetProcessHeap(), 0, data);
}
@ -683,7 +683,7 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
case WINED3D_LOCATION_BUFFER:
if (!buffer->conversion_map)
wined3d_buffer_upload_ranges(buffer, context, buffer->resource.heap_memory,
buffer->modified_areas, buffer->maps);
0, buffer->modified_areas, buffer->maps);
else
buffer_conversion_upload(buffer, context);
break;
@ -1266,31 +1266,23 @@ HRESULT wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_
return WINED3D_OK;
}
HRESULT wined3d_buffer_upload_data(struct wined3d_buffer *buffer,
void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_context *context,
const struct wined3d_box *box, const void *data)
{
UINT offset, size;
HRESULT hr;
BYTE *ptr;
struct wined3d_map_range range;
if (box)
{
offset = box->left;
size = box->right - box->left;
range.offset = box->left;
range.size = box->right - box->left;
}
else
{
offset = 0;
size = buffer->resource.size;
range.offset = 0;
range.size = buffer->resource.size;
}
if (FAILED(hr = wined3d_buffer_map(buffer, offset, size, &ptr, 0)))
return hr;
memcpy(ptr, data, size);
wined3d_buffer_unmap(buffer);
return WINED3D_OK;
wined3d_buffer_upload_ranges(buffer, context, data, range.offset, 1, &range);
}
static ULONG buffer_resource_incref(struct wined3d_resource *resource)

View file

@ -4061,7 +4061,6 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
if (resource->type == WINED3D_RTYPE_BUFFER)
{
struct wined3d_buffer *buffer = buffer_from_resource(resource);
HRESULT hr;
if (sub_resource_idx > 0)
{
@ -4069,8 +4068,16 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
return;
}
if (FAILED(hr = wined3d_buffer_upload_data(buffer, box, data)))
WARN("Failed to update buffer data, hr %#x.\n", hr);
context = context_acquire(resource->device, NULL);
if (!wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_BUFFER))
{
ERR("Failed to load buffer location.\n");
return;
}
wined3d_buffer_upload_data(buffer, context, box, data);
wined3d_buffer_invalidate_location(buffer, ~WINED3D_LOCATION_BUFFER);
context_release(context);
return;
}

View file

@ -3250,7 +3250,7 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context) DECLSPEC_HIDDEN;
HRESULT 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;
HRESULT wined3d_buffer_upload_data(struct wined3d_buffer *buffer,
void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_context *context,
const struct wined3d_box *box, const void *data) DECLSPEC_HIDDEN;
struct wined3d_rendertarget_view