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
/* IDirect3DDevice8 fields */
IDirect3D8Impl *direct3d8;
IWineD3DDevice *WineD3DDevice;
IDirect3DSurface8Impl *frontBuffer;
IDirect3DSurface8Impl *backBuffer;
......
......@@ -306,8 +306,10 @@ ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface) {
ULONG ref = --This->ref;
TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
if (ref == 0) {
IDirect3DDevice8Impl_CleanRender(iface);
HeapFree(GetProcessHeap(), 0, This);
IDirect3DDevice8Impl_CleanRender(iface);
IDirect3D8_Release((LPDIRECT3D8) This->direct3d8);
IWineD3DDevice_Release(This->WineD3DDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
......
......@@ -547,6 +547,7 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
int num;
XVisualInfo template;
HDC hDc;
WINED3DPRESENT_PARAMETERS localParameters;
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
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,
/** The device AddRef the direct3d8 Interface else crash in propers clients codes */
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 */
object->StateBlock = NULL;
IDirect3DDeviceImpl_CreateStateBlock(object, D3DSBT_ALL, NULL);
......
......@@ -68,6 +68,7 @@ ULONG WINAPI IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9 iface) {
TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
if (ref == 0) {
IDirect3D9_Release((LPDIRECT3D9) This->direct3d);
IWineD3DDevice_Release(This->WineD3DDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
......
......@@ -172,9 +172,6 @@ HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3
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;
......@@ -183,7 +180,7 @@ HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3
/* Allocate the storage for the device object */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDevice9Impl));
if (NULL == object) {
return D3DERR_OUTOFVIDEOMEMORY;
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DDevice9_Vtbl;
object->ref = 1;
......@@ -192,9 +189,21 @@ HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3
*ppReturnedDeviceInterface = (IDirect3DDevice9 *)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);
memcpy(pPresentationParameters, &localParameters, sizeof(D3DPRESENT_PARAMETERS));
FIXME("(%p) : incomplete stub\n", This);
return D3D_OK;
......
......@@ -32,6 +32,7 @@
#include "wingdi.h"
#include "winuser.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "d3d9.h"
#include "d3d9types.h"
......@@ -75,6 +76,16 @@ extern int num_lock;
#define WINED3D_VSHADER_MAX_CONSTANTS 96
/* 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
*/
......@@ -99,14 +110,35 @@ extern IWineD3DVtbl IWineD3D_Vtbl;
*/
typedef struct IWineD3DDeviceImpl
{
/* IUnknown fields */
/* IUnknown fields */
IWineD3DDeviceVtbl *lpVtbl;
DWORD ref; /* Note: Ref counting not required */
/* WineD3D Information */
/* WineD3D Information */
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;
extern IWineD3DDeviceVtbl IWineD3DDevice_Vtbl;
......
......@@ -1258,6 +1258,7 @@ typedef struct _D3DPRESENT_PARAMETERS_ {
UINT BackBufferCount;
D3DMULTISAMPLE_TYPE MultiSampleType;
DWORD MultiSampleQuality;
D3DSWAPEFFECT SwapEffect;
HWND hDeviceWindow;
......@@ -1267,7 +1268,7 @@ typedef struct _D3DPRESENT_PARAMETERS_ {
DWORD Flags;
UINT FullScreen_RefreshRateInHz;
UINT FullScreen_PresentationInterval;
UINT PresentationInterval;
} D3DPRESENT_PARAMETERS;
......
......@@ -54,20 +54,20 @@ typedef struct _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;
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;
......@@ -143,9 +143,9 @@ DECLARE_INTERFACE_(IWineD3DDevice,IUnknown)
#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)
#define IWineD3DDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IWineD3DDevice_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IWineD3DDevice_Release(p) (p)->lpVtbl->Release(p)
/*** IWineD3D methods ***/
#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