wined3d: Add support for buffers in wined3d_device_copy_sub_resource().

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 2016-03-20 23:15:27 +01:00 committed by Alexandre Julliard
parent 94039385f9
commit 33e786565c
1 changed files with 48 additions and 10 deletions

View File

@ -3922,6 +3922,14 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
device, dst_resource, dst_sub_resource_idx, dst_x, dst_y, dst_z,
src_resource, src_sub_resource_idx, debug_box(src_box));
if (src_box && (src_box->left >= src_box->right
|| src_box->top >= src_box->bottom
|| src_box->front >= src_box->back))
{
WARN("Invalid box %s specified.\n", debug_box(src_box));
return WINED3DERR_INVALIDCALL;
}
if (src_resource == dst_resource && src_sub_resource_idx == dst_sub_resource_idx)
{
WARN("Source and destination are the same sub-resource.\n");
@ -3944,6 +3952,46 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
return WINED3DERR_INVALIDCALL;
}
if (dst_resource->type == WINED3D_RTYPE_BUFFER)
{
unsigned int src_offset, size;
if (dst_sub_resource_idx)
{
WARN("Invalid dst_sub_resource_idx %u.\n", dst_sub_resource_idx);
return WINED3DERR_INVALIDCALL;
}
if (src_sub_resource_idx)
{
WARN("Invalid src_sub_resource_idx %u.\n", src_sub_resource_idx);
return WINED3DERR_INVALIDCALL;
}
if (src_box)
{
src_offset = src_box->left;
size = src_box->right - src_box->left;
}
else
{
src_offset = 0;
size = src_resource->size;
}
if (src_offset > src_resource->size
|| size > src_resource->size - src_offset
|| dst_x > dst_resource->size
|| size > dst_resource->size - dst_x)
{
WARN("Invalid range specified, dst_offset %u, src_offset %u, size %u.\n",
dst_x, src_offset, size);
return WINED3DERR_INVALIDCALL;
}
return wined3d_buffer_copy(buffer_from_resource(dst_resource), dst_x,
buffer_from_resource(src_resource), src_offset, size);
}
if (dst_resource->type != WINED3D_RTYPE_TEXTURE_2D)
{
FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(dst_resource->type));
@ -3967,19 +4015,9 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
src_surface = surface_from_resource(tmp);
if (src_box)
{
if (src_box->front >= src_box->back)
{
WARN("Invalid box %s specified.\n", debug_box(src_box));
return WINED3DERR_INVALIDCALL;
}
SetRect(&src_rect, src_box->left, src_box->top, src_box->right, src_box->bottom);
}
else
{
SetRect(&src_rect, 0, 0, src_surface->resource.width, src_surface->resource.height);
}
SetRect(&dst_rect, dst_x, dst_y, dst_x + (src_rect.right - src_rect.left),
dst_y + (src_rect.bottom - src_rect.top));