d3d8: Get rid of IDirect3D8Impl.

This commit is contained in:
Henri Verbeet 2012-05-03 21:49:37 +02:00 committed by Alexandre Julliard
parent 5a4c15b9d9
commit e103a7a52d
4 changed files with 139 additions and 153 deletions

View File

@ -37,7 +37,7 @@ void WINAPI DebugSetMute(void) {
IDirect3D8 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT sdk_version) IDirect3D8 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT sdk_version)
{ {
IDirect3D8Impl *object; struct d3d8 *object;
TRACE("sdk_version %#x.\n", sdk_version); TRACE("sdk_version %#x.\n", sdk_version);

View File

@ -100,9 +100,6 @@
void fixup_caps(WINED3DCAPS *pWineCaps) DECLSPEC_HIDDEN; void fixup_caps(WINED3DCAPS *pWineCaps) DECLSPEC_HIDDEN;
/* Direct3D8 Interfaces: */
typedef struct IDirect3DBaseTexture8Impl IDirect3DBaseTexture8Impl;
typedef struct IDirect3D8Impl IDirect3D8Impl;
typedef struct IDirect3DDevice8Impl IDirect3DDevice8Impl; typedef struct IDirect3DDevice8Impl IDirect3DDevice8Impl;
typedef struct IDirect3DIndexBuffer8Impl IDirect3DIndexBuffer8Impl; typedef struct IDirect3DIndexBuffer8Impl IDirect3DIndexBuffer8Impl;
typedef struct IDirect3DSurface8Impl IDirect3DSurface8Impl; typedef struct IDirect3DSurface8Impl IDirect3DSurface8Impl;
@ -110,17 +107,14 @@ typedef struct IDirect3DSwapChain8Impl IDirect3DSwapChain8Impl;
typedef struct IDirect3DVolume8Impl IDirect3DVolume8Impl; typedef struct IDirect3DVolume8Impl IDirect3DVolume8Impl;
typedef struct IDirect3DVertexBuffer8Impl IDirect3DVertexBuffer8Impl; typedef struct IDirect3DVertexBuffer8Impl IDirect3DVertexBuffer8Impl;
/***************************************************************************** struct d3d8
* IDirect3D implementation structure
*/
struct IDirect3D8Impl
{ {
IDirect3D8 IDirect3D8_iface; IDirect3D8 IDirect3D8_iface;
LONG ref; LONG refcount;
struct wined3d *WineD3D; struct wined3d *wined3d;
}; };
BOOL d3d8_init(IDirect3D8Impl *d3d8) DECLSPEC_HIDDEN; BOOL d3d8_init(struct d3d8 *d3d8) DECLSPEC_HIDDEN;
/***************************************************************************** /*****************************************************************************
* IDirect3DDevice8 implementation structure * IDirect3DDevice8 implementation structure
@ -176,7 +170,7 @@ struct IDirect3DDevice8Impl
BOOL lost; BOOL lost;
}; };
HRESULT device_init(IDirect3DDevice8Impl *device, IDirect3D8Impl *parent, struct wined3d *wined3d, UINT adapter, HRESULT device_init(IDirect3DDevice8Impl *device, struct d3d8 *parent, struct wined3d *wined3d, UINT adapter,
D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters) DECLSPEC_HIDDEN; D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters) DECLSPEC_HIDDEN;
/* ---------------- */ /* ---------------- */

View File

@ -3065,7 +3065,7 @@ static void setup_fpu(void)
#endif #endif
} }
HRESULT device_init(IDirect3DDevice8Impl *device, IDirect3D8Impl *parent, struct wined3d *wined3d, UINT adapter, HRESULT device_init(IDirect3DDevice8Impl *device, struct d3d8 *parent, struct wined3d *wined3d, UINT adapter,
D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters) D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters)
{ {
struct wined3d_swapchain_desc swapchain_desc; struct wined3d_swapchain_desc swapchain_desc;

View File

@ -37,251 +37,247 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d8); WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
static inline IDirect3D8Impl *impl_from_IDirect3D8(IDirect3D8 *iface) static inline struct d3d8 *impl_from_IDirect3D8(IDirect3D8 *iface)
{ {
return CONTAINING_RECORD(iface, IDirect3D8Impl, IDirect3D8_iface); return CONTAINING_RECORD(iface, struct d3d8, IDirect3D8_iface);
} }
static HRESULT WINAPI IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface, REFIID riid,LPVOID *ppobj) static HRESULT WINAPI d3d8_QueryInterface(IDirect3D8 *iface, REFIID riid, void **out)
{ {
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj); TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
if (IsEqualGUID(riid, &IID_IDirect3D8) if (IsEqualGUID(riid, &IID_IDirect3D8)
|| IsEqualGUID(riid, &IID_IUnknown)) || IsEqualGUID(riid, &IID_IUnknown))
{ {
IUnknown_AddRef(iface); IUnknown_AddRef(iface);
*ppobj = iface; *out = iface;
return S_OK; return S_OK;
} }
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*ppobj = NULL; *out = NULL;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG WINAPI IDirect3D8Impl_AddRef(LPDIRECT3D8 iface) static ULONG WINAPI d3d8_AddRef(IDirect3D8 *iface)
{ {
IDirect3D8Impl *This = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
ULONG ref = InterlockedIncrement(&This->ref); ULONG refcount = InterlockedIncrement(&d3d8->refcount);
TRACE("%p increasing refcount to %u.\n", iface, ref); TRACE("%p increasing refcount to %u.\n", iface, refcount);
return ref; return refcount;
} }
static ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface) static ULONG WINAPI d3d8_Release(IDirect3D8 *iface)
{ {
IDirect3D8Impl *This = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
ULONG ref = InterlockedDecrement(&This->ref); ULONG refcount = InterlockedDecrement(&d3d8->refcount);
TRACE("%p decreasing refcount to %u.\n", iface, ref); TRACE("%p decreasing refcount to %u.\n", iface, refcount);
if (ref == 0) {
TRACE("Releasing wined3d %p\n", This->WineD3D);
if (!refcount)
{
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_decref(This->WineD3D); wined3d_decref(d3d8->wined3d);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, d3d8);
} }
return ref; return refcount;
} }
static HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice(LPDIRECT3D8 iface, static HRESULT WINAPI d3d8_RegisterSoftwareDevice(IDirect3D8 *iface, void *init_function)
void* pInitializeFunction)
{ {
IDirect3D8Impl *This = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p, init_function %p.\n", iface, pInitializeFunction); TRACE("iface %p, init_function %p.\n", iface, init_function);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_register_software_device(This->WineD3D, pInitializeFunction); hr = wined3d_register_software_device(d3d8->wined3d, init_function);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
} }
static UINT WINAPI IDirect3D8Impl_GetAdapterCount(LPDIRECT3D8 iface) static UINT WINAPI d3d8_GetAdapterCount(IDirect3D8 *iface)
{ {
IDirect3D8Impl *This = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_get_adapter_count(This->WineD3D); hr = wined3d_get_adapter_count(d3d8->wined3d);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
} }
static HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier(LPDIRECT3D8 iface, UINT Adapter, static HRESULT WINAPI d3d8_GetAdapterIdentifier(IDirect3D8 *iface, UINT adapter,
DWORD Flags, D3DADAPTER_IDENTIFIER8 *pIdentifier) DWORD flags, D3DADAPTER_IDENTIFIER8 *identifier)
{ {
IDirect3D8Impl *This = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
struct wined3d_adapter_identifier adapter_id; struct wined3d_adapter_identifier adapter_id;
HRESULT hr; HRESULT hr;
TRACE("iface %p, adapter %u, flags %#x, identifier %p.\n", TRACE("iface %p, adapter %u, flags %#x, identifier %p.\n",
iface, Adapter, Flags, pIdentifier); iface, adapter, flags, identifier);
adapter_id.driver = pIdentifier->Driver; adapter_id.driver = identifier->Driver;
adapter_id.driver_size = sizeof(pIdentifier->Driver); adapter_id.driver_size = sizeof(identifier->Driver);
adapter_id.description = pIdentifier->Description; adapter_id.description = identifier->Description;
adapter_id.description_size = sizeof(pIdentifier->Description); adapter_id.description_size = sizeof(identifier->Description);
adapter_id.device_name = NULL; /* d3d9 only */ adapter_id.device_name = NULL; /* d3d9 only */
adapter_id.device_name_size = 0; /* d3d9 only */ adapter_id.device_name_size = 0; /* d3d9 only */
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_get_adapter_identifier(This->WineD3D, Adapter, Flags, &adapter_id); hr = wined3d_get_adapter_identifier(d3d8->wined3d, adapter, flags, &adapter_id);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
pIdentifier->DriverVersion = adapter_id.driver_version; identifier->DriverVersion = adapter_id.driver_version;
pIdentifier->VendorId = adapter_id.vendor_id; identifier->VendorId = adapter_id.vendor_id;
pIdentifier->DeviceId = adapter_id.device_id; identifier->DeviceId = adapter_id.device_id;
pIdentifier->SubSysId = adapter_id.subsystem_id; identifier->SubSysId = adapter_id.subsystem_id;
pIdentifier->Revision = adapter_id.revision; identifier->Revision = adapter_id.revision;
memcpy(&pIdentifier->DeviceIdentifier, &adapter_id.device_identifier, sizeof(pIdentifier->DeviceIdentifier)); memcpy(&identifier->DeviceIdentifier, &adapter_id.device_identifier, sizeof(identifier->DeviceIdentifier));
pIdentifier->WHQLLevel = adapter_id.whql_level; identifier->WHQLLevel = adapter_id.whql_level;
return hr; return hr;
} }
static UINT WINAPI IDirect3D8Impl_GetAdapterModeCount(LPDIRECT3D8 iface,UINT Adapter) static UINT WINAPI d3d8_GetAdapterModeCount(IDirect3D8 *iface, UINT adapter)
{ {
IDirect3D8Impl *This = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p, adapter %u.\n", iface, Adapter); TRACE("iface %p, adapter %u.\n", iface, adapter);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_get_adapter_mode_count(This->WineD3D, Adapter, 0); hr = wined3d_get_adapter_mode_count(d3d8->wined3d, adapter, 0);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
} }
static HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes(LPDIRECT3D8 iface, UINT Adapter, UINT Mode, static HRESULT WINAPI d3d8_EnumAdapterModes(IDirect3D8 *iface, UINT adapter, UINT mode_idx, D3DDISPLAYMODE *mode)
D3DDISPLAYMODE* pMode)
{ {
IDirect3D8Impl *This = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p, adapter %u, mode_idx %u, mode %p.\n", TRACE("iface %p, adapter %u, mode_idx %u, mode %p.\n",
iface, Adapter, Mode, pMode); iface, adapter, mode_idx, mode);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_enum_adapter_modes(This->WineD3D, Adapter, WINED3DFMT_UNKNOWN, hr = wined3d_enum_adapter_modes(d3d8->wined3d, adapter, WINED3DFMT_UNKNOWN,
Mode, (struct wined3d_display_mode *)pMode); mode_idx, (struct wined3d_display_mode *)mode);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format); if (SUCCEEDED(hr))
mode->Format = d3dformat_from_wined3dformat(mode->Format);
return hr; return hr;
} }
static HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode(LPDIRECT3D8 iface, UINT Adapter, static HRESULT WINAPI d3d8_GetAdapterDisplayMode(IDirect3D8 *iface, UINT adapter, D3DDISPLAYMODE *mode)
D3DDISPLAYMODE* pMode)
{ {
IDirect3D8Impl *This = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p, adapter %u, mode %p.\n", TRACE("iface %p, adapter %u, mode %p.\n",
iface, Adapter, pMode); iface, adapter, mode);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_get_adapter_display_mode(This->WineD3D, Adapter, (struct wined3d_display_mode *)pMode); hr = wined3d_get_adapter_display_mode(d3d8->wined3d, adapter, (struct wined3d_display_mode *)mode);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format); if (SUCCEEDED(hr))
mode->Format = d3dformat_from_wined3dformat(mode->Format);
return hr; return hr;
} }
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceType(LPDIRECT3D8 iface, UINT Adapter, static HRESULT WINAPI d3d8_CheckDeviceType(IDirect3D8 *iface, UINT adapter, D3DDEVTYPE device_type,
D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed) D3DFORMAT display_format, D3DFORMAT backbuffer_format, BOOL windowed)
{ {
IDirect3D8Impl *This = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n", TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n",
iface, Adapter, CheckType, DisplayFormat, BackBufferFormat, Windowed); iface, adapter, device_type, display_format, backbuffer_format, windowed);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_check_device_type(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat), hr = wined3d_check_device_type(d3d8->wined3d, adapter, device_type, wined3dformat_from_d3dformat(display_format),
wined3dformat_from_d3dformat(BackBufferFormat), Windowed); wined3dformat_from_d3dformat(backbuffer_format), windowed);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
} }
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat(LPDIRECT3D8 iface, UINT Adapter, static HRESULT WINAPI d3d8_CheckDeviceFormat(IDirect3D8 *iface, UINT adapter, D3DDEVTYPE device_type,
D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT adapter_format, DWORD usage, D3DRESOURCETYPE resource_type, D3DFORMAT format)
D3DFORMAT CheckFormat)
{ {
IDirect3D8Impl *This = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
enum wined3d_resource_type wined3d_rtype; enum wined3d_resource_type wined3d_rtype;
HRESULT hr; HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, usage %#x, resource_type %#x, format %#x.\n", TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, usage %#x, resource_type %#x, format %#x.\n",
iface, Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat); iface, adapter, device_type, adapter_format, usage, resource_type, format);
switch(RType) { switch (resource_type)
{
case D3DRTYPE_VERTEXBUFFER: case D3DRTYPE_VERTEXBUFFER:
case D3DRTYPE_INDEXBUFFER: case D3DRTYPE_INDEXBUFFER:
wined3d_rtype = WINED3D_RTYPE_BUFFER; wined3d_rtype = WINED3D_RTYPE_BUFFER;
break; break;
default: default:
wined3d_rtype = RType; wined3d_rtype = resource_type;
break; break;
} }
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_check_device_format(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat), hr = wined3d_check_device_format(d3d8->wined3d, adapter, device_type, wined3dformat_from_d3dformat(adapter_format),
Usage, wined3d_rtype, wined3dformat_from_d3dformat(CheckFormat), WINED3D_SURFACE_TYPE_OPENGL); usage, wined3d_rtype, wined3dformat_from_d3dformat(format), WINED3D_SURFACE_TYPE_OPENGL);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
} }
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType(IDirect3D8 *iface, UINT Adapter, static HRESULT WINAPI d3d8_CheckDeviceMultiSampleType(IDirect3D8 *iface, UINT adapter, D3DDEVTYPE device_type,
D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DFORMAT format, BOOL windowed, D3DMULTISAMPLE_TYPE multisample_type)
D3DMULTISAMPLE_TYPE MultiSampleType)
{ {
IDirect3D8Impl *This = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x.\n", TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x.\n",
iface, Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType); iface, adapter, device_type, format, windowed, multisample_type);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_check_device_multisample_type(This->WineD3D, Adapter, DeviceType, hr = wined3d_check_device_multisample_type(d3d8->wined3d, adapter, device_type,
wined3dformat_from_d3dformat(SurfaceFormat), Windowed, wined3dformat_from_d3dformat(format), windowed,
(enum wined3d_multisample_type)MultiSampleType, NULL); (enum wined3d_multisample_type)multisample_type, NULL);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
} }
static HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(IDirect3D8 *iface, UINT Adapter, static HRESULT WINAPI d3d8_CheckDepthStencilMatch(IDirect3D8 *iface, UINT adapter, D3DDEVTYPE device_type,
D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT adapter_format, D3DFORMAT rt_format, D3DFORMAT ds_format)
D3DFORMAT DepthStencilFormat)
{ {
IDirect3D8Impl *This = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, rt_format %#x, ds_format %#x.\n", TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, rt_format %#x, ds_format %#x.\n",
iface, Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat); iface, adapter, device_type, adapter_format, rt_format, ds_format);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_check_depth_stencil_match(This->WineD3D, Adapter, DeviceType, hr = wined3d_check_depth_stencil_match(d3d8->wined3d, adapter, device_type,
wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat), wined3dformat_from_d3dformat(adapter_format), wined3dformat_from_d3dformat(rt_format),
wined3dformat_from_d3dformat(DepthStencilFormat)); wined3dformat_from_d3dformat(ds_format));
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
@ -303,54 +299,50 @@ void fixup_caps(WINED3DCAPS *caps)
caps->StencilCaps &= ~WINED3DSTENCILCAPS_TWOSIDED; caps->StencilCaps &= ~WINED3DSTENCILCAPS_TWOSIDED;
} }
static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, static HRESULT WINAPI d3d8_GetDeviceCaps(IDirect3D8 *iface, UINT adapter, D3DDEVTYPE device_type, D3DCAPS8 *caps)
D3DDEVTYPE DeviceType, D3DCAPS8* pCaps)
{ {
IDirect3D8Impl *This = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
HRESULT hrc = D3D_OK; WINED3DCAPS *wined3d_caps;
WINED3DCAPS *pWineCaps; HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, caps %p.\n", iface, Adapter, DeviceType, pCaps); TRACE("iface %p, adapter %u, device_type %#x, caps %p.\n", iface, adapter, device_type, caps);
if(NULL == pCaps){ if (!caps)
return D3DERR_INVALIDCALL;
if (!(wined3d_caps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wined3d_caps))))
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
}
pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
if(pWineCaps == NULL){
return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
}
wined3d_mutex_lock(); wined3d_mutex_lock();
hrc = wined3d_get_device_caps(This->WineD3D, Adapter, DeviceType, pWineCaps); hr = wined3d_get_device_caps(d3d8->wined3d, adapter, device_type, wined3d_caps);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
fixup_caps(pWineCaps); fixup_caps(wined3d_caps);
WINECAPSTOD3D8CAPS(pCaps, pWineCaps) WINECAPSTOD3D8CAPS(caps, wined3d_caps)
HeapFree(GetProcessHeap(), 0, pWineCaps); HeapFree(GetProcessHeap(), 0, wined3d_caps);
TRACE("(%p) returning %p\n", This, pCaps); return hr;
return hrc;
} }
static HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter) static HMONITOR WINAPI d3d8_GetAdapterMonitor(IDirect3D8 *iface, UINT adapter)
{ {
IDirect3D8Impl *This = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
HMONITOR ret; HMONITOR ret;
TRACE("iface %p, adapter %u.\n", iface, Adapter); TRACE("iface %p, adapter %u.\n", iface, adapter);
wined3d_mutex_lock(); wined3d_mutex_lock();
ret = wined3d_get_adapter_monitor(This->WineD3D, Adapter); ret = wined3d_get_adapter_monitor(d3d8->wined3d, adapter);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return ret; return ret;
} }
static HRESULT WINAPI IDirect3D8Impl_CreateDevice(IDirect3D8 *iface, UINT adapter, static HRESULT WINAPI d3d8_CreateDevice(IDirect3D8 *iface, UINT adapter,
D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters, D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters,
IDirect3DDevice8 **device) IDirect3DDevice8 **device)
{ {
IDirect3D8Impl *This = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
IDirect3DDevice8Impl *object; IDirect3DDevice8Impl *object;
HRESULT hr; HRESULT hr;
@ -364,7 +356,7 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(IDirect3D8 *iface, UINT adapte
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
hr = device_init(object, This, This->WineD3D, adapter, device_type, focus_window, flags, parameters); hr = device_init(object, d3d8, d3d8->wined3d, adapter, device_type, focus_window, flags, parameters);
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to initialize device, hr %#x.\n", hr); WARN("Failed to initialize device, hr %#x.\n", hr);
@ -378,37 +370,37 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(IDirect3D8 *iface, UINT adapte
return D3D_OK; return D3D_OK;
} }
static const struct IDirect3D8Vtbl Direct3D8_Vtbl = static const struct IDirect3D8Vtbl d3d8_vtbl =
{ {
/* IUnknown */ /* IUnknown */
IDirect3D8Impl_QueryInterface, d3d8_QueryInterface,
IDirect3D8Impl_AddRef, d3d8_AddRef,
IDirect3D8Impl_Release, d3d8_Release,
/* IDirect3D8 */ /* IDirect3D8 */
IDirect3D8Impl_RegisterSoftwareDevice, d3d8_RegisterSoftwareDevice,
IDirect3D8Impl_GetAdapterCount, d3d8_GetAdapterCount,
IDirect3D8Impl_GetAdapterIdentifier, d3d8_GetAdapterIdentifier,
IDirect3D8Impl_GetAdapterModeCount, d3d8_GetAdapterModeCount,
IDirect3D8Impl_EnumAdapterModes, d3d8_EnumAdapterModes,
IDirect3D8Impl_GetAdapterDisplayMode, d3d8_GetAdapterDisplayMode,
IDirect3D8Impl_CheckDeviceType, d3d8_CheckDeviceType,
IDirect3D8Impl_CheckDeviceFormat, d3d8_CheckDeviceFormat,
IDirect3D8Impl_CheckDeviceMultiSampleType, d3d8_CheckDeviceMultiSampleType,
IDirect3D8Impl_CheckDepthStencilMatch, d3d8_CheckDepthStencilMatch,
IDirect3D8Impl_GetDeviceCaps, d3d8_GetDeviceCaps,
IDirect3D8Impl_GetAdapterMonitor, d3d8_GetAdapterMonitor,
IDirect3D8Impl_CreateDevice d3d8_CreateDevice,
}; };
BOOL d3d8_init(IDirect3D8Impl *d3d8) BOOL d3d8_init(struct d3d8 *d3d8)
{ {
d3d8->IDirect3D8_iface.lpVtbl = &Direct3D8_Vtbl; d3d8->IDirect3D8_iface.lpVtbl = &d3d8_vtbl;
d3d8->ref = 1; d3d8->refcount = 1;
wined3d_mutex_lock(); wined3d_mutex_lock();
d3d8->WineD3D = wined3d_create(8, WINED3D_LEGACY_DEPTH_BIAS); d3d8->wined3d = wined3d_create(8, WINED3D_LEGACY_DEPTH_BIAS);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
if (!d3d8->WineD3D) if (!d3d8->wined3d)
return FALSE; return FALSE;
return TRUE; return TRUE;