wined3d: Introduce a new wined3d_texture_blt function.

Signed-off-by: Riccardo Bortolato <rikyz619@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Riccardo Bortolato 2015-10-16 13:59:19 +02:00 committed by Alexandre Julliard
parent 6671535dc3
commit 6241ce5637
6 changed files with 37 additions and 11 deletions

View File

@ -233,7 +233,6 @@ struct d3d8_surface
struct d3d8_resource resource; struct d3d8_resource resource;
struct wined3d_texture *wined3d_texture; struct wined3d_texture *wined3d_texture;
unsigned int sub_resource_idx; unsigned int sub_resource_idx;
struct wined3d_surface *wined3d_surface;
struct list rtv_entry; struct list rtv_entry;
struct wined3d_rendertarget_view *wined3d_rtv; struct wined3d_rendertarget_view *wined3d_rtv;
IDirect3DDevice8 *parent_device; 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; 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, 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_surface *unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface) DECLSPEC_HIDDEN;
struct d3d8_vertexbuffer struct d3d8_vertexbuffer

View File

@ -1085,8 +1085,8 @@ static HRESULT WINAPI d3d8_device_CopyRects(IDirect3DDevice8 *iface,
if (!rect_count && !src_rects && !dst_points) if (!rect_count && !src_rects && !dst_points)
{ {
RECT rect = {0, 0, src_w, src_h}; RECT rect = {0, 0, src_w, src_h};
wined3d_surface_blt(dst->wined3d_surface, &rect, wined3d_texture_blt(dst->wined3d_texture, dst->sub_resource_idx, &rect,
src->wined3d_surface, &rect, 0, NULL, WINED3D_TEXF_POINT); src->wined3d_texture, src->sub_resource_idx, &rect, 0, NULL, WINED3D_TEXF_POINT);
} }
else else
{ {
@ -1101,8 +1101,8 @@ static HRESULT WINAPI d3d8_device_CopyRects(IDirect3DDevice8 *iface,
RECT dst_rect = {dst_points[i].x, dst_points[i].y, RECT dst_rect = {dst_points[i].x, dst_points[i].y,
dst_points[i].x + w, dst_points[i].y + h}; dst_points[i].x + w, dst_points[i].y + h};
wined3d_surface_blt(dst->wined3d_surface, &dst_rect, wined3d_texture_blt(dst->wined3d_texture, dst->sub_resource_idx, &dst_rect,
src->wined3d_surface, &src_rects[i], 0, NULL, WINED3D_TEXF_POINT); src->wined3d_texture, src->sub_resource_idx, &src_rects[i], 0, NULL, WINED3D_TEXF_POINT);
} }
} }
else else
@ -1113,8 +1113,8 @@ static HRESULT WINAPI d3d8_device_CopyRects(IDirect3DDevice8 *iface,
UINT h = src_rects[i].bottom - src_rects[i].top; UINT h = src_rects[i].bottom - src_rects[i].top;
RECT dst_rect = {0, 0, w, h}; RECT dst_rect = {0, 0, w, h};
wined3d_surface_blt(dst->wined3d_surface, &dst_rect, wined3d_texture_blt(dst->wined3d_texture, dst->sub_resource_idx, &dst_rect,
src->wined3d_surface, &src_rects[i], 0, NULL, WINED3D_TEXF_POINT); 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)))) if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface))))
return E_OUTOFMEMORY; 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; *parent = d3d_surface;
TRACE("Created surface %p.\n", d3d_surface); TRACE("Created surface %p.\n", d3d_surface);

View File

@ -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, 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; IDirect3DBaseTexture8 *texture;
surface->IDirect3DSurface8_iface.lpVtbl = &d3d8_surface_vtbl; surface->IDirect3DSurface8_iface.lpVtbl = &d3d8_surface_vtbl;
d3d8_resource_init(&surface->resource); d3d8_resource_init(&surface->resource);
surface->resource.refcount = 0; surface->resource.refcount = 0;
surface->wined3d_surface = wined3d_surface;
list_init(&surface->rtv_entry); list_init(&surface->rtv_entry);
surface->container = wined3d_texture_get_parent(wined3d_texture); surface->container = wined3d_texture_get_parent(wined3d_texture);
surface->wined3d_texture = wined3d_texture; surface->wined3d_texture = wined3d_texture;

View File

@ -1434,6 +1434,30 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
return WINED3D_OK; 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, 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, 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) const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture)

View File

@ -257,6 +257,7 @@
@ cdecl wined3d_swapchain_set_window(ptr ptr) @ cdecl wined3d_swapchain_set_window(ptr ptr)
@ cdecl wined3d_texture_add_dirty_region(ptr long 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_create(ptr ptr long long ptr ptr ptr ptr)
@ cdecl wined3d_texture_decref(ptr) @ cdecl wined3d_texture_decref(ptr)
@ cdecl wined3d_texture_generate_mipmaps(ptr) @ cdecl wined3d_texture_generate_mipmaps(ptr)

View File

@ -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, HRESULT __cdecl wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
UINT layer, const struct wined3d_box *dirty_region); 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, 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, 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); const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);