d3d8: Call IDirect3DSwapChain8::Present in IDirect3DDevice8::Present.

Signed-off-by: Stefan Dösinger <stefan@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Stefan Dösinger 2015-10-14 11:09:55 +02:00 committed by Alexandre Julliard
parent 3b54ec6a34
commit 20d5be042c
2 changed files with 15 additions and 10 deletions

View File

@ -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,

View File

@ -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);