Add a IWineD3DDevice object type (empty for now), and create one when

an IDirect3DDevice object is created.
This commit is contained in:
Jason Edmeades 2004-10-07 04:22:21 +00:00 committed by Alexandre Julliard
parent 370f220744
commit ac490fabac
8 changed files with 185 additions and 8 deletions

View File

@ -196,9 +196,6 @@ struct IDirect3D9Impl
IWineD3D *WineD3D; IWineD3D *WineD3D;
/* IDirect3D9 fields */ /* IDirect3D9 fields */
/*
GL_Info gl_info;
*/
}; };
/* IUnknown: */ /* IUnknown: */
@ -242,7 +239,9 @@ struct IDirect3DDevice9Impl
/* IDirect3DDevice9 fields */ /* IDirect3DDevice9 fields */
IDirect3D9Impl *direct3d; IDirect3D9Impl *direct3d;
IWineD3DDevice *WineD3DDevice;
/* FIXME: To be sorted out during move */
IDirect3DSurface9Impl *frontBuffer; IDirect3DSurface9Impl *frontBuffer;
IDirect3DSurface9Impl *backBuffer; IDirect3DSurface9Impl *backBuffer;
IDirect3DSurface9Impl *depthStencilBuffer; IDirect3DSurface9Impl *depthStencilBuffer;

View File

@ -67,6 +67,7 @@ ULONG WINAPI IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9 iface) {
ULONG ref = --This->ref; ULONG ref = --This->ref;
TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref); TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
if (ref == 0) { if (ref == 0) {
IDirect3D9_Release((LPDIRECT3D9) This->direct3d);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;

View File

@ -168,8 +168,35 @@ HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3
DWORD BehaviourFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, DWORD BehaviourFlags, D3DPRESENT_PARAMETERS* pPresentationParameters,
IDirect3DDevice9** ppReturnedDeviceInterface) { IDirect3DDevice9** ppReturnedDeviceInterface) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface; IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
FIXME("(%p) : stub\n", This); IDirect3DDevice9Impl *object = NULL;
WINED3DPRESENT_PARAMETERS localParameters;
TRACE("(%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %lx, PresParms: %p, RetDevInt: %p)\n", This, Adapter, DeviceType,
hFocusWindow, BehaviourFlags, pPresentationParameters, ppReturnedDeviceInterface);
/* Check the validity range of the adapter parameter */
if (Adapter >= IDirect3D9Impl_GetAdapterCount(iface)) {
return D3DERR_INVALIDCALL;
}
/* Allocate the storage for the device object */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDevice9Impl));
if (NULL == object) {
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DDevice9_Vtbl;
object->ref = 1;
object->direct3d = This;
IDirect3D9_AddRef((LPDIRECT3D9) object->direct3d);
*ppReturnedDeviceInterface = (IDirect3DDevice9 *)object;
/* Allocate an associated WineD3DDevice object */
memcpy(&localParameters, pPresentationParameters, sizeof(D3DPRESENT_PARAMETERS));
IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice);
memcpy(pPresentationParameters, &localParameters, sizeof(D3DPRESENT_PARAMETERS));
FIXME("(%p) : incomplete stub\n", This);
return D3D_OK; return D3D_OK;
} }

View File

@ -8,6 +8,7 @@ EXTRAINCL = @X_CFLAGS@
EXTRALIBS = -ldxguid -luuid @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@ @OPENGL_LIBS@ EXTRALIBS = -ldxguid -luuid @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@ @OPENGL_LIBS@
C_SRCS = \ C_SRCS = \
device.c \
directx.c \ directx.c \
utils.c \ utils.c \
vertexshader.c \ vertexshader.c \

75
dlls/wined3d/device.c Normal file
View File

@ -0,0 +1,75 @@
/*
* IWineD3DDevice implementation
*
* Copyright 2002-2004 Jason Edmeades
* Copyright 2003-2004 Raphael Junqueira
* Copyright 2004 Christian Costa
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DECLARE_DEBUG_CHANNEL(d3d_caps);
/**********************************************************
* Utility functions follow
**********************************************************/
/**********************************************************
* IWineD3DDevice implementation follows
**********************************************************/
/**********************************************************
* IUnknown parts follows
**********************************************************/
HRESULT WINAPI IWineD3DDeviceImpl_QueryInterface(IWineD3DDevice *iface,REFIID riid,LPVOID *ppobj)
{
return E_NOINTERFACE;
}
ULONG WINAPI IWineD3DDeviceImpl_AddRef(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
FIXME("(%p) : AddRef increasing from %ld\n", This, This->ref);
return InterlockedIncrement(&This->ref);
}
ULONG WINAPI IWineD3DDeviceImpl_Release(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %ld\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
IWineD3D_Release(This->WineD3D);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/**********************************************************
* IWineD3DDevice VTbl follows
**********************************************************/
IWineD3DDeviceVtbl IWineD3DDevice_Vtbl =
{
IWineD3DDeviceImpl_QueryInterface,
IWineD3DDeviceImpl_AddRef,
IWineD3DDeviceImpl_Release
};

View File

@ -1306,6 +1306,24 @@ HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, D3DDEVT
return D3D_OK; return D3D_OK;
} }
/* Note due to structure differences between dx8 and dx9 D3DPRESENT_PARAMETERS,
and fields being inserted in the middle, a new structure is used in place */
HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
DWORD BehaviourFlags, WINED3DPRESENT_PARAMETERS* pPresentationParameters,
IWineD3DDevice** ppReturnedDeviceInterface) {
/* Create a WineD3DDevice object */
IWineD3DDeviceImpl* object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DDeviceImpl));
object->lpVtbl = &IWineD3DDevice_Vtbl;
object->ref = 1;
object->WineD3D = iface;
IWineD3D_AddRef(object->WineD3D);
*ppReturnedDeviceInterface = (IWineD3DDevice *)object;
TRACE("Created WineD3DDevice object @ %p \n", object);
return D3D_OK;
}
/********************************************************** /**********************************************************
* IUnknown parts follows * IUnknown parts follows
**********************************************************/ **********************************************************/
@ -1351,5 +1369,6 @@ IWineD3DVtbl IWineD3D_Vtbl =
IWineD3DImpl_CheckDeviceType, IWineD3DImpl_CheckDeviceType,
IWineD3DImpl_CheckDeviceFormat, IWineD3DImpl_CheckDeviceFormat,
IWineD3DImpl_CheckDeviceFormatConversion, IWineD3DImpl_CheckDeviceFormatConversion,
IWineD3DImpl_GetDeviceCaps IWineD3DImpl_GetDeviceCaps,
IWineD3DImpl_CreateDevice
}; };

View File

@ -94,6 +94,23 @@ typedef struct IWineD3DImpl
extern IWineD3DVtbl IWineD3D_Vtbl; extern IWineD3DVtbl IWineD3D_Vtbl;
/*****************************************************************************
* IWineD3DDevice implementation structure
*/
typedef struct IWineD3DDeviceImpl
{
/* IUnknown fields */
IWineD3DDeviceVtbl *lpVtbl;
DWORD ref; /* Note: Ref counting not required */
/* WineD3D Information */
IWineD3D *WineD3D;
/* GL Information */
} IWineD3DDeviceImpl;
extern IWineD3DDeviceVtbl IWineD3DDevice_Vtbl;
/* Utility function prototypes */ /* Utility function prototypes */
const char* debug_d3dformat(D3DFORMAT fmt); const char* debug_d3dformat(D3DFORMAT fmt);
const char* debug_d3ddevicetype(D3DDEVTYPE devtype); const char* debug_d3ddevicetype(D3DDEVTYPE devtype);

View File

@ -53,12 +53,29 @@ typedef struct _WINED3DADAPTER_IDENTIFIER {
DWORD *WHQLLevel; DWORD *WHQLLevel;
} WINED3DADAPTER_IDENTIFIER; } WINED3DADAPTER_IDENTIFIER;
typedef struct _WINED3DPRESENT_PARAMETERS {
UINT BackBufferWidth;
UINT BackBufferHeight;
D3DFORMAT BackBufferFormat;
UINT BackBufferCount;
D3DMULTISAMPLE_TYPE MultiSampleType;
DWORD MultiSampleQuality;
D3DSWAPEFFECT SwapEffect;
HWND hDeviceWindow;
BOOL Windowed;
BOOL EnableAutoDepthStencil;
D3DFORMAT AutoDepthStencilFormat;
DWORD Flags;
UINT FullScreen_RefreshRateInHz;
UINT PresentationInterval;
} WINED3DPRESENT_PARAMETERS;
typedef struct IWineD3D IWineD3D;
typedef struct IWineD3DDevice IWineD3DDevice;
/***************************************************************************** /*****************************************************************************
* WineD3D interface * WineD3D interface
*/ */
typedef struct IWineD3D IWineD3D;
#define INTERFACE IWineD3D #define INTERFACE IWineD3D
DECLARE_INTERFACE_(IWineD3D,IUnknown) DECLARE_INTERFACE_(IWineD3D,IUnknown)
@ -81,6 +98,7 @@ DECLARE_INTERFACE_(IWineD3D,IUnknown)
STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) PURE; STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) PURE;
STDMETHOD(CheckDeviceFormatConversion)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) PURE; STDMETHOD(CheckDeviceFormatConversion)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) PURE;
STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, void * pCaps) PURE; STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, void * pCaps) PURE;
STDMETHOD(CreateDevice)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType,HWND hFocusWindow, DWORD BehaviorFlags, WINED3DPRESENT_PARAMETERS * pPresentationParameters, IWineD3DDevice ** ppReturnedDeviceInterface) PURE;
}; };
#undef INTERFACE #undef INTERFACE
@ -103,13 +121,33 @@ DECLARE_INTERFACE_(IWineD3D,IUnknown)
#define IWineD3D_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f) #define IWineD3D_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f)
#define IWineD3D_CheckDeviceFormatConversion(p,a,b,c,d) (p)->lpVtbl->CheckDeviceFormatConversion(p,a,b,c,d) #define IWineD3D_CheckDeviceFormatConversion(p,a,b,c,d) (p)->lpVtbl->CheckDeviceFormatConversion(p,a,b,c,d)
#define IWineD3D_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c) #define IWineD3D_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c)
#define IWineD3D_CreateDevice(p,a,b,c,d,e,f) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f)
#endif #endif
/* Define the main WineD3D entrypoint */ /* Define the main WineD3D entrypoint */
IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion); IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion);
/*****************************************************************************
* WineD3DDevice interface
*/
#define INTERFACE IWineD3DDevice
DECLARE_INTERFACE_(IWineD3DDevice,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IWineD3D methods ***/
};
#undef INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IWineD3D_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IWineD3D_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IWineD3D_Release(p) (p)->lpVtbl->Release(p)
/*** IWineD3D methods ***/
#endif
#if 0 /* FIXME: During porting in from d3d8 - the following will be used */ #if 0 /* FIXME: During porting in from d3d8 - the following will be used */
/***************************************************************** /*****************************************************************