Commit cf30899f authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Version 1 devices are aggregated by the surface that created them.

parent e13de0ad
......@@ -4426,7 +4426,7 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid,
TRACE("iface %p, riid %s, surface %p, device %p.\n", iface, debugstr_guid(riid), surface, device);
wined3d_mutex_lock();
hr = d3d_device_create(ddraw, target, 7, &object);
hr = d3d_device_create(ddraw, target, 7, &object, NULL);
if (SUCCEEDED(hr))
*device = &object->IDirect3DDevice7_iface;
else
......@@ -4454,7 +4454,7 @@ static HRESULT WINAPI d3d3_CreateDevice(IDirect3D3 *iface, REFCLSID riid,
return CLASS_E_NOAGGREGATION;
wined3d_mutex_lock();
hr = d3d_device_create(ddraw, surface_impl, 3, &device_impl);
hr = d3d_device_create(ddraw, surface_impl, 3, &device_impl, NULL);
if (SUCCEEDED(hr))
*device = &device_impl->IDirect3DDevice3_iface;
else
......@@ -4479,7 +4479,7 @@ static HRESULT WINAPI d3d2_CreateDevice(IDirect3D2 *iface, REFCLSID riid,
iface, debugstr_guid(riid), surface, device);
wined3d_mutex_lock();
hr = d3d_device_create(ddraw, surface_impl, 2, &device_impl);
hr = d3d_device_create(ddraw, surface_impl, 2, &device_impl, NULL);
if (SUCCEEDED(hr))
*device = &device_impl->IDirect3DDevice2_iface;
else
......
......@@ -159,6 +159,7 @@ struct ddraw_surface
struct ddraw *ddraw;
struct wined3d_surface *wined3d_surface;
struct wined3d_texture *wined3d_texture;
IDirect3DDeviceImpl *device1;
/* This implementation handles attaching surfaces to other surfaces */
struct ddraw_surface *next_attached;
......@@ -278,10 +279,11 @@ struct IDirect3DDeviceImpl
IDirect3DDevice3 IDirect3DDevice3_iface;
IDirect3DDevice2 IDirect3DDevice2_iface;
IDirect3DDevice IDirect3DDevice_iface;
IUnknown IUnknown_inner;
LONG ref;
UINT version;
/* Other object connections */
IUnknown *outer_unknown;
struct wined3d_device *wined3d_device;
struct ddraw *ddraw;
struct wined3d_buffer *indexbuffer;
......@@ -316,7 +318,7 @@ struct IDirect3DDeviceImpl
};
HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target,
UINT version, IDirect3DDeviceImpl **device) DECLSPEC_HIDDEN;
UINT version, IDirect3DDeviceImpl **device, IUnknown *outer_unknown) DECLSPEC_HIDDEN;
/* The IID */
extern const GUID IID_D3DDEVICE_WineD3D DECLSPEC_HIDDEN;
......
......@@ -204,19 +204,23 @@ static HRESULT WINAPI ddraw_surface7_QueryInterface(IDirectDrawSurface7 *iface,
|| IsEqualGUID(riid, &IID_IDirect3DHALDevice)
|| IsEqualGUID(riid, &IID_IDirect3DRGBDevice))
{
IDirect3DDeviceImpl *device;
HRESULT hr;
wined3d_mutex_lock();
hr = d3d_device_create(This->ddraw, This, 1, &device);
wined3d_mutex_unlock();
if (FAILED(hr))
if (!This->device1)
{
WARN("Failed to create device, hr %#x.\n", hr);
return hr;
HRESULT hr = d3d_device_create(This->ddraw, This, 1, &This->device1,
(IUnknown *)&This->IDirectDrawSurface_iface);
if (FAILED(hr))
{
This->device1 = NULL;
wined3d_mutex_unlock();
WARN("Failed to create device, hr %#x.\n", hr);
return hr;
}
}
wined3d_mutex_unlock();
*obj = &device->IDirect3DDevice_iface;
IDirect3DDevice_AddRef(&This->device1->IDirect3DDevice_iface);
*obj = &This->device1->IDirect3DDevice_iface;
return S_OK;
}
......@@ -502,6 +506,8 @@ static void ddraw_surface_cleanup(struct ddraw_surface *surface)
}
}
if (surface->device1)
IUnknown_Release(&surface->device1->IUnknown_inner);
ifaceToRelease = surface->ifaceToRelease;
/* Destroy the root surface. */
......
......@@ -3523,7 +3523,6 @@ static void FindDevice(void)
hr = IDirectDrawSurface_QueryInterface(Surface1, &IID_IDirect3DHALDevice, (void **)&d3dhal);
/* Currently Wine only supports the creation of one Direct3D device
* for a given DirectDraw instance. */
todo_wine
ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDPIXELFORMAT) /* XP/Win2003 Wow64 on VMware */,
"Expected IDirectDrawSurface::QueryInterface to succeed, got 0x%08x\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment