From 20d5be042c577b8dfcca431fa4688cad192196df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Wed, 14 Oct 2015 11:09:55 +0200 Subject: [PATCH] d3d8: Call IDirect3DSwapChain8::Present in IDirect3DDevice8::Present. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Dösinger Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d8/d3d8_private.h | 4 ++++ dlls/d3d8/device.c | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 3069487b9eb..9a5de928a49 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -176,6 +176,10 @@ struct d3d8_device LONG device_state; /* Avoids recursion with nested ReleaseRef to 0 */ BOOL inDestruction; + + /* The d3d8 API supports only one implicit swapchain (no D3DCREATE_ADAPTERGROUP_DEVICE, + * no GetSwapchain, GetBackBuffer doesn't accept a swapchain number). */ + struct d3d8_swapchain *implicit_swapchain; }; HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wined3d *wined3d, UINT adapter, diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 0648f51bf80..20ce900417c 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -705,20 +705,17 @@ static HRESULT WINAPI d3d8_device_Present(IDirect3DDevice8 *iface, const RECT *s const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region) { struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); - HRESULT hr; TRACE("iface %p, src_rect %s, dst_rect %s, dst_window_override %p, dirty_region %p.\n", iface, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect), dst_window_override, dirty_region); - if (device->device_state != D3D8_DEVICE_STATE_OK) - return D3DERR_DEVICELOST; - - wined3d_mutex_lock(); - hr = wined3d_device_present(device->wined3d_device, src_rect, dst_rect, - dst_window_override, dirty_region, 0); - wined3d_mutex_unlock(); - - return hr; + /* Fraps does not hook IDirect3DDevice8::Present regardless of the hotpatch + * attribute. It only hooks IDirect3DSwapChain8::Present. Yet it properly + * shows a framerate on Windows in applications that only call the device + * method, like e.g. the dx8 sdk samples. The conclusion is that native + * calls the swapchain's public method from the device. */ + return IDirect3DSwapChain8_Present(&device->implicit_swapchain->IDirect3DSwapChain8_iface, + src_rect, dst_rect, dst_window_override, dirty_region); } static HRESULT WINAPI d3d8_device_GetBackBuffer(IDirect3DDevice8 *iface, @@ -3114,6 +3111,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters) { struct wined3d_swapchain_desc swapchain_desc; + struct wined3d_swapchain *wined3d_swapchain; HRESULT hr; device->IDirect3DDevice8_iface.lpVtbl = &d3d8_device_vtbl; @@ -3200,6 +3198,9 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine goto err; } + wined3d_swapchain = wined3d_device_get_swapchain(device->wined3d_device, 0); + device->implicit_swapchain = wined3d_swapchain_get_parent(wined3d_swapchain); + device->d3d_parent = &parent->IDirect3D8_iface; IDirect3D8_AddRef(device->d3d_parent);