d3d9: 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:32 +01:00 committed by Alexandre Julliard
parent f93fbcad41
commit c1aba7cd8b
4 changed files with 19 additions and 5 deletions

View file

@ -230,6 +230,7 @@ struct d3d9_surface
struct d3d9_texture *texture;
};
struct d3d9_device *d3d9_surface_get_device(const struct d3d9_surface *surface) DECLSPEC_HIDDEN;
struct wined3d_rendertarget_view *d3d9_surface_get_rendertarget_view(struct d3d9_surface *surface) DECLSPEC_HIDDEN;
void surface_init(struct d3d9_surface *surface, struct wined3d_texture *wined3d_texture,
unsigned int sub_resource_idx, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;

View file

@ -1523,8 +1523,14 @@ static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex *iface, DWO
if (!idx && !surface_impl)
{
WARN("Trying to set render target 0 to NULL.\n");
return D3DERR_INVALIDCALL;
WARN("Trying to set render target 0 to NULL.\n");
return D3DERR_INVALIDCALL;
}
if (surface_impl && d3d9_surface_get_device(surface_impl) != device)
{
WARN("Render target surface does not match device.\n");
return D3DERR_INVALIDCALL;
}
wined3d_mutex_lock();

View file

@ -389,6 +389,13 @@ static const struct wined3d_parent_ops d3d9_view_wined3d_parent_ops =
view_wined3d_object_destroyed,
};
struct d3d9_device *d3d9_surface_get_device(const struct d3d9_surface *surface)
{
IDirect3DDevice9Ex *device;
device = surface->texture ? surface->texture->parent_device : surface->parent_device;
return impl_from_IDirect3DDevice9Ex(device);
}
struct wined3d_rendertarget_view *d3d9_surface_get_rendertarget_view(struct d3d9_surface *surface)
{
HRESULT hr;

View file

@ -11375,7 +11375,7 @@ static void test_render_target_device_mismatch(void)
ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderTarget(device, 0, surface);
todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
IDirect3DSurface9_Release(surface);
@ -11383,13 +11383,13 @@ static void test_render_target_device_mismatch(void)
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderTarget(device, 0, surface);
todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
IDirect3DSurface9_Release(surface);
hr = IDirect3DDevice9_GetRenderTarget(device, 0, &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);
IDirect3DSurface9_Release(surface);
IDirect3DSurface9_Release(rt);