Commit b9e2beda authored by Jason Edmeades's avatar Jason Edmeades Committed by Alexandre Julliard

Copy and tidy up the code from dx8 create device into wined3d. Call

from wined3d and d3d8, but short term only use the code for real from d3d9.
parent 861f6240
...@@ -340,6 +340,7 @@ struct IDirect3DDevice8Impl ...@@ -340,6 +340,7 @@ struct IDirect3DDevice8Impl
/* IDirect3DDevice8 fields */ /* IDirect3DDevice8 fields */
IDirect3D8Impl *direct3d8; IDirect3D8Impl *direct3d8;
IWineD3DDevice *WineD3DDevice;
IDirect3DSurface8Impl *frontBuffer; IDirect3DSurface8Impl *frontBuffer;
IDirect3DSurface8Impl *backBuffer; IDirect3DSurface8Impl *backBuffer;
......
...@@ -306,8 +306,10 @@ ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface) { ...@@ -306,8 +306,10 @@ ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 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) {
IDirect3DDevice8Impl_CleanRender(iface); IDirect3DDevice8Impl_CleanRender(iface);
HeapFree(GetProcessHeap(), 0, This); IDirect3D8_Release((LPDIRECT3D8) This->direct3d8);
IWineD3DDevice_Release(This->WineD3DDevice);
HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;
} }
......
...@@ -547,6 +547,7 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface, ...@@ -547,6 +547,7 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
int num; int num;
XVisualInfo template; XVisualInfo template;
HDC hDc; HDC hDc;
WINED3DPRESENT_PARAMETERS localParameters;
IDirect3D8Impl *This = (IDirect3D8Impl *)iface; IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
TRACE("(%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %lx, PresParms: %p, RetDevInt: %p)\n", This, Adapter, DeviceType, TRACE("(%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %lx, PresParms: %p, RetDevInt: %p)\n", This, Adapter, DeviceType,
...@@ -567,6 +568,23 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface, ...@@ -567,6 +568,23 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
/** The device AddRef the direct3d8 Interface else crash in propers clients codes */ /** The device AddRef the direct3d8 Interface else crash in propers clients codes */
IDirect3D8_AddRef((LPDIRECT3D8) object->direct3d8); IDirect3D8_AddRef((LPDIRECT3D8) object->direct3d8);
/* Allocate an associated WineD3DDevice object */
localParameters.BackBufferWidth = &pPresentationParameters->BackBufferWidth;
localParameters.BackBufferHeight = &pPresentationParameters->BackBufferHeight;
localParameters.BackBufferFormat = &pPresentationParameters->BackBufferFormat;
localParameters.BackBufferCount = &pPresentationParameters->BackBufferCount;
localParameters.MultiSampleType = &pPresentationParameters->MultiSampleType;
localParameters.MultiSampleQuality = NULL; /* New at dx9 */
localParameters.SwapEffect = &pPresentationParameters->SwapEffect;
localParameters.hDeviceWindow = &pPresentationParameters->hDeviceWindow;
localParameters.Windowed = &pPresentationParameters->Windowed;
localParameters.EnableAutoDepthStencil = &pPresentationParameters->EnableAutoDepthStencil;
localParameters.AutoDepthStencilFormat = &pPresentationParameters->AutoDepthStencilFormat;
localParameters.Flags = &pPresentationParameters->Flags;
localParameters.FullScreen_RefreshRateInHz = &pPresentationParameters->FullScreen_RefreshRateInHz;
localParameters.PresentationInterval = &pPresentationParameters->FullScreen_PresentationInterval; /* Renamed in dx9 */
IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice);
/** use StateBlock Factory here, for creating the startup stateBlock */ /** use StateBlock Factory here, for creating the startup stateBlock */
object->StateBlock = NULL; object->StateBlock = NULL;
IDirect3DDeviceImpl_CreateStateBlock(object, D3DSBT_ALL, NULL); IDirect3DDeviceImpl_CreateStateBlock(object, D3DSBT_ALL, NULL);
......
...@@ -68,6 +68,7 @@ ULONG WINAPI IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9 iface) { ...@@ -68,6 +68,7 @@ ULONG WINAPI IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9 iface) {
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); IDirect3D9_Release((LPDIRECT3D9) This->direct3d);
IWineD3DDevice_Release(This->WineD3DDevice);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;
......
...@@ -172,9 +172,6 @@ HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3 ...@@ -172,9 +172,6 @@ HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3
IDirect3DDevice9Impl *object = NULL; IDirect3DDevice9Impl *object = NULL;
WINED3DPRESENT_PARAMETERS localParameters; 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 */ /* Check the validity range of the adapter parameter */
if (Adapter >= IDirect3D9Impl_GetAdapterCount(iface)) { if (Adapter >= IDirect3D9Impl_GetAdapterCount(iface)) {
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
...@@ -183,7 +180,7 @@ HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3 ...@@ -183,7 +180,7 @@ HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3
/* Allocate the storage for the device object */ /* Allocate the storage for the device object */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDevice9Impl)); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDevice9Impl));
if (NULL == object) { if (NULL == object) {
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
} }
object->lpVtbl = &Direct3DDevice9_Vtbl; object->lpVtbl = &Direct3DDevice9_Vtbl;
object->ref = 1; object->ref = 1;
...@@ -192,9 +189,21 @@ HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3 ...@@ -192,9 +189,21 @@ HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3
*ppReturnedDeviceInterface = (IDirect3DDevice9 *)object; *ppReturnedDeviceInterface = (IDirect3DDevice9 *)object;
/* Allocate an associated WineD3DDevice object */ /* Allocate an associated WineD3DDevice object */
memcpy(&localParameters, pPresentationParameters, sizeof(D3DPRESENT_PARAMETERS)); localParameters.BackBufferWidth = &pPresentationParameters->BackBufferWidth;
localParameters.BackBufferHeight = &pPresentationParameters->BackBufferHeight;
localParameters.BackBufferFormat = &pPresentationParameters->BackBufferFormat;
localParameters.BackBufferCount = &pPresentationParameters->BackBufferCount;
localParameters.MultiSampleType = &pPresentationParameters->MultiSampleType;
localParameters.MultiSampleQuality = &pPresentationParameters->MultiSampleQuality;
localParameters.SwapEffect = &pPresentationParameters->SwapEffect;
localParameters.hDeviceWindow = &pPresentationParameters->hDeviceWindow;
localParameters.Windowed = &pPresentationParameters->Windowed;
localParameters.EnableAutoDepthStencil = &pPresentationParameters->EnableAutoDepthStencil;
localParameters.AutoDepthStencilFormat = &pPresentationParameters->AutoDepthStencilFormat;
localParameters.Flags = &pPresentationParameters->Flags;
localParameters.FullScreen_RefreshRateInHz = &pPresentationParameters->FullScreen_RefreshRateInHz;
localParameters.PresentationInterval = &pPresentationParameters->PresentationInterval;
IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice); IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice);
memcpy(pPresentationParameters, &localParameters, sizeof(D3DPRESENT_PARAMETERS));
FIXME("(%p) : incomplete stub\n", This); FIXME("(%p) : incomplete stub\n", This);
return D3D_OK; return D3D_OK;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h"
#include "d3d9.h" #include "d3d9.h"
#include "d3d9types.h" #include "d3d9types.h"
...@@ -75,6 +76,16 @@ extern int num_lock; ...@@ -75,6 +76,16 @@ extern int num_lock;
#define WINED3D_VSHADER_MAX_CONSTANTS 96 #define WINED3D_VSHADER_MAX_CONSTANTS 96
/* Maximum number of constants provided to the shaders */ /* Maximum number of constants provided to the shaders */
#define checkGLcall(A) \
{ \
GLint err = glGetError(); \
if (err != GL_NO_ERROR) { \
FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", err, A, __FILE__, __LINE__); \
} else { \
TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__); \
} \
}
/***************************************************************************** /*****************************************************************************
* IWineD3D implementation structure * IWineD3D implementation structure
*/ */
...@@ -99,14 +110,35 @@ extern IWineD3DVtbl IWineD3D_Vtbl; ...@@ -99,14 +110,35 @@ extern IWineD3DVtbl IWineD3D_Vtbl;
*/ */
typedef struct IWineD3DDeviceImpl typedef struct IWineD3DDeviceImpl
{ {
/* IUnknown fields */ /* IUnknown fields */
IWineD3DDeviceVtbl *lpVtbl; IWineD3DDeviceVtbl *lpVtbl;
DWORD ref; /* Note: Ref counting not required */ DWORD ref; /* Note: Ref counting not required */
/* WineD3D Information */ /* WineD3D Information */
IWineD3D *WineD3D; IWineD3D *WineD3D;
/* GL Information */ /* X and GL Information */
HWND win_handle;
Window win;
Display *display;
GLXContext glCtx;
XVisualInfo *visInfo;
GLXContext render_ctx;
Drawable drawable;
GLint maxConcurrentLights;
/* Optimization */
BOOL modelview_valid;
BOOL proj_valid;
BOOL view_ident; /* true iff view matrix is identity */
BOOL last_was_rhw; /* true iff last draw_primitive was in xyzrhw mode */
/* Internal use fields */
D3DDEVICE_CREATION_PARAMETERS createParms;
D3DPRESENT_PARAMETERS presentParms;
UINT adapterNo;
D3DDEVTYPE devType;
} IWineD3DDeviceImpl; } IWineD3DDeviceImpl;
extern IWineD3DDeviceVtbl IWineD3DDevice_Vtbl; extern IWineD3DDeviceVtbl IWineD3DDevice_Vtbl;
......
...@@ -1258,6 +1258,7 @@ typedef struct _D3DPRESENT_PARAMETERS_ { ...@@ -1258,6 +1258,7 @@ typedef struct _D3DPRESENT_PARAMETERS_ {
UINT BackBufferCount; UINT BackBufferCount;
D3DMULTISAMPLE_TYPE MultiSampleType; D3DMULTISAMPLE_TYPE MultiSampleType;
DWORD MultiSampleQuality;
D3DSWAPEFFECT SwapEffect; D3DSWAPEFFECT SwapEffect;
HWND hDeviceWindow; HWND hDeviceWindow;
...@@ -1267,7 +1268,7 @@ typedef struct _D3DPRESENT_PARAMETERS_ { ...@@ -1267,7 +1268,7 @@ typedef struct _D3DPRESENT_PARAMETERS_ {
DWORD Flags; DWORD Flags;
UINT FullScreen_RefreshRateInHz; UINT FullScreen_RefreshRateInHz;
UINT FullScreen_PresentationInterval; UINT PresentationInterval;
} D3DPRESENT_PARAMETERS; } D3DPRESENT_PARAMETERS;
......
...@@ -54,20 +54,20 @@ typedef struct _WINED3DADAPTER_IDENTIFIER { ...@@ -54,20 +54,20 @@ typedef struct _WINED3DADAPTER_IDENTIFIER {
} WINED3DADAPTER_IDENTIFIER; } WINED3DADAPTER_IDENTIFIER;
typedef struct _WINED3DPRESENT_PARAMETERS { typedef struct _WINED3DPRESENT_PARAMETERS {
UINT BackBufferWidth; UINT *BackBufferWidth;
UINT BackBufferHeight; UINT *BackBufferHeight;
D3DFORMAT BackBufferFormat; D3DFORMAT *BackBufferFormat;
UINT BackBufferCount; UINT *BackBufferCount;
D3DMULTISAMPLE_TYPE MultiSampleType; D3DMULTISAMPLE_TYPE *MultiSampleType;
DWORD MultiSampleQuality; DWORD *MultiSampleQuality;
D3DSWAPEFFECT SwapEffect; D3DSWAPEFFECT *SwapEffect;
HWND hDeviceWindow; HWND *hDeviceWindow;
BOOL Windowed; BOOL *Windowed;
BOOL EnableAutoDepthStencil; BOOL *EnableAutoDepthStencil;
D3DFORMAT AutoDepthStencilFormat; D3DFORMAT *AutoDepthStencilFormat;
DWORD Flags; DWORD *Flags;
UINT FullScreen_RefreshRateInHz; UINT *FullScreen_RefreshRateInHz;
UINT PresentationInterval; UINT *PresentationInterval;
} WINED3DPRESENT_PARAMETERS; } WINED3DPRESENT_PARAMETERS;
typedef struct IWineD3D IWineD3D; typedef struct IWineD3D IWineD3D;
...@@ -143,9 +143,9 @@ DECLARE_INTERFACE_(IWineD3DDevice,IUnknown) ...@@ -143,9 +143,9 @@ DECLARE_INTERFACE_(IWineD3DDevice,IUnknown)
#if !defined(__cplusplus) || defined(CINTERFACE) #if !defined(__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/ /*** IUnknown methods ***/
#define IWineD3D_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) #define IWineD3DDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IWineD3D_AddRef(p) (p)->lpVtbl->AddRef(p) #define IWineD3DDevice_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IWineD3D_Release(p) (p)->lpVtbl->Release(p) #define IWineD3DDevice_Release(p) (p)->lpVtbl->Release(p)
/*** IWineD3D methods ***/ /*** IWineD3D methods ***/
#endif #endif
......
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