d3d10core: Implement d3d10_device_CopySubresourceRegion().

This commit is contained in:
Henri Verbeet 2015-07-20 11:07:30 +02:00 committed by Alexandre Julliard
parent fc1286aed8
commit e2c0c611d4
4 changed files with 96 additions and 2 deletions

View File

@ -635,10 +635,25 @@ static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *
ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z, ID3D10Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z,
ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box) ID3D10Resource *src_resource, UINT src_subresource_idx, const D3D10_BOX *src_box)
{ {
FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u,\n" struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
"\tsrc_resource %p, src_subresource_idx %u, src_box %p stub!\n", struct d3d10_device *device = impl_from_ID3D10Device(iface);
struct wined3d_box wined3d_src_box;
TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
"src_resource %p, src_subresource_idx %u, src_box %p.\n",
iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z, iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z,
src_resource, src_subresource_idx, src_box); src_resource, src_subresource_idx, src_box);
wined3d_dst_resource = wined3d_resource_from_resource(dst_resource);
wined3d_src_resource = wined3d_resource_from_resource(src_resource);
wined3d_src_box.left = src_box->left;
wined3d_src_box.top = src_box->top;
wined3d_src_box.front = src_box->front;
wined3d_src_box.right = src_box->right;
wined3d_src_box.bottom = src_box->bottom;
wined3d_src_box.back = src_box->back;
wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_dst_resource, dst_subresource_idx,
dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, &wined3d_src_box);
} }
static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface, static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface,

View File

@ -3908,6 +3908,80 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device,
} }
} }
void CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *device,
struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx, unsigned int dst_x,
unsigned int dst_y, unsigned int dst_z, struct wined3d_resource *src_resource,
unsigned int src_sub_resource_idx, const struct wined3d_box *src_box)
{
struct wined3d_surface *dst_surface, *src_surface;
struct wined3d_texture *dst_texture, *src_texture;
struct wined3d_resource *tmp;
RECT dst_rect, src_rect;
HRESULT hr;
TRACE("device %p, dst_resource %p, dst_sub_resource_idx %u, dst_x %u, dst_y %u, dst_z %u, "
"src_resource %p, src_sub_resource_idx %u, src_box %p.\n",
device, dst_resource, dst_sub_resource_idx, dst_x, dst_y, dst_z,
src_resource, src_sub_resource_idx, src_box);
if (src_resource == dst_resource && src_sub_resource_idx == dst_sub_resource_idx)
{
WARN("Source and destination are the same sub-resource.\n");
return;
}
if (src_resource->type != dst_resource->type)
{
WARN("Resource types (%s / %s) don't match.\n",
debug_d3dresourcetype(dst_resource->type),
debug_d3dresourcetype(src_resource->type));
return;
}
if (src_resource->format->id != dst_resource->format->id)
{
WARN("Resource formats (%s / %s) don't match.\n",
debug_d3dformat(dst_resource->format->id),
debug_d3dformat(src_resource->format->id));
return;
}
if (dst_resource->type != WINED3D_RTYPE_TEXTURE)
{
FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(dst_resource->type));
return;
}
dst_texture = wined3d_texture_from_resource(dst_resource);
if (!(tmp = wined3d_texture_get_sub_resource(dst_texture, dst_sub_resource_idx)))
{
WARN("Invalid dst_sub_resource_idx %u.\n", dst_sub_resource_idx);
return;
}
dst_surface = surface_from_resource(tmp);
src_texture = wined3d_texture_from_resource(src_resource);
if (!(tmp = wined3d_texture_get_sub_resource(src_texture, src_sub_resource_idx)))
{
WARN("Invalid src_sub_resource_idx %u.\n", src_sub_resource_idx);
return;
}
src_surface = surface_from_resource(tmp);
dst_rect.left = dst_x;
dst_rect.top = dst_y;
dst_rect.right = dst_x + (src_box->right - src_box->left);
dst_rect.bottom = dst_y + (src_box->bottom - src_box->top);
src_rect.left = src_box->left;
src_rect.top = src_box->top;
src_rect.right = src_box->right;
src_rect.bottom = src_box->bottom;
if (FAILED(hr = wined3d_surface_blt(dst_surface, &dst_rect, src_surface, &src_rect, 0, NULL, WINED3D_TEXF_POINT)))
ERR("Failed to blit, hr %#x.\n", hr);
}
HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *device, HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *device,
struct wined3d_rendertarget_view *view, const RECT *rect, const struct wined3d_color *color) struct wined3d_rendertarget_view *view, const RECT *rect, const struct wined3d_color *color)
{ {

View File

@ -38,6 +38,7 @@
@ cdecl wined3d_device_clear(ptr long ptr long ptr float long) @ cdecl wined3d_device_clear(ptr long ptr long ptr float long)
@ cdecl wined3d_device_clear_rendertarget_view(ptr ptr ptr ptr) @ cdecl wined3d_device_clear_rendertarget_view(ptr ptr ptr ptr)
@ cdecl wined3d_device_copy_resource(ptr ptr ptr) @ cdecl wined3d_device_copy_resource(ptr ptr ptr)
@ cdecl wined3d_device_copy_sub_resource_region(ptr ptr long long long long ptr long ptr)
@ cdecl wined3d_device_create(ptr long long ptr long long ptr ptr) @ cdecl wined3d_device_create(ptr long long ptr long long ptr ptr)
@ cdecl wined3d_device_decref(ptr) @ cdecl wined3d_device_decref(ptr)
@ cdecl wined3d_device_draw_indexed_primitive(ptr long long) @ cdecl wined3d_device_draw_indexed_primitive(ptr long long)

View File

@ -2137,6 +2137,10 @@ HRESULT __cdecl wined3d_device_clear_rendertarget_view(struct wined3d_device *de
struct wined3d_rendertarget_view *view, const RECT *rect, const struct wined3d_color *color); struct wined3d_rendertarget_view *view, const RECT *rect, const struct wined3d_color *color);
void __cdecl wined3d_device_copy_resource(struct wined3d_device *device, void __cdecl wined3d_device_copy_resource(struct wined3d_device *device,
struct wined3d_resource *dst_resource, struct wined3d_resource *src_resource); struct wined3d_resource *dst_resource, struct wined3d_resource *src_resource);
void __cdecl wined3d_device_copy_sub_resource_region(struct wined3d_device *device,
struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx, unsigned int dst_x,
unsigned int dst_y, unsigned int dst_z, struct wined3d_resource *src_resource,
unsigned int src_sub_resource_idx, const struct wined3d_box *src_box);
HRESULT __cdecl wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx, HRESULT __cdecl wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx,
enum wined3d_device_type device_type, HWND focus_window, DWORD behaviour_flags, BYTE surface_alignment, enum wined3d_device_type device_type, HWND focus_window, DWORD behaviour_flags, BYTE surface_alignment,
struct wined3d_device_parent *device_parent, struct wined3d_device **device); struct wined3d_device_parent *device_parent, struct wined3d_device **device);