=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: d3d9: Reject render target surfaces created for other devices.
Alexandre Julliard
julliard at winehq.org
Tue Jan 3 15:31:04 CST 2017
Module: wine
Branch: master
Commit: c1aba7cd8b35f100e594805956964b962dc30a42
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c1aba7cd8b35f100e594805956964b962dc30a42
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Tue Jan 3 13:46:32 2017 +0100
d3d9: Reject render target surfaces created for other devices.
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/d3d9/d3d9_private.h | 1 +
dlls/d3d9/device.c | 10 ++++++++--
dlls/d3d9/surface.c | 7 +++++++
dlls/d3d9/tests/device.c | 6 +++---
4 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index 3317e9c..20c4c5c 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -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;
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index dab19ab..d47c705 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -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();
diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c
index be68682..12e0f39 100644
--- a/dlls/d3d9/surface.c
+++ b/dlls/d3d9/surface.c
@@ -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;
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index fbae9d6..aa266a5 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -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);
More information about the wine-cvs
mailing list