From: Józef Kucia Subject: [PATCH v2 6/6] wined3d: Allow copying sub-resource regions between compatible formats. Message-Id: <20170317121204.29413-2-jkucia@codeweavers.com> Date: Fri, 17 Mar 2017 13:12:04 +0100 In-Reply-To: <20170317121204.29413-1-jkucia@codeweavers.com> References: <20170317121204.29413-1-jkucia@codeweavers.com> Signed-off-by: Józef Kucia --- Version 2: A grammar fix in the subject. --- dlls/d3d9/device.c | 20 ++++++++++++++++++-- dlls/wined3d/device.c | 5 +++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 74070af..1f7c62c 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1395,6 +1395,8 @@ static HRESULT WINAPI d3d9_device_UpdateSurface(IDirect3DDevice9Ex *iface, struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_surface *src = unsafe_impl_from_IDirect3DSurface9(src_surface); struct d3d9_surface *dst = unsafe_impl_from_IDirect3DSurface9(dst_surface); + struct wined3d_resource *dst_resource, *src_resource; + struct wined3d_resource_desc src_desc, dst_desc; struct wined3d_box src_box; HRESULT hr; @@ -1412,9 +1414,23 @@ static HRESULT WINAPI d3d9_device_UpdateSurface(IDirect3DDevice9Ex *iface, } wined3d_mutex_lock(); + + dst_resource = wined3d_texture_get_resource(dst->wined3d_texture); + src_resource = wined3d_texture_get_resource(src->wined3d_texture); + wined3d_resource_get_desc(dst_resource, &dst_desc); + wined3d_resource_get_desc(src_resource, &src_desc); + if (dst_desc.format != src_desc.format) + { + wined3d_mutex_unlock(); + WARN("Surface formats (%#x / %#x) don't match.\n", + d3dformat_from_wined3dformat(dst_desc.format), + d3dformat_from_wined3dformat(src_desc.format)); + return D3DERR_INVALIDCALL; + } + hr = wined3d_device_copy_sub_resource_region(device->wined3d_device, - wined3d_texture_get_resource(dst->wined3d_texture), dst->sub_resource_idx, dst_point ? dst_point->x : 0, - dst_point ? dst_point->y : 0, 0, wined3d_texture_get_resource(src->wined3d_texture), + dst_resource, dst->sub_resource_idx, dst_point ? dst_point->x : 0, + dst_point ? dst_point->y : 0, 0, src_resource, src->sub_resource_idx, src_rect ? &src_box : NULL); wined3d_mutex_unlock(); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 5f7ef5e..358a62e 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3949,9 +3949,10 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev return WINED3DERR_INVALIDCALL; } - if (src_resource->format->id != dst_resource->format->id) + if (src_resource->format->typeless_id != dst_resource->format->typeless_id + || (!src_resource->format->typeless_id && src_resource->format->id != dst_resource->format->id)) { - WARN("Resource formats (%s / %s) don't match.\n", + WARN("Incompatible formats (%s / %s).\n", debug_d3dformat(dst_resource->format->id), debug_d3dformat(src_resource->format->id)); return WINED3DERR_INVALIDCALL; -- 2.10.2