Commit 6a1a18e7 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d10core: Implement d3d10_device_CopyResource().

parent 80bca9bc
...@@ -60,6 +60,7 @@ const char *debug_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN; ...@@ -60,6 +60,7 @@ const char *debug_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN;
DXGI_FORMAT dxgi_format_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; DXGI_FORMAT dxgi_format_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN;
enum wined3d_format_id wined3dformat_from_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN; enum wined3d_format_id wined3dformat_from_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN;
DWORD wined3d_usage_from_d3d10core(UINT bind_flags, enum D3D10_USAGE usage) DECLSPEC_HIDDEN; DWORD wined3d_usage_from_d3d10core(UINT bind_flags, enum D3D10_USAGE usage) DECLSPEC_HIDDEN;
struct wined3d_resource *wined3d_resource_from_resource(ID3D10Resource *resource) DECLSPEC_HIDDEN;
static inline void read_dword(const char **ptr, DWORD *d) static inline void read_dword(const char **ptr, DWORD *d)
{ {
...@@ -86,6 +87,7 @@ struct d3d10_texture2d ...@@ -86,6 +87,7 @@ struct d3d10_texture2d
HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d10_device *device, HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d10_device *device,
const D3D10_TEXTURE2D_DESC *desc) DECLSPEC_HIDDEN; const D3D10_TEXTURE2D_DESC *desc) DECLSPEC_HIDDEN;
struct d3d10_texture2d *unsafe_impl_from_ID3D10Texture2D(ID3D10Texture2D *iface) DECLSPEC_HIDDEN;
/* ID3D10Texture3D */ /* ID3D10Texture3D */
struct d3d10_texture3d struct d3d10_texture3d
......
...@@ -514,7 +514,14 @@ static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 * ...@@ -514,7 +514,14 @@ static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *
static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface, static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface,
ID3D10Resource *dst_resource, ID3D10Resource *src_resource) ID3D10Resource *dst_resource, ID3D10Resource *src_resource)
{ {
FIXME("iface %p, dst_resource %p, src_resource %p stub!\n", iface, dst_resource, src_resource); struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource;
struct d3d10_device *device = impl_from_ID3D10Device(iface);
TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst_resource, src_resource);
wined3d_dst_resource = wined3d_resource_from_resource(dst_resource);
wined3d_src_resource = wined3d_resource_from_resource(src_resource);
wined3d_device_copy_resource(device->wined3d_device, wined3d_dst_resource, wined3d_src_resource);
} }
static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *iface, static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *iface,
......
...@@ -236,6 +236,14 @@ static const struct ID3D10Texture2DVtbl d3d10_texture2d_vtbl = ...@@ -236,6 +236,14 @@ static const struct ID3D10Texture2DVtbl d3d10_texture2d_vtbl =
d3d10_texture2d_GetDesc, d3d10_texture2d_GetDesc,
}; };
struct d3d10_texture2d *unsafe_impl_from_ID3D10Texture2D(ID3D10Texture2D *iface)
{
if (!iface)
return NULL;
assert(iface->lpVtbl == &d3d10_texture2d_vtbl);
return CONTAINING_RECORD(iface, struct d3d10_texture2d, ID3D10Texture2D_iface);
}
static const struct wined3d_parent_ops d3d10_texture2d_wined3d_parent_ops = static const struct wined3d_parent_ops d3d10_texture2d_wined3d_parent_ops =
{ {
d3d10_texture2d_wined3d_object_released, d3d10_texture2d_wined3d_object_released,
......
...@@ -367,6 +367,28 @@ DWORD wined3d_usage_from_d3d10core(UINT bind_flags, enum D3D10_USAGE usage) ...@@ -367,6 +367,28 @@ DWORD wined3d_usage_from_d3d10core(UINT bind_flags, enum D3D10_USAGE usage)
return wined3d_usage; return wined3d_usage;
} }
struct wined3d_resource *wined3d_resource_from_resource(ID3D10Resource *resource)
{
D3D10_RESOURCE_DIMENSION dimension;
ID3D10Resource_GetType(resource, &dimension);
switch (dimension)
{
case D3D10_RESOURCE_DIMENSION_BUFFER:
return wined3d_buffer_get_resource(unsafe_impl_from_ID3D10Buffer(
(ID3D10Buffer *)resource)->wined3d_buffer);
case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
return wined3d_texture_get_resource(unsafe_impl_from_ID3D10Texture2D(
(ID3D10Texture2D *)resource)->wined3d_texture);
default:
FIXME("Unhandled resource dimension %#x.\n", dimension);
return NULL;
}
}
void skip_dword_unknown(const char **ptr, unsigned int count) void skip_dword_unknown(const char **ptr, unsigned int count)
{ {
unsigned int i; unsigned int i;
......
...@@ -25,26 +25,6 @@ ...@@ -25,26 +25,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d10core); WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
static struct wined3d_resource *wined3d_resource_from_resource(ID3D10Resource *resource)
{
D3D10_RESOURCE_DIMENSION dimension;
ID3D10Resource_GetType(resource, &dimension);
switch(dimension)
{
case D3D10_RESOURCE_DIMENSION_BUFFER:
return wined3d_buffer_get_resource(((struct d3d10_buffer *)resource)->wined3d_buffer);
case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
return wined3d_texture_get_resource(((struct d3d10_texture2d *)resource)->wined3d_texture);
default:
FIXME("Unhandled resource dimension %#x.\n", dimension);
return NULL;
}
}
static HRESULT set_dsdesc_from_resource(D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10Resource *resource) static HRESULT set_dsdesc_from_resource(D3D10_DEPTH_STENCIL_VIEW_DESC *desc, ID3D10Resource *resource)
{ {
D3D10_RESOURCE_DIMENSION dimension; D3D10_RESOURCE_DIMENSION dimension;
......
...@@ -3664,6 +3664,77 @@ HRESULT CDECL wined3d_device_color_fill(struct wined3d_device *device, ...@@ -3664,6 +3664,77 @@ HRESULT CDECL wined3d_device_color_fill(struct wined3d_device *device,
return surface_color_fill(surface, rect, color); return surface_color_fill(surface, rect, color);
} }
void CDECL wined3d_device_copy_resource(struct wined3d_device *device,
struct wined3d_resource *dst_resource, struct wined3d_resource *src_resource)
{
struct wined3d_surface *dst_surface, *src_surface;
struct wined3d_texture *dst_texture, *src_texture;
unsigned int i, count;
HRESULT hr;
TRACE("device %p, dst_resource %p, src_resource %p.\n", device, dst_resource, src_resource);
if (src_resource == dst_resource)
{
WARN("Source and destination are the same 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->width != dst_resource->width
|| src_resource->height != dst_resource->height
|| src_resource->depth != dst_resource->depth)
{
WARN("Resource dimensions (%ux%ux%u / %ux%ux%u) don't match.\n",
dst_resource->width, dst_resource->height, dst_resource->depth,
src_resource->width, src_resource->height, src_resource->depth);
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);
src_texture = wined3d_texture_from_resource(src_resource);
if (src_texture->layer_count != dst_texture->layer_count
|| src_texture->level_count != dst_texture->level_count)
{
WARN("Subresource layouts (%ux%u / %ux%u) don't match.\n",
dst_texture->layer_count, dst_texture->level_count,
src_texture->layer_count, src_texture->level_count);
return;
}
count = dst_texture->layer_count * dst_texture->level_count;
for (i = 0; i < count; ++i)
{
dst_surface = surface_from_resource(wined3d_texture_get_sub_resource(dst_texture, i));
src_surface = surface_from_resource(wined3d_texture_get_sub_resource(src_texture, i));
if (FAILED(hr = wined3d_surface_blt(dst_surface, NULL, src_surface, NULL, 0, NULL, WINED3D_TEXF_POINT)))
ERR("Failed to blit, subresource %u, hr %#x.\n", i, hr);
}
}
void CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *device, void CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *device,
struct wined3d_rendertarget_view *rendertarget_view, const struct wined3d_color *color) struct wined3d_rendertarget_view *rendertarget_view, const struct wined3d_color *color)
{ {
......
...@@ -38,6 +38,7 @@ ...@@ -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) @ cdecl wined3d_device_clear_rendertarget_view(ptr ptr ptr)
@ cdecl wined3d_device_color_fill(ptr ptr ptr ptr) @ cdecl wined3d_device_color_fill(ptr ptr ptr ptr)
@ cdecl wined3d_device_copy_resource(ptr ptr 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)
......
...@@ -2080,6 +2080,8 @@ void __cdecl wined3d_device_clear_rendertarget_view(struct wined3d_device *devic ...@@ -2080,6 +2080,8 @@ void __cdecl wined3d_device_clear_rendertarget_view(struct wined3d_device *devic
struct wined3d_rendertarget_view *rendertarget_view, const struct wined3d_color *color); struct wined3d_rendertarget_view *rendertarget_view, const struct wined3d_color *color);
HRESULT __cdecl wined3d_device_color_fill(struct wined3d_device *device, struct wined3d_surface *surface, HRESULT __cdecl wined3d_device_color_fill(struct wined3d_device *device, struct wined3d_surface *surface,
const RECT *rect, const struct wined3d_color *color); const RECT *rect, const struct wined3d_color *color);
void __cdecl wined3d_device_copy_resource(struct wined3d_device *device,
struct wined3d_resource *dst_resource, struct wined3d_resource *src_resource);
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment