Commit 24ab49e2 authored by Jason Edmeades's avatar Jason Edmeades Committed by Alexandre Julliard

Create a wined3d interface, and generate a wined3d object in the d3d9

create method. Make the first (simple) call implementation into the new wined3d interface.
parent e63e3781
...@@ -3,7 +3,7 @@ TOPOBJDIR = ../.. ...@@ -3,7 +3,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
MODULE = d3d9.dll MODULE = d3d9.dll
IMPORTS = user32 gdi32 kernel32 IMPORTS = wined3d user32 gdi32 kernel32
EXTRAINCL = @X_CFLAGS@ 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@
......
...@@ -21,23 +21,10 @@ ...@@ -21,23 +21,10 @@
*/ */
#include "config.h" #include "config.h"
#include <stdarg.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/debug.h"
#include "d3d9.h"
#include "d3d9_private.h" #include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
void (*wine_tsx11_lock_ptr)(void) = NULL; void (*wine_tsx11_lock_ptr)(void) = NULL;
void (*wine_tsx11_unlock_ptr)(void) = NULL; void (*wine_tsx11_unlock_ptr)(void) = NULL;
...@@ -56,8 +43,9 @@ IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion) { ...@@ -56,8 +43,9 @@ IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion) {
object->lpVtbl = &Direct3D9_Vtbl; object->lpVtbl = &Direct3D9_Vtbl;
object->ref = 1; object->ref = 1;
object->WineD3D = WineDirect3DCreate(SDKVersion, 9);
TRACE("SDKVersion = %x, Created Direct3D object at %p\n", SDKVersion, object); TRACE("SDKVersion = %x, Created Direct3D object @ %p, WineObj @ %p\n", SDKVersion, object, object->WineD3D);
return (IDirect3D9*) object; return (IDirect3D9*) object;
} }
......
...@@ -27,7 +27,16 @@ ...@@ -27,7 +27,16 @@
#endif #endif
/* THIS FILE MUST NOT CONTAIN X11 or MESA DEFINES */ /* THIS FILE MUST NOT CONTAIN X11 or MESA DEFINES */
/* #include <stdarg.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/debug.h"
#define XMD_H #define XMD_H
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glx.h> #include <GL/glx.h>
...@@ -35,7 +44,6 @@ ...@@ -35,7 +44,6 @@
# include <GL/glext.h> # include <GL/glext.h>
#endif #endif
#undef XMD_H #undef XMD_H
*/
#undef APIENTRY #undef APIENTRY
#undef CALLBACK #undef CALLBACK
...@@ -46,6 +54,10 @@ ...@@ -46,6 +54,10 @@
#define WINAPI __stdcall #define WINAPI __stdcall
#define APIENTRY WINAPI #define APIENTRY WINAPI
#include "d3d9.h"
#include "d3d9_private.h"
#include "wine/wined3d_interface.h"
/* X11 locking */ /* X11 locking */
extern void (*wine_tsx11_lock_ptr)(void); extern void (*wine_tsx11_lock_ptr)(void);
...@@ -180,6 +192,9 @@ struct IDirect3D9Impl ...@@ -180,6 +192,9 @@ struct IDirect3D9Impl
IDirect3D9Vtbl *lpVtbl; IDirect3D9Vtbl *lpVtbl;
DWORD ref; DWORD ref;
/* The WineD3D device */
IWineD3D *WineD3D;
/* IDirect3D9 fields */ /* IDirect3D9 fields */
/* /*
GL_Info gl_info; GL_Info gl_info;
......
...@@ -75,9 +75,7 @@ HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9 iface, void* ...@@ -75,9 +75,7 @@ HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9 iface, void*
UINT WINAPI IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9 iface) { UINT WINAPI IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9 iface) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface; IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
/* FIXME: Set to one for now to imply the display */ return IWineD3D_GetAdapterCount(This->WineD3D);
TRACE("(%p): Mostly stub, only returns primary display\n", This);
return 1;
} }
HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9 iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) { HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9 iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) {
......
...@@ -3,11 +3,12 @@ TOPOBJDIR = ../.. ...@@ -3,11 +3,12 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
MODULE = wined3d.dll MODULE = wined3d.dll
IMPORTS = user32 gdi32 kernel32 IMPORTS = user32 gdi32 advapi32 kernel32
EXTRAINCL = @X_CFLAGS@ 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 = \
directx.c \
vertexshader.c \ vertexshader.c \
wined3d_main.c wined3d_main.c
......
/*
* IWineD3D 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);
UINT WINAPI IWineD3DImpl_GetAdapterCount (IWineD3D *iface) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
/* FIXME: Set to one for now to imply the display */
TRACE_(d3d_caps)("(%p): Mostly stub, only returns primary display\n", This);
return 1;
}
/* IUnknown parts follow: */
HRESULT WINAPI IWineD3DImpl_QueryInterface(IWineD3D *iface,REFIID riid,LPVOID *ppobj)
{
return E_NOINTERFACE;
}
ULONG WINAPI IWineD3DImpl_AddRef(IWineD3D *iface) {
return 1;
}
ULONG WINAPI IWineD3DImpl_Release(IWineD3D *iface) {
return 0;
}
/* VTbl definition */
IWineD3DVtbl IWineD3D_Vtbl =
{
IWineD3DImpl_QueryInterface,
IWineD3DImpl_AddRef,
IWineD3DImpl_Release,
IWineD3DImpl_GetAdapterCount
};
...@@ -37,6 +37,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); ...@@ -37,6 +37,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
# define TRACE_VSVECTOR(name) # define TRACE_VSVECTOR(name)
#endif #endif
#if 0 /* FIXME : Needs sorting when vshader code moved in properly */
/** /**
* DirectX9 SDK download * DirectX9 SDK download
...@@ -845,3 +846,5 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_GetConstantB(IDirect3DVertexShaderImpl* ...@@ -845,3 +846,5 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_GetConstantB(IDirect3DVertexShaderImpl*
FIXME("(%p) : stub\n", This); FIXME("(%p) : stub\n", This);
return D3D_OK; return D3D_OK;
} }
#endif
@ stdcall WineDirect3DCreate(long) @ stdcall WineDirect3DCreate(long long)
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* *
* Copyright 2002-2003 The wine-d3d team * Copyright 2002-2003 The wine-d3d team
* Copyright 2002-2003 Raphael Junqueira * Copyright 2002-2003 Raphael Junqueira
* Copyright 2004 Jason Edmeades
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -25,17 +26,69 @@ ...@@ -25,17 +26,69 @@
WINE_DEFAULT_DEBUG_CHANNEL(wine_d3d); WINE_DEFAULT_DEBUG_CHANNEL(wine_d3d);
IDirect3DImpl* WINAPI WineDirect3DCreate(UINT SDKVersion) { int num_lock = 0;
FIXME("SDKVersion = %x, TODO\n", SDKVersion); void (*wine_tsx11_lock_ptr)(void) = NULL;
return NULL; void (*wine_tsx11_unlock_ptr)(void) = NULL;
int vs_mode = VS_HW; /* Hardware by default */
int ps_mode = PS_NONE; /* Disabled by default */
IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion) {
IWineD3DImpl* object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DImpl));
object->lpVtbl = &IWineD3D_Vtbl;
object->dxVersion = dxVersion;
TRACE("Created WineD3D object @ %p for d3d%d support\n", object, dxVersion);
return (IWineD3D *)object;
} }
/* At process attach */ /* At process attach */
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{ {
TRACE("wined3d DLLMain Reason=%ld\n", fdwReason); TRACE("WineD3D DLLMain Reason=%ld\n", fdwReason);
if (fdwReason == DLL_PROCESS_ATTACH) { if (fdwReason == DLL_PROCESS_ATTACH)
DisableThreadLibraryCalls(hInstDLL); {
HMODULE mod;
char buffer[32];
DWORD size = sizeof(buffer);
HKEY hkey = 0;
DisableThreadLibraryCalls(hInstDLL);
mod = GetModuleHandleA( "x11drv.dll" );
if (mod)
{
wine_tsx11_lock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_lock" );
wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" );
}
if ( !RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Direct3D", &hkey) )
{
if ( !RegQueryValueExA( hkey, "VertexShaderMode", 0, NULL, buffer, &size) )
{
if (!strcmp(buffer,"none"))
{
TRACE("Disable vertex shaders\n");
vs_mode = VS_NONE;
}
else if (!strcmp(buffer,"emulation"))
{
TRACE("Force SW vertex shaders\n");
vs_mode = VS_SW;
}
}
if ( !RegQueryValueExA( hkey, "PixelShaderMode", 0, NULL, buffer, &size) )
{
if (!strcmp(buffer,"enabled"))
{
TRACE("Allow pixel shaders\n");
ps_mode = PS_HW;
}
}
}
if (vs_mode == VS_HW)
TRACE("Allow HW vertex shaders\n");
if (ps_mode == PS_NONE)
TRACE("Disable pixel shaders\n");
} }
return TRUE; return TRUE;
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* *
* Copyright 2002-2003 The wine-d3d team * Copyright 2002-2003 The wine-d3d team
* Copyright 2002-2003 Raphael Junqueira * Copyright 2002-2003 Raphael Junqueira
* Copyright 2004 Jason Edmeades
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -23,18 +24,46 @@ ...@@ -23,18 +24,46 @@
#define __WINE_WINED3D_PRIVATE_H #define __WINE_WINED3D_PRIVATE_H
#include <stdarg.h> #include <stdarg.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winreg.h"
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "d3d8.h" #include "d3d9.h"
#include "d3d8types.h" #include "d3d9types.h"
#include "wine/wined3d_interface.h" #include "wine/wined3d_interface.h"
extern int vs_mode;
#define VS_NONE 0
#define VS_HW 1
#define VS_SW 2
extern int ps_mode;
#define PS_NONE 0
#define PS_HW 1
/*****************************************************************************
* IWineD3D implementation structure
*/
typedef struct IWineD3DImpl
{
/* IUnknown fields */
IWineD3DVtbl *lpVtbl;
DWORD ref; /* Note: Ref counting not required */
/* WineD3D Information */
UINT dxVersion;
} IWineD3DImpl;
extern IWineD3DVtbl IWineD3D_Vtbl;
#if 0 /* Needs fixing during rework */
/***************************************************************************** /*****************************************************************************
* IDirect3DVertexShaderDeclaration implementation structure * IDirect3DVertexShaderDeclaration implementation structure
*/ */
...@@ -86,4 +115,5 @@ struct IDirect3DPixelShaderImpl { ...@@ -86,4 +115,5 @@ struct IDirect3DPixelShaderImpl {
PSHADEROUTPUTDATA output; PSHADEROUTPUTDATA output;
}; };
#endif /* Needs fixing during rework */
#endif #endif
...@@ -35,6 +35,36 @@ ...@@ -35,6 +35,36 @@
* PLEASE USE wine/wined3d_gl.h INSTEAD * PLEASE USE wine/wined3d_gl.h INSTEAD
*/ */
/*****************************************************************************
* WineD3D interface
*/
typedef struct IWineD3D IWineD3D;
#define INTERFACE IWineD3D
#define IWineD3D_METHODS \
IUnknown_METHODS \
STDMETHOD_(UINT,GetAdapterCount )(THIS) PURE; \
DECLARE_INTERFACE_(IWineD3D,IUnknown) { IWineD3D_METHODS };
#undef INTERFACE
#ifdef COBJMACROS
/*** 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 ***/
#define IWineD3D_GetAdapterCount(p) (p)->lpVtbl->GetAdapterCount(p)
#endif
/* Define the main WineD3D entrypoint */
IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion);
#if 0 /* FIXME: During porting in from d3d8 - the following will be used */
/***************************************************************** /*****************************************************************
* Some defines * Some defines
*/ */
...@@ -104,15 +134,7 @@ extern HRESULT WINAPI IDirect3DVertexShaderImpl_GetConstantF(IDirect3DVertexShad ...@@ -104,15 +134,7 @@ extern HRESULT WINAPI IDirect3DVertexShaderImpl_GetConstantF(IDirect3DVertexShad
extern DWORD WINAPI IDirect3DVertexShaderImpl_GetVersion(IDirect3DVertexShaderImpl* This); extern DWORD WINAPI IDirect3DVertexShaderImpl_GetVersion(IDirect3DVertexShaderImpl* This);
extern HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* This, VSHADERINPUTDATA* input, VSHADEROUTPUTDATA* output); extern HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* This, VSHADERINPUTDATA* input, VSHADEROUTPUTDATA* output);
#ifdef __cplusplus #endif /* Temporary #if 0 */
extern "C" {
#endif /* defined(__cplusplus) */
/* Define the main entrypoint as well */
IDirect3DImpl* WINAPI WineDirect3DCreate(UINT SDKVersion);
#ifdef __cplusplus
} /* extern "C" */
#endif /* defined(__cplusplus) */
#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