Commit e2dbbec1 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

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

parent 160ad457
...@@ -532,7 +532,7 @@ ULONG CDECL wined3d_buffer_incref(struct wined3d_buffer *buffer) ...@@ -532,7 +532,7 @@ ULONG CDECL wined3d_buffer_incref(struct wined3d_buffer *buffer)
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
static void wined3d_buffer_upload_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, 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_gl_info *gl_info = context->gl_info;
const struct wined3d_map_range *range; const struct wined3d_map_range *range;
...@@ -543,7 +543,7 @@ static void wined3d_buffer_upload_ranges(struct wined3d_buffer *buffer, struct w ...@@ -543,7 +543,7 @@ static void wined3d_buffer_upload_ranges(struct wined3d_buffer *buffer, struct w
{ {
range = &ranges[range_count]; range = &ranges[range_count];
GL_EXTCALL(glBufferSubData(buffer->buffer_type_hint, 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"); checkGLcall("glBufferSubData");
} }
...@@ -599,7 +599,7 @@ static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined ...@@ -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); HeapFree(GetProcessHeap(), 0, data);
} }
...@@ -683,7 +683,7 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, ...@@ -683,7 +683,7 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
case WINED3D_LOCATION_BUFFER: case WINED3D_LOCATION_BUFFER:
if (!buffer->conversion_map) if (!buffer->conversion_map)
wined3d_buffer_upload_ranges(buffer, context, buffer->resource.heap_memory, wined3d_buffer_upload_ranges(buffer, context, buffer->resource.heap_memory,
buffer->modified_areas, buffer->maps); 0, buffer->modified_areas, buffer->maps);
else else
buffer_conversion_upload(buffer, context); buffer_conversion_upload(buffer, context);
break; break;
...@@ -1266,31 +1266,23 @@ HRESULT wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_ ...@@ -1266,31 +1266,23 @@ HRESULT wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_
return WINED3D_OK; 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) const struct wined3d_box *box, const void *data)
{ {
UINT offset, size; struct wined3d_map_range range;
HRESULT hr;
BYTE *ptr;
if (box) if (box)
{ {
offset = box->left; range.offset = box->left;
size = box->right - box->left; range.size = box->right - box->left;
} }
else else
{ {
offset = 0; range.offset = 0;
size = buffer->resource.size; range.size = buffer->resource.size;
} }
if (FAILED(hr = wined3d_buffer_map(buffer, offset, size, &ptr, 0))) wined3d_buffer_upload_ranges(buffer, context, data, range.offset, 1, &range);
return hr;
memcpy(ptr, data, size);
wined3d_buffer_unmap(buffer);
return WINED3D_OK;
} }
static ULONG buffer_resource_incref(struct wined3d_resource *resource) static ULONG buffer_resource_incref(struct wined3d_resource *resource)
......
...@@ -4061,7 +4061,6 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str ...@@ -4061,7 +4061,6 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
if (resource->type == WINED3D_RTYPE_BUFFER) if (resource->type == WINED3D_RTYPE_BUFFER)
{ {
struct wined3d_buffer *buffer = buffer_from_resource(resource); struct wined3d_buffer *buffer = buffer_from_resource(resource);
HRESULT hr;
if (sub_resource_idx > 0) if (sub_resource_idx > 0)
{ {
...@@ -4069,8 +4068,16 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str ...@@ -4069,8 +4068,16 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
return; return;
} }
if (FAILED(hr = wined3d_buffer_upload_data(buffer, box, data))) context = context_acquire(resource->device, NULL);
WARN("Failed to update buffer data, hr %#x.\n", hr); 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; return;
} }
......
...@@ -3250,7 +3250,7 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, ...@@ -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; 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, 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; 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; const struct wined3d_box *box, const void *data) DECLSPEC_HIDDEN;
struct wined3d_rendertarget_view struct wined3d_rendertarget_view
......
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