Commit c1aba7cd authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3d9: Reject render target surfaces created for other devices.

parent f93fbcad
......@@ -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;
......
......@@ -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();
......
......@@ -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;
......
......@@ -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);
......
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