Module: wine Branch: master Commit: 09fda3b805b2defeb04f8df6ca7acbe25f2ae10d URL: http://source.winehq.org/git/wine.git/?a=commit;h=09fda3b805b2defeb04f8df6ca...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Fri Jun 27 08:26:59 2014 +0200
d3d9: Improve d3d9_device_TestCooperativeLevel().
---
dlls/d3d10core/device.c | 6 ++++++ dlls/d3d8/device.c | 6 ++++++ dlls/d3d9/d3d9_private.h | 9 ++++++++- dlls/d3d9/device.c | 40 +++++++++++++++++++++++++++++++++------- dlls/d3d9/tests/device.c | 4 ++-- dlls/ddraw/ddraw.c | 6 ++++++ dlls/wined3d/device.c | 4 ++++ include/wine/wined3d.h | 1 + 8 files changed, 66 insertions(+), 10 deletions(-)
diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c index 722b5aa..db3f265 100644 --- a/dlls/d3d10core/device.c +++ b/dlls/d3d10core/device.c @@ -1935,6 +1935,11 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic TRACE("device_parent %p.\n", device_parent); }
+static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate) +{ + TRACE("device_parent %p, activate %#x.\n", device_parent, activate); +} + static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent, void *container_parent, struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops) @@ -2033,6 +2038,7 @@ static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops = { device_parent_wined3d_device_created, device_parent_mode_changed, + device_parent_activate, device_parent_surface_created, device_parent_volume_created, device_parent_create_swapchain_surface, diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index c83d16c..53a832e 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -2921,6 +2921,11 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic TRACE("device_parent %p.\n", device_parent); }
+static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate) +{ + TRACE("device_parent %p, activate %#x.\n", device_parent, activate); +} + static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent, void *container_parent, struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops) @@ -3034,6 +3039,7 @@ static const struct wined3d_device_parent_ops d3d8_wined3d_device_parent_ops = { device_parent_wined3d_device_created, device_parent_mode_changed, + device_parent_activate, device_parent_surface_created, device_parent_volume_created, device_parent_create_swapchain_surface, diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index 8d75f62..8c685e4 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -139,6 +139,13 @@ struct fvf_declaration DWORD fvf; };
+enum d3d9_device_state +{ + D3D9_DEVICE_STATE_OK, + D3D9_DEVICE_STATE_LOST, + D3D9_DEVICE_STATE_NOT_RESET, +}; + struct d3d9_device { IDirect3DDevice9Ex IDirect3DDevice9Ex_iface; @@ -157,8 +164,8 @@ struct d3d9_device UINT index_buffer_size; UINT index_buffer_pos;
+ LONG device_state; BOOL in_destruction; - BOOL not_reset; BOOL in_scene; };
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 263ac12..57ad1e7 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -323,13 +323,21 @@ static HRESULT WINAPI d3d9_device_TestCooperativeLevel(IDirect3DDevice9Ex *iface
TRACE("iface %p.\n", iface);
- if (device->not_reset) + TRACE("device state: %#x.\n", device->device_state); + + if (device->d3d_parent->extended) + return D3D_OK; + + switch (device->device_state) { - TRACE("D3D9 device is marked not reset.\n"); - return D3DERR_DEVICENOTRESET; + default: + case D3D9_DEVICE_STATE_OK: + return D3D_OK; + case D3D9_DEVICE_STATE_LOST: + return D3DERR_DEVICELOST; + case D3D9_DEVICE_STATE_NOT_RESET: + return D3DERR_DEVICENOTRESET; } - - return D3D_OK; }
static UINT WINAPI d3d9_device_GetAvailableTextureMem(IDirect3DDevice9Ex *iface) @@ -621,9 +629,9 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Reset(IDirect3DDevice9Ex *if hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc, NULL, reset_enum_callback, !device->d3d_parent->extended); if (FAILED(hr) && !device->d3d_parent->extended) - device->not_reset = TRUE; + device->device_state = D3D9_DEVICE_STATE_NOT_RESET; else - device->not_reset = FALSE; + device->device_state = D3D9_DEVICE_STATE_OK; wined3d_mutex_unlock();
return hr; @@ -3414,6 +3422,23 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic TRACE("device_parent %p.\n", device_parent); }
+static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate) +{ + struct d3d9_device *device = device_from_device_parent(device_parent); + + TRACE("device_parent %p, activate %#x.\n", device_parent, activate); + + if (!device->d3d_parent) + return; + + if (!activate) + InterlockedCompareExchange(&device->device_state, D3D9_DEVICE_STATE_LOST, D3D9_DEVICE_STATE_OK); + else if (device->d3d_parent->extended) + InterlockedCompareExchange(&device->device_state, D3D9_DEVICE_STATE_OK, D3D9_DEVICE_STATE_LOST); + else + InterlockedCompareExchange(&device->device_state, D3D9_DEVICE_STATE_NOT_RESET, D3D9_DEVICE_STATE_LOST); +} + static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent, void *container_parent, struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops) @@ -3531,6 +3556,7 @@ static const struct wined3d_device_parent_ops d3d9_wined3d_device_parent_ops = { device_parent_wined3d_device_created, device_parent_mode_changed, + device_parent_activate, device_parent_surface_created, device_parent_volume_created, device_parent_create_swapchain_surface, diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index bfd5e5a..edf3fa8 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -8930,7 +8930,7 @@ static void test_lost_device(void) ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); hr = IDirect3DDevice9_TestCooperativeLevel(device); - todo_wine ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr); + ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); todo_wine ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
@@ -8939,7 +8939,7 @@ static void test_lost_device(void) ret = SetForegroundWindow(window); ok(ret, "Failed to set foreground window.\n"); hr = IDirect3DDevice9_TestCooperativeLevel(device); - todo_wine ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr); + ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); todo_wine ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index b62d5f6..617474b 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -4722,6 +4722,11 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic ERR("Failed to resize window.\n"); }
+static void CDECL device_parent_activate(struct wined3d_device_parent *device_parent, BOOL activate) +{ + TRACE("device_parent %p, activate %#x.\n", device_parent, activate); +} + static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent, void *container_parent, struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops) @@ -4846,6 +4851,7 @@ static const struct wined3d_device_parent_ops ddraw_wined3d_device_parent_ops = { device_parent_wined3d_device_created, device_parent_mode_changed, + device_parent_activate, device_parent_surface_created, device_parent_volume_created, device_parent_create_swapchain_surface, diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 4cd6342..65f4ad7 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4775,6 +4775,10 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL { device->device_parent->ops->mode_changed(device->device_parent); } + else if (message == WM_ACTIVATEAPP) + { + device->device_parent->ops->activate(device->device_parent, wparam); + }
if (unicode) return CallWindowProcW(proc, window, message, wparam, lparam); diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 328b595..f21abaf 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -1981,6 +1981,7 @@ struct wined3d_device_parent_ops { void (__cdecl *wined3d_device_created)(struct wined3d_device_parent *device_parent, struct wined3d_device *device); void (__cdecl *mode_changed)(struct wined3d_device_parent *device_parent); + void (__cdecl *activate)(struct wined3d_device_parent *device_parent, BOOL activate); HRESULT (__cdecl *surface_created)(struct wined3d_device_parent *device_parent, void *container_parent, struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops); HRESULT (__cdecl *volume_created)(struct wined3d_device_parent *device_parent, void *container_parent,