From 6241ce5637d53d8355d5d3b06b014066be599c9d Mon Sep 17 00:00:00 2001 From: Riccardo Bortolato Date: Fri, 16 Oct 2015 13:59:19 +0200 Subject: [PATCH] wined3d: Introduce a new wined3d_texture_blt function. Signed-off-by: Riccardo Bortolato Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d8/d3d8_private.h | 3 +-- dlls/d3d8/device.c | 14 +++++++------- dlls/d3d8/surface.c | 3 +-- dlls/wined3d/texture.c | 24 ++++++++++++++++++++++++ dlls/wined3d/wined3d.spec | 1 + include/wine/wined3d.h | 3 +++ 6 files changed, 37 insertions(+), 11 deletions(-) diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 9a5de928a49..958b3c0c61b 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -233,7 +233,6 @@ struct d3d8_surface struct d3d8_resource resource; struct wined3d_texture *wined3d_texture; unsigned int sub_resource_idx; - struct wined3d_surface *wined3d_surface; struct list rtv_entry; struct wined3d_rendertarget_view *wined3d_rtv; IDirect3DDevice8 *parent_device; @@ -243,7 +242,7 @@ struct d3d8_surface struct wined3d_rendertarget_view *d3d8_surface_get_rendertarget_view(struct d3d8_surface *surface) DECLSPEC_HIDDEN; void surface_init(struct d3d8_surface *surface, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, - struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; + const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; struct d3d8_surface *unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface) DECLSPEC_HIDDEN; struct d3d8_vertexbuffer diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index ae6bebbf0c7..6c942432c6b 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1085,8 +1085,8 @@ static HRESULT WINAPI d3d8_device_CopyRects(IDirect3DDevice8 *iface, if (!rect_count && !src_rects && !dst_points) { RECT rect = {0, 0, src_w, src_h}; - wined3d_surface_blt(dst->wined3d_surface, &rect, - src->wined3d_surface, &rect, 0, NULL, WINED3D_TEXF_POINT); + wined3d_texture_blt(dst->wined3d_texture, dst->sub_resource_idx, &rect, + src->wined3d_texture, src->sub_resource_idx, &rect, 0, NULL, WINED3D_TEXF_POINT); } else { @@ -1101,8 +1101,8 @@ static HRESULT WINAPI d3d8_device_CopyRects(IDirect3DDevice8 *iface, RECT dst_rect = {dst_points[i].x, dst_points[i].y, dst_points[i].x + w, dst_points[i].y + h}; - wined3d_surface_blt(dst->wined3d_surface, &dst_rect, - src->wined3d_surface, &src_rects[i], 0, NULL, WINED3D_TEXF_POINT); + wined3d_texture_blt(dst->wined3d_texture, dst->sub_resource_idx, &dst_rect, + src->wined3d_texture, src->sub_resource_idx, &src_rects[i], 0, NULL, WINED3D_TEXF_POINT); } } else @@ -1113,8 +1113,8 @@ static HRESULT WINAPI d3d8_device_CopyRects(IDirect3DDevice8 *iface, UINT h = src_rects[i].bottom - src_rects[i].top; RECT dst_rect = {0, 0, w, h}; - wined3d_surface_blt(dst->wined3d_surface, &dst_rect, - src->wined3d_surface, &src_rects[i], 0, NULL, WINED3D_TEXF_POINT); + wined3d_texture_blt(dst->wined3d_texture, dst->sub_resource_idx, &dst_rect, + src->wined3d_texture, src->sub_resource_idx, &src_rects[i], 0, NULL, WINED3D_TEXF_POINT); } } } @@ -3003,7 +3003,7 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface)))) return E_OUTOFMEMORY; - surface_init(d3d_surface, wined3d_texture, sub_resource_idx, surface, parent_ops); + surface_init(d3d_surface, wined3d_texture, sub_resource_idx, parent_ops); *parent = d3d_surface; TRACE("Created surface %p.\n", d3d_surface); diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c index 077502d3bc8..81533404306 100644 --- a/dlls/d3d8/surface.c +++ b/dlls/d3d8/surface.c @@ -301,14 +301,13 @@ static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops = }; void surface_init(struct d3d8_surface *surface, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, - struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) + const struct wined3d_parent_ops **parent_ops) { IDirect3DBaseTexture8 *texture; surface->IDirect3DSurface8_iface.lpVtbl = &d3d8_surface_vtbl; d3d8_resource_init(&surface->resource); surface->resource.refcount = 0; - surface->wined3d_surface = wined3d_surface; list_init(&surface->rtv_entry); surface->container = wined3d_texture_get_parent(wined3d_texture); surface->wined3d_texture = wined3d_texture; diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index f00553ae82b..7aa723e1940 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1434,6 +1434,30 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct return WINED3D_OK; } +HRESULT CDECL wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, const RECT *dst_rect_in, + struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, const RECT *src_rect_in, DWORD flags, + const WINEDDBLTFX *fx, enum wined3d_texture_filter_type filter) +{ + struct wined3d_resource *dst_resource, *src_resource = NULL; + + TRACE("dst_texture %p, dst_sub_resource_idx %u, src_texture %p, src_sub_resource_idx %u.\n", + dst_texture, dst_sub_resource_idx, src_texture, src_sub_resource_idx); + + if (!(dst_resource = wined3d_texture_get_sub_resource(dst_texture, dst_sub_resource_idx)) + || dst_resource->type != WINED3D_RTYPE_SURFACE) + return WINED3DERR_INVALIDCALL; + + if (src_texture) + { + if (!(src_resource = wined3d_texture_get_sub_resource(src_texture, src_sub_resource_idx)) + || src_resource->type != WINED3D_RTYPE_SURFACE) + return WINED3DERR_INVALIDCALL; + } + + return wined3d_surface_blt(surface_from_resource(dst_resource), dst_rect_in, + src_resource ? surface_from_resource(src_resource) : NULL, src_rect_in, flags, fx, filter); +} + HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct wined3d_resource_desc *desc, UINT level_count, DWORD surface_flags, const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture) diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index da1cbc4a8e2..9a266c9c782 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -257,6 +257,7 @@ @ cdecl wined3d_swapchain_set_window(ptr ptr) @ cdecl wined3d_texture_add_dirty_region(ptr long ptr) +@ cdecl wined3d_texture_blt(ptr long ptr ptr long ptr long ptr long) @ cdecl wined3d_texture_create(ptr ptr long long ptr ptr ptr ptr) @ cdecl wined3d_texture_decref(ptr) @ cdecl wined3d_texture_generate_mipmaps(ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index cb412e438ec..6f98c342400 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2527,6 +2527,9 @@ void __cdecl wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain, H HRESULT __cdecl wined3d_texture_add_dirty_region(struct wined3d_texture *texture, UINT layer, const struct wined3d_box *dirty_region); +HRESULT __cdecl wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigned int dst_idx, const RECT *dst_rect_in, + struct wined3d_texture *src_texture, unsigned int src_idx, const RECT *src_rect_in, DWORD flags, + const WINEDDBLTFX *fx, enum wined3d_texture_filter_type filter); HRESULT __cdecl wined3d_texture_create(struct wined3d_device *device, const struct wined3d_resource_desc *desc, UINT level_count, DWORD surface_flags, const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);