Module: wine Branch: master Commit: 176e60074b2b69d28d53adbe6606bf7c5eaf1fc5 URL: http://source.winehq.org/git/wine.git/?a=commit;h=176e60074b2b69d28d53adbe66...
Author: Józef Kucia jkucia@codeweavers.com Date: Tue Jan 3 13:46:33 2017 +0100
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
---
dlls/d3d8/d3d8_private.h | 1 + dlls/d3d8/device.c | 7 ++++++- dlls/d3d8/surface.c | 7 +++++++ dlls/d3d8/tests/device.c | 6 +++--- 4 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index f55d2c2..ffcd1cd 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -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; diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index fae5610..5a5871f 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -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; - } }
diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c index 565f642..137033e 100644 --- a/dlls/d3d8/surface.c +++ b/dlls/d3d8/surface.c @@ -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; diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 2dbf9d8..22667ec 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -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);