wined3d: Download buffer ranges through buffer ops.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ac7ca87a68
commit
e1448751ea
|
@ -628,9 +628,7 @@ static BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer,
|
||||||
BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
|
BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
|
||||||
struct wined3d_context *context, DWORD location)
|
struct wined3d_context *context, DWORD location)
|
||||||
{
|
{
|
||||||
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
|
struct wined3d_map_range range;
|
||||||
struct wined3d_buffer_gl *buffer_gl = wined3d_buffer_gl(buffer);
|
|
||||||
const struct wined3d_gl_info *gl_info = context_gl->gl_info;
|
|
||||||
|
|
||||||
TRACE("buffer %p, context %p, location %s.\n",
|
TRACE("buffer %p, context %p, location %s.\n",
|
||||||
buffer, context, wined3d_debug_location(location));
|
buffer, context, wined3d_debug_location(location));
|
||||||
|
@ -664,10 +662,10 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
|
||||||
switch (location)
|
switch (location)
|
||||||
{
|
{
|
||||||
case WINED3D_LOCATION_SYSMEM:
|
case WINED3D_LOCATION_SYSMEM:
|
||||||
wined3d_buffer_gl_bind(buffer_gl, context_gl);
|
range.offset = 0;
|
||||||
GL_EXTCALL(glGetBufferSubData(buffer_gl->buffer_type_hint, 0, buffer->resource.size,
|
range.size = buffer->resource.size;
|
||||||
buffer->resource.heap_memory));
|
buffer->buffer_ops->buffer_download_ranges(buffer, context,
|
||||||
checkGLcall("buffer download");
|
buffer->resource.heap_memory, 0, 1, &range);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WINED3D_LOCATION_BUFFER:
|
case WINED3D_LOCATION_BUFFER:
|
||||||
|
@ -1463,9 +1461,30 @@ static void wined3d_buffer_gl_upload_ranges(struct wined3d_buffer *buffer, struc
|
||||||
checkGLcall("buffer upload");
|
checkGLcall("buffer upload");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Context activation is done by the caller. */
|
||||||
|
static void wined3d_buffer_gl_download_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context,
|
||||||
|
void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges)
|
||||||
|
{
|
||||||
|
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
|
||||||
|
struct wined3d_buffer_gl *buffer_gl = wined3d_buffer_gl(buffer);
|
||||||
|
const struct wined3d_gl_info *gl_info = context_gl->gl_info;
|
||||||
|
const struct wined3d_map_range *range;
|
||||||
|
|
||||||
|
wined3d_buffer_gl_bind(buffer_gl, context_gl);
|
||||||
|
|
||||||
|
while (range_count--)
|
||||||
|
{
|
||||||
|
range = &ranges[range_count];
|
||||||
|
GL_EXTCALL(glGetBufferSubData(buffer_gl->buffer_type_hint,
|
||||||
|
range->offset, range->size, (BYTE *)data + range->offset - data_offset));
|
||||||
|
}
|
||||||
|
checkGLcall("buffer download");
|
||||||
|
}
|
||||||
|
|
||||||
static const struct wined3d_buffer_ops wined3d_buffer_gl_ops =
|
static const struct wined3d_buffer_ops wined3d_buffer_gl_ops =
|
||||||
{
|
{
|
||||||
wined3d_buffer_gl_upload_ranges,
|
wined3d_buffer_gl_upload_ranges,
|
||||||
|
wined3d_buffer_gl_download_ranges,
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, const struct wined3d_buffer_desc *desc,
|
HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, const struct wined3d_buffer_desc *desc,
|
||||||
|
|
|
@ -4047,6 +4047,8 @@ struct wined3d_buffer_ops
|
||||||
{
|
{
|
||||||
void (*buffer_upload_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, const void *data,
|
void (*buffer_upload_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, const void *data,
|
||||||
unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges);
|
unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges);
|
||||||
|
void (*buffer_download_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, void *data,
|
||||||
|
unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wined3d_buffer
|
struct wined3d_buffer
|
||||||
|
|
Loading…
Reference in New Issue