d3d8: Reject render target surfaces created for other devices.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2017-01-03 13:46:33 +01:00 committed by Alexandre Julliard
parent c1aba7cd8b
commit 176e60074b
4 changed files with 17 additions and 4 deletions

View File

@ -242,6 +242,7 @@ struct d3d8_surface
struct d3d8_texture *texture;
};
struct d3d8_device *d3d8_surface_get_device(const 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,
const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;

View File

@ -1161,6 +1161,12 @@ static HRESULT WINAPI d3d8_device_SetRenderTarget(IDirect3DDevice8 *iface,
TRACE("iface %p, render_target %p, depth_stencil %p.\n", iface, render_target, depth_stencil);
if (rt_impl && d3d8_surface_get_device(rt_impl) != device)
{
WARN("Render target surface does not match device.\n");
return D3DERR_INVALIDCALL;
}
wined3d_mutex_lock();
if (ds_impl)
@ -1200,7 +1206,6 @@ static HRESULT WINAPI d3d8_device_SetRenderTarget(IDirect3DDevice8 *iface,
WARN("Multisample settings do not match, returning D3DERR_INVALIDCALL\n");
wined3d_mutex_unlock();
return D3DERR_INVALIDCALL;
}
}

View File

@ -353,6 +353,13 @@ static const struct wined3d_parent_ops d3d8_view_wined3d_parent_ops =
view_wined3d_object_destroyed,
};
struct d3d8_device *d3d8_surface_get_device(const struct d3d8_surface *surface)
{
IDirect3DDevice8 *device;
device = surface->texture ? surface->texture->parent_device : surface->parent_device;
return impl_from_IDirect3DDevice8(device);
}
struct wined3d_rendertarget_view *d3d8_surface_get_rendertarget_view(struct d3d8_surface *surface)
{
HRESULT hr;

View File

@ -8115,7 +8115,7 @@ static void test_render_target_device_mismatch(void)
ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetRenderTarget(device, surface, NULL);
todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
IDirect3DSurface8_Release(surface);
@ -8123,13 +8123,13 @@ static void test_render_target_device_mismatch(void)
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetRenderTarget(device, surface, NULL);
todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
IDirect3DSurface8_Release(surface);
hr = IDirect3DDevice8_GetRenderTarget(device, &surface);
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
todo_wine ok(surface == rt, "Got unexpected render target %p, expected %p.\n", surface, rt);
ok(surface == rt, "Got unexpected render target %p, expected %p.\n", surface, rt);
IDirect3DSurface8_Release(surface);
IDirect3DSurface8_Release(rt);