From e31ae92630cbe50ab01006f52aa0ee0aa3b4a469 Mon Sep 17 00:00:00 2001 From: Raphael Junqueira Date: Tue, 17 Dec 2002 01:15:15 +0000 Subject: [PATCH] - some D3D8 fixes - beginning of shaders support (Vertex and Pixel Shaders 1.1 on DirectX8) - beginning of D3DX8 support the D3D8 utility API (very basic, only the core header) --- configure | 3 +- configure.ac | 1 + dlls/Makefile.in | 15 +- dlls/d3d8/Makefile.in | 1 + dlls/d3d8/basetexture.c | 7 +- dlls/d3d8/cubetexture.c | 13 +- dlls/d3d8/d3d8_main.c | 13 +- dlls/d3d8/d3d8_private.h | 485 ++++++++++++++++++++++----------------- dlls/d3d8/device.c | 276 ++++++++++++++++++---- dlls/d3d8/directx.c | 2 +- dlls/d3d8/indexbuffer.c | 7 +- dlls/d3d8/shader.c | 337 +++++++++++++++++++++++++++ dlls/d3d8/surface.c | 2 +- dlls/d3d8/swapchain.c | 2 +- dlls/d3d8/texture.c | 4 +- dlls/d3d8/vertexbuffer.c | 13 +- dlls/d3d8/volume.c | 2 +- dlls/d3dx8/.cvsignore | 4 + dlls/{d3d8 => d3dx8}/Makefile.in | 19 +- dlls/d3dx8/d3dx8.spec | 6 + dlls/d3dx8/d3dx8_main.c | 90 ++++++++ dlls/d3dx8/d3dx8core_private.h | 91 ++++++++ dlls/d3dx8/d3dxbuffer.c | 86 +++++++ dlls/make_dlls | 1 + include/Makefile.in | 1 + include/d3d8.h | 173 +++++++------- include/d3d8types.h | 77 +++++++ include/d3dx8core.h | 126 ++++++++++ 28 files changed, 1458 insertions(+), 399 deletions(-) create mode 100644 dlls/d3d8/shader.c create mode 100644 dlls/d3dx8/.cvsignore copy dlls/{d3d8 => d3dx8}/Makefile.in (54%) create mode 100644 dlls/d3dx8/d3dx8.spec create mode 100644 dlls/d3dx8/d3dx8_main.c create mode 100644 dlls/d3dx8/d3dx8core_private.h create mode 100644 dlls/d3dx8/d3dxbuffer.c create mode 100644 include/d3dx8core.h diff --git a/configure b/configure index b4b878c70be..f546ad4bb3d 100755 --- a/configure +++ b/configure @@ -13916,7 +13916,7 @@ MAKE_TEST_RULES=dlls/Maketest.rules MAKE_PROG_RULES=programs/Makeprog.rules - ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/d3d8/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msdmo/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvideo/Makefile dlls/msvideo/msrle32/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/version/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winenas/Makefile dlls/winmm/winejack/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile include/Makefile library/Makefile miscemu/Makefile ole/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/notepad/Makefile programs/osversioncheck/Makefile programs/progman/Makefile programs/regapi/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/regtest/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/wmc/Makefile tools/wpp/Makefile tools/wrc/Makefile unicode/Makefile" + ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/d3d8/Makefile dlls/d3dx8/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msdmo/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvideo/Makefile dlls/msvideo/msrle32/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/version/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winenas/Makefile dlls/winmm/winejack/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile include/Makefile library/Makefile miscemu/Makefile ole/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/notepad/Makefile programs/osversioncheck/Makefile programs/progman/Makefile programs/regapi/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/regtest/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/wmc/Makefile tools/wpp/Makefile tools/wrc/Makefile unicode/Makefile" cat >confcache <<\_ACEOF @@ -14443,6 +14443,7 @@ do "dlls/crtdll/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/crtdll/Makefile" ;; "dlls/crypt32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/crypt32/Makefile" ;; "dlls/d3d8/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/d3d8/Makefile" ;; + "dlls/d3dx8/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/d3dx8/Makefile" ;; "dlls/dciman32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/dciman32/Makefile" ;; "dlls/ddraw/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/ddraw/Makefile" ;; "dlls/devenum/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/devenum/Makefile" ;; diff --git a/configure.ac b/configure.ac index ad433ea3fcc..a25b77f771a 100644 --- a/configure.ac +++ b/configure.ac @@ -1366,6 +1366,7 @@ dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/d3d8/Makefile +dlls/d3dx8/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/devenum/Makefile diff --git a/dlls/Makefile.in b/dlls/Makefile.in index dee895cac16..813b8520f10 100644 --- a/dlls/Makefile.in +++ b/dlls/Makefile.in @@ -8,7 +8,7 @@ VPATH = @srcdir@ # special configure-dependent targets GLU32FILES = glu32 -OPENGLFILES = d3d8 opengl32 +OPENGLFILES = d3d8 d3dx8 opengl32 XFILES = ddraw x11drv EXTRADIRS = @GLU32FILES@ @OPENGLFILES@ @XFILES@ @@ -112,6 +112,7 @@ BASEDIRS = \ SUBDIRS = \ $(BASEDIRS) \ d3d8 \ + d3dx8 \ ddraw \ glu32 \ opengl32 \ @@ -301,6 +302,9 @@ crypt32.dll$(DLLEXT): crypt32/crypt32.dll$(DLLEXT) d3d8.dll$(DLLEXT): d3d8/d3d8.dll$(DLLEXT) $(RM) $@ && $(LN_S) d3d8/d3d8.dll$(DLLEXT) $@ +d3dx8.dll$(DLLEXT): d3dx8/d3dx8.dll$(DLLEXT) + $(RM) $@ && $(LN_S) d3dx8/d3dx8.dll$(DLLEXT) $@ + dciman32.dll$(DLLEXT): dciman32/dciman32.dll$(DLLEXT) $(RM) $@ && $(LN_S) dciman32/dciman32.dll$(DLLEXT) $@ @@ -585,6 +589,7 @@ IMPORT_LIBS = \ libcrtdll \ libcrypt32 \ libd3d8 \ + libd3dx8 \ libdciman32 \ libddraw \ libdevenum \ @@ -705,6 +710,11 @@ libd3d8.def: d3d8/d3d8.spec.def libd3d8.a: d3d8/d3d8.spec.def $(DLLTOOL) -k -l $@ -d d3d8/d3d8.spec.def +libd3dx8.def: d3dx8/d3dx8.spec.def + $(RM) $@ && $(LN_S) d3dx8/d3dx8.spec.def $@ +libd3dx8.a: d3dx8/d3dx8.spec.def + $(DLLTOOL) -k -l $@ -d d3dx8/d3dx8.spec.def + libdciman32.def: dciman32/dciman32.spec.def $(RM) $@ && $(LN_S) dciman32/dciman32.spec.def $@ libdciman32.a: dciman32/dciman32.spec.def @@ -1060,6 +1070,7 @@ commdlg/comdlg32.spec.def: $(WINEBUILD) crtdll/crtdll.spec.def: $(WINEBUILD) crypt32/crypt32.spec.def: $(WINEBUILD) d3d8/d3d8.spec.def: $(WINEBUILD) +d3dx8/d3dx8.spec.def: $(WINEBUILD) dciman32/dciman32.spec.def: $(WINEBUILD) ddraw/ddraw.spec.def: $(WINEBUILD) devenum/devenum.spec.def: $(WINEBUILD) @@ -1145,6 +1156,7 @@ commdlg/comdlg32.dll$(DLLEXT): commdlg crtdll/crtdll.dll$(DLLEXT): crtdll crypt32/crypt32.dll$(DLLEXT): crypt32 d3d8/d3d8.dll$(DLLEXT): d3d8 +d3dx8/d3dx8.dll$(DLLEXT): d3dx8 dciman32/dciman32.dll$(DLLEXT): dciman32 ddraw/ddraw.dll$(DLLEXT): ddraw devenum/devenum.dll$(DLLEXT): devenum @@ -1246,6 +1258,7 @@ commdlg/__install__: comdlg32.dll$(DLLEXT) crtdll/__install__: crtdll.dll$(DLLEXT) crypt32/__install__: crypt32.dll$(DLLEXT) d3d8/__install__: d3d8.dll$(DLLEXT) +d3dx8/__install__: d3dx8.dll$(DLLEXT) dciman32/__install__: dciman32.dll$(DLLEXT) ddraw/__install__: ddraw.dll$(DLLEXT) devenum/__install__: devenum.dll$(DLLEXT) diff --git a/dlls/d3d8/Makefile.in b/dlls/d3d8/Makefile.in index e0faaef014a..e319a40df58 100644 --- a/dlls/d3d8/Makefile.in +++ b/dlls/d3d8/Makefile.in @@ -18,6 +18,7 @@ C_SRCS = \ directx.c \ indexbuffer.c \ resource.c \ + shader.c \ surface.c \ swapchain.c \ texture.c \ diff --git a/dlls/d3d8/basetexture.c b/dlls/d3d8/basetexture.c index e9def5a750f..1cffddce447 100644 --- a/dlls/d3d8/basetexture.c +++ b/dlls/d3d8/basetexture.c @@ -28,13 +28,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); -/* IDirect3DBaseTexture8 IUnknown parts follow: */ +/* IDirect3DBaseTexture8 (Inherited from IUnknown) */ HRESULT WINAPI IDirect3DBaseTexture8Impl_QueryInterface(LPDIRECT3DBASETEXTURE8 iface,REFIID riid,LPVOID *ppobj) { ICOM_THIS(IDirect3DBaseTexture8Impl,iface); TRACE("(%p) : QueryInterface\n", This); if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_IClassFactory)) { + || IsEqualGUID(riid, &IID_IDirect3DResource8) + || IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)) { IDirect3DBaseTexture8Impl_AddRef(iface); *ppobj = This; return D3D_OK; @@ -59,7 +60,7 @@ ULONG WINAPI IDirect3DBaseTexture8Impl_Release(LPDIRECT3DBASETEXTURE8 iface) { return ref; } -/* IDirect3DBaseTexture8 IDirect3DResource8 Interface follow: */ +/* IDirect3DBaseTexture8 (Inherited from IDirect3DResource8) */ HRESULT WINAPI IDirect3DBaseTexture8Impl_GetDevice(LPDIRECT3DBASETEXTURE8 iface, IDirect3DDevice8** ppDevice) { ICOM_THIS(IDirect3DBaseTexture8Impl,iface); TRACE("(%p) : returning %p\n", This, This->Device); diff --git a/dlls/d3d8/cubetexture.c b/dlls/d3d8/cubetexture.c index 1012b1a73b0..9f53403196d 100644 --- a/dlls/d3d8/cubetexture.c +++ b/dlls/d3d8/cubetexture.c @@ -34,7 +34,9 @@ HRESULT WINAPI IDirect3DCubeTexture8Impl_QueryInterface(LPDIRECT3DCUBETEXTURE8 i ICOM_THIS(IDirect3DCubeTexture8Impl,iface); TRACE("(%p) : QueryInterface\n", This); if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_IClassFactory)) { + || IsEqualGUID(riid, &IID_IDirect3DResource8) + || IsEqualGUID(riid, &IID_IDirect3DBaseTexture8) + || IsEqualGUID(riid, &IID_IDirect3DCubeTexture8)) { IDirect3DCubeTexture8Impl_AddRef(iface); *ppobj = This; return D3D_OK; @@ -68,7 +70,7 @@ ULONG WINAPI IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 iface) { return ref; } -/* IDirect3DCubeTexture8 IDirect3DResource8 Interface follow: */ +/* IDirect3DCubeTexture8 (Inherited from IDirect3DResource8) */ HRESULT WINAPI IDirect3DCubeTexture8Impl_GetDevice(LPDIRECT3DCUBETEXTURE8 iface, IDirect3DDevice8** ppDevice) { ICOM_THIS(IDirect3DCubeTexture8Impl,iface); TRACE("(%p) : returning %p\n", This, This->Device); @@ -109,11 +111,13 @@ D3DRESOURCETYPE WINAPI IDirect3DCubeTexture8Impl_GetType(LPDIRECT3DCUBETEXTURE8 /* IDirect3DCubeTexture8 (Inherited from IDirect3DBaseTexture8) */ DWORD WINAPI IDirect3DCubeTexture8Impl_SetLOD(LPDIRECT3DCUBETEXTURE8 iface, DWORD LODNew) { ICOM_THIS(IDirect3DCubeTexture8Impl,iface); - FIXME("(%p) : stub\n", This); return D3D_OK; + FIXME("(%p) : stub\n", This); + return D3D_OK; } DWORD WINAPI IDirect3DCubeTexture8Impl_GetLOD(LPDIRECT3DCUBETEXTURE8 iface) { ICOM_THIS(IDirect3DCubeTexture8Impl,iface); - FIXME("(%p) : stub\n", This); return D3D_OK; + FIXME("(%p) : stub\n", This); + return D3D_OK; } DWORD WINAPI IDirect3DCubeTexture8Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE8 iface) { @@ -133,7 +137,6 @@ HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(LPDIRECT3DCUBETEXT } return D3D_OK; } - HRESULT WINAPI IDirect3DCubeTexture8Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE8 iface,D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface8** ppCubeMapSurface) { ICOM_THIS(IDirect3DCubeTexture8Impl,iface); TRACE("(%p) : returning %p\n", This, This->surfaces[FaceType][Level]); diff --git a/dlls/d3d8/d3d8_main.c b/dlls/d3d8/d3d8_main.c index 9cc690f746a..597fd209723 100644 --- a/dlls/d3d8/d3d8_main.c +++ b/dlls/d3d8/d3d8_main.c @@ -22,6 +22,7 @@ #include "winuser.h" #include "wine/debug.h" +#include "d3d8.h" #include "d3d8_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d); @@ -29,18 +30,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); void (*wine_tsx11_lock_ptr)(void) = NULL; void (*wine_tsx11_unlock_ptr)(void) = NULL; -HRESULT WINAPI ValidatePixelShader(void) -{ - FIXME("(void): stub\n"); - return 0; -} - -HRESULT WINAPI ValidateVertexShader(void) -{ - FIXME("(void): stub\n"); - return 0; -} - HRESULT WINAPI D3D8GetSWInfo(void) { FIXME("(void): stub\n"); diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 40462d3e6e5..1ff3b58148d 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -152,6 +152,50 @@ typedef struct STATEBLOCK { } STATEBLOCK; +typedef struct SHADER8Vector { + float x; + float y; + float z; + float w; +} SHADER8Vector; + +typedef struct SHADER8Scalar { + float x; +} SHADER8Scalar; + +#define SHADER_MAX_CONSTANTS 96 +#define VSHADER_MAX_CONSTANTS 96 +#define PSHADER_MAX_CONSTANTS 96 +typedef SHADER8Vector SHADER8Constants[SHADER_MAX_CONSTANTS]; + +typedef struct SHADER8Data { + /** Run Time Shader Function Constants */ + /*D3DXBUFFER* constants; */ + SHADER8Constants constants; + /** Shader Code as char ... */ + CONST DWORD* code; + UINT codeLength; +} SHADER8Data; + +typedef struct VERTEXSHADER8 { /* TODO: Vertex Shader */ + CONST DWORD* decl; + CONST DWORD* function; + DWORD usage; /* 0 || D3DUSAGE_SOFTWAREPROCESSING */ + UINT declLength; + UINT functionLength; + + /* run time datas */ + SHADER8Data* data; +} VERTEXSHADER8; + +typedef struct PIXELSHADER8 { /* TODO: Pixel Shader */ + CONST DWORD* function; + UINT functionLength; + + /* run time datas */ + SHADER8Data* data; +} PIXELSHADER8; + /* * External prototypes */ @@ -198,11 +242,11 @@ struct IDirect3D8Impl }; /* IUnknown: */ -extern HRESULT WINAPI IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface,REFIID refiid,LPVOID *obj); -extern ULONG WINAPI IDirect3D8Impl_AddRef(LPDIRECT3D8 iface); -extern ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface); +extern HRESULT WINAPI IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface,REFIID refiid,LPVOID *obj); +extern ULONG WINAPI IDirect3D8Impl_AddRef(LPDIRECT3D8 iface); +extern ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface); -/* IDirect3d8:*/ +/* IDirect3d8: */ extern HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice(LPDIRECT3D8 iface, void* pInitializeFunction); extern UINT WINAPI IDirect3D8Impl_GetAdapterCount(LPDIRECT3D8 iface); extern HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier(LPDIRECT3D8 iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER8* pIdentifier); @@ -220,50 +264,8 @@ extern HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(LPDIRECT3D8 iface, extern HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps); extern HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter); extern HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, - DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, - IDirect3DDevice8** ppReturnedDeviceInterface); -/* --------------------- */ -/* IDirect3DBaseTexture8 */ -/* --------------------- */ - -/***************************************************************************** - * Predeclare the interface implementation structures - */ -extern ICOM_VTABLE(IDirect3DBaseTexture8) Direct3DBaseTexture8_Vtbl; - -/***************************************************************************** - * IDirect3DBaseTexture8 implementation structure - */ -struct IDirect3DBaseTexture8Impl -{ - /* IUnknown fields */ - ICOM_VFIELD(IDirect3DBaseTexture8); - DWORD ref; - - /* IDirect3DBaseTexture8 fields */ - IDirect3DDevice8Impl *Device; - D3DRESOURCETYPE ResourceType; -}; - -/* IUnknown: */ -extern HRESULT WINAPI IDirect3DBaseTexture8Impl_QueryInterface(LPDIRECT3DBASETEXTURE8 iface,REFIID refiid,LPVOID *obj); -extern ULONG WINAPI IDirect3DBaseTexture8Impl_AddRef(LPDIRECT3DBASETEXTURE8 iface); -extern ULONG WINAPI IDirect3DBaseTexture8Impl_Release(LPDIRECT3DBASETEXTURE8 iface); - -/* IDirect3DBaseTexture8 (Inherited from IDirect3DResource8) */ -extern HRESULT WINAPI IDirect3DBaseTexture8Impl_GetDevice(LPDIRECT3DBASETEXTURE8 iface, IDirect3DDevice8** ppDevice); -extern HRESULT WINAPI IDirect3DBaseTexture8Impl_SetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags); -extern HRESULT WINAPI IDirect3DBaseTexture8Impl_GetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData); -extern HRESULT WINAPI IDirect3DBaseTexture8Impl_FreePrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid); -extern DWORD WINAPI IDirect3DBaseTexture8Impl_SetPriority(LPDIRECT3DBASETEXTURE8 iface, DWORD PriorityNew); -extern DWORD WINAPI IDirect3DBaseTexture8Impl_GetPriority(LPDIRECT3DBASETEXTURE8 iface); -extern void WINAPI IDirect3DBaseTexture8Impl_PreLoad(LPDIRECT3DBASETEXTURE8 iface); -extern D3DRESOURCETYPE WINAPI IDirect3DBaseTexture8Impl_GetType(LPDIRECT3DBASETEXTURE8 iface); - -/* IDirect3DBaseTexture8 */ -extern DWORD WINAPI IDirect3DBaseTexture8Impl_SetLOD(LPDIRECT3DBASETEXTURE8 iface, DWORD LODNew); -extern DWORD WINAPI IDirect3DBaseTexture8Impl_GetLOD(LPDIRECT3DBASETEXTURE8 iface); -extern DWORD WINAPI IDirect3DBaseTexture8Impl_GetLevelCount(LPDIRECT3DBASETEXTURE8 iface); + DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, + IDirect3DDevice8** ppReturnedDeviceInterface); /* ---------------- */ /* IDirect3DDevice8 */ @@ -274,7 +276,6 @@ extern DWORD WINAPI IDirect3DBaseTexture8Impl_GetLevelCount(LPDIRECT3D */ extern ICOM_VTABLE(IDirect3DDevice8) Direct3DDevice8_Vtbl; - /***************************************************************************** * IDirect3DDevice8 implementation structure */ @@ -282,45 +283,44 @@ struct IDirect3DDevice8Impl { /* IUnknown fields */ ICOM_VFIELD(IDirect3DDevice8); - DWORD ref; + DWORD ref; /* IDirect3DDevice8 fields */ - IDirect3D8Impl *direct3d8; - IDirect3DSurface8Impl *backBuffer; + IDirect3D8Impl *direct3d8; + IDirect3DSurface8Impl *backBuffer; D3DPRESENT_PARAMETERS PresentParms; D3DDEVICE_CREATION_PARAMETERS CreateParms; - UINT adapterNo; - D3DDEVTYPE devType; + UINT adapterNo; + D3DDEVTYPE devType; - UINT srcBlend; - UINT dstBlend; + UINT srcBlend; + UINT dstBlend; /* State block related */ - BOOL isRecordingState; - STATEBLOCK StateBlock; - STATEBLOCK *UpdateStateBlock; + BOOL isRecordingState; + STATEBLOCK StateBlock; + STATEBLOCK *UpdateStateBlock; /* Other required values */ - float lightPosn[MAX_ACTIVE_LIGHTS][4]; - float lightDirn[MAX_ACTIVE_LIGHTS][4]; + float lightPosn[MAX_ACTIVE_LIGHTS][4]; + float lightDirn[MAX_ACTIVE_LIGHTS][4]; /* OpenGL related */ - GLXContext glCtx; - XVisualInfo *visInfo; - Display *display; - Window win; - - UINT dummyTextureName[8]; + GLXContext glCtx; + XVisualInfo *visInfo; + Display *display; + Window win; + UINT dummyTextureName[8]; }; /* IUnknown: */ -extern HRESULT WINAPI IDirect3DDevice8Impl_QueryInterface(LPDIRECT3DDEVICE8 iface,REFIID refiid,LPVOID *obj); -extern ULONG WINAPI IDirect3DDevice8Impl_AddRef(LPDIRECT3DDEVICE8 iface); -extern ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface); +extern HRESULT WINAPI IDirect3DDevice8Impl_QueryInterface(LPDIRECT3DDEVICE8 iface,REFIID refiid,LPVOID *obj); +extern ULONG WINAPI IDirect3DDevice8Impl_AddRef(LPDIRECT3DDEVICE8 iface); +extern ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface); -/* IDirect3DDevice8:*/ +/* IDirect3DDevice8: */ extern HRESULT WINAPI IDirect3DDevice8Impl_TestCooperativeLevel(LPDIRECT3DDEVICE8 iface); extern UINT WINAPI IDirect3DDevice8Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE8 iface); extern HRESULT WINAPI IDirect3DDevice8Impl_ResourceManagerDiscardBytes(LPDIRECT3DDEVICE8 iface, DWORD Bytes); @@ -416,91 +416,9 @@ extern HRESULT WINAPI IDirect3DDevice8Impl_DrawRectPatch(LPDIRECT3DDEVICE8 ifa extern HRESULT WINAPI IDirect3DDevice8Impl_DrawTriPatch(LPDIRECT3DDEVICE8 iface, UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo); extern HRESULT WINAPI IDirect3DDevice8Impl_DeletePatch(LPDIRECT3DDEVICE8 iface, UINT Handle); -/* ------------------ */ -/* IDirect3DResource8 */ -/* ------------------ */ - -/***************************************************************************** - * Predeclare the interface implementation structures - */ -extern ICOM_VTABLE(IDirect3DResource8) Direct3DResource8_Vtbl; - -/***************************************************************************** - * IDirect3DResource8 implementation structure - */ -struct IDirect3DResource8Impl -{ - /* IUnknown fields */ - ICOM_VFIELD(IDirect3DResource8); - DWORD ref; - - /* IDirect3DResource8 fields */ - IDirect3DDevice8Impl *Device; - D3DRESOURCETYPE ResourceType; -}; - -/* IUnknown: */ -extern HRESULT WINAPI IDirect3DResource8Impl_QueryInterface(LPDIRECT3DRESOURCE8 iface,REFIID refiid,LPVOID *obj); -extern ULONG WINAPI IDirect3DResource8Impl_AddRef(LPDIRECT3DRESOURCE8 iface); -extern ULONG WINAPI IDirect3DResource8Impl_Release(LPDIRECT3DRESOURCE8 iface); - -/* IDirect3DResource8 */ -extern HRESULT WINAPI IDirect3DResource8Impl_GetDevice(LPDIRECT3DRESOURCE8 iface, IDirect3DDevice8** ppDevice); -extern HRESULT WINAPI IDirect3DResource8Impl_SetPrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags); -extern HRESULT WINAPI IDirect3DResource8Impl_GetPrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData); -extern HRESULT WINAPI IDirect3DResource8Impl_FreePrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid); -extern DWORD WINAPI IDirect3DResource8Impl_SetPriority(LPDIRECT3DRESOURCE8 iface, DWORD PriorityNew); -extern DWORD WINAPI IDirect3DResource8Impl_GetPriority(LPDIRECT3DRESOURCE8 iface); -extern void WINAPI IDirect3DResource8Impl_PreLoad(LPDIRECT3DRESOURCE8 iface); -extern D3DRESOURCETYPE WINAPI IDirect3DResource8Impl_GetType(LPDIRECT3DRESOURCE8 iface); - -/* ---------------------- */ -/* IDirect3DVertexBuffer8 */ -/* ---------------------- */ - -/***************************************************************************** - * Predeclare the interface implementation structures - */ -extern ICOM_VTABLE(IDirect3DVertexBuffer8) Direct3DVertexBuffer8_Vtbl; - -/***************************************************************************** - * IDirect3DVertexBuffer8 implementation structure - */ -struct IDirect3DVertexBuffer8Impl -{ - /* IUnknown fields */ - ICOM_VFIELD(IDirect3DVertexBuffer8); - DWORD ref; - - /* IDirect3DVertexBuffer8 fields */ - IDirect3DDevice8Impl *Device; - D3DRESOURCETYPE ResourceType; - BYTE *allocatedMemory; - D3DVERTEXBUFFER_DESC currentDesc; -}; - -/* IUnknown: */ -extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER8 iface,REFIID refiid,LPVOID *obj); -extern ULONG WINAPI IDirect3DVertexBuffer8Impl_AddRef(LPDIRECT3DVERTEXBUFFER8 iface); -extern ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 iface); - -/* IDirect3DVertexBuffer8 (Inherited from IDirect3DResource8) */ -extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDevice(LPDIRECT3DVERTEXBUFFER8 iface, IDirect3DDevice8** ppDevice); -extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags); -extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData); -extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid); -extern DWORD WINAPI IDirect3DVertexBuffer8Impl_SetPriority(LPDIRECT3DVERTEXBUFFER8 iface, DWORD PriorityNew); -extern DWORD WINAPI IDirect3DVertexBuffer8Impl_GetPriority(LPDIRECT3DVERTEXBUFFER8 iface); -extern void WINAPI IDirect3DVertexBuffer8Impl_PreLoad(LPDIRECT3DVERTEXBUFFER8 iface); -extern D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer8Impl_GetType(LPDIRECT3DVERTEXBUFFER8 iface); - -/* IDirect3DVertexBuffer8 */ -extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_Lock(LPDIRECT3DVERTEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE** ppbData, DWORD Flags); -extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_Unlock(LPDIRECT3DVERTEXBUFFER8 iface); -extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8 iface, D3DVERTEXBUFFER_DESC *pDesc); - -/* IDirect3DVolume8 private include file - */ +/* ---------------- */ +/* IDirect3DVolume8 */ +/* ---------------- */ /***************************************************************************** * Predeclare the interface implementation structures @@ -525,15 +443,14 @@ struct IDirect3DVolume8Impl BYTE *allocatedMemory; UINT textureName; UINT bytesPerPixel; - }; /* IUnknown: */ extern HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 iface,REFIID refiid,LPVOID *obj); -extern ULONG WINAPI IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface); -extern ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface); +extern ULONG WINAPI IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface); +extern ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface); -/* IDirect3DVolume8 */ +/* IDirect3DVolume8: */ extern HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, IDirect3DDevice8** ppDevice); extern HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags); extern HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData); @@ -566,10 +483,10 @@ struct IDirect3DSwapChain8Impl /* IUnknown: */ extern HRESULT WINAPI IDirect3DSwapChain8Impl_QueryInterface(LPDIRECT3DSWAPCHAIN8 iface,REFIID refiid,LPVOID *obj); -extern ULONG WINAPI IDirect3DSwapChain8Impl_AddRef(LPDIRECT3DSWAPCHAIN8 iface); -extern ULONG WINAPI IDirect3DSwapChain8Impl_Release(LPDIRECT3DSWAPCHAIN8 iface); +extern ULONG WINAPI IDirect3DSwapChain8Impl_AddRef(LPDIRECT3DSWAPCHAIN8 iface); +extern ULONG WINAPI IDirect3DSwapChain8Impl_Release(LPDIRECT3DSWAPCHAIN8 iface); -/* IDirect3DSwapChain8 */ +/* IDirect3DSwapChain8: */ extern HRESULT WINAPI IDirect3DSwapChain8Impl_Present(LPDIRECT3DSWAPCHAIN8 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion); extern HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN8 iface, UINT BackBuffer, D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer); @@ -605,10 +522,10 @@ struct IDirect3DSurface8Impl /* IUnknown: */ extern HRESULT WINAPI IDirect3DSurface8Impl_QueryInterface(LPDIRECT3DSURFACE8 iface,REFIID refiid,LPVOID *obj); -extern ULONG WINAPI IDirect3DSurface8Impl_AddRef(LPDIRECT3DSURFACE8 iface); -extern ULONG WINAPI IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface); +extern ULONG WINAPI IDirect3DSurface8Impl_AddRef(LPDIRECT3DSURFACE8 iface); +extern ULONG WINAPI IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface); -/* IDirect3DSurface8 */ +/* IDirect3DSurface8: */ extern HRESULT WINAPI IDirect3DSurface8Impl_GetDevice(LPDIRECT3DSURFACE8 iface, IDirect3DDevice8** ppDevice); extern HRESULT WINAPI IDirect3DSurface8Impl_SetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags); extern HRESULT WINAPI IDirect3DSurface8Impl_GetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid,void* pData,DWORD* pSizeOfData); @@ -618,6 +535,91 @@ extern HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface, D3 extern HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect,DWORD Flags); extern HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface); +/* ------------------ */ +/* IDirect3DResource8 */ +/* ------------------ */ + +/***************************************************************************** + * Predeclare the interface implementation structures + */ +extern ICOM_VTABLE(IDirect3DResource8) Direct3DResource8_Vtbl; + +/***************************************************************************** + * IDirect3DResource8 implementation structure + */ +struct IDirect3DResource8Impl +{ + /* IUnknown fields */ + ICOM_VFIELD(IDirect3DResource8); + DWORD ref; + + /* IDirect3DResource8 fields */ + IDirect3DDevice8Impl *Device; + D3DRESOURCETYPE ResourceType; +}; + +/* IUnknown: */ +extern HRESULT WINAPI IDirect3DResource8Impl_QueryInterface(LPDIRECT3DRESOURCE8 iface,REFIID refiid,LPVOID *obj); +extern ULONG WINAPI IDirect3DResource8Impl_AddRef(LPDIRECT3DRESOURCE8 iface); +extern ULONG WINAPI IDirect3DResource8Impl_Release(LPDIRECT3DRESOURCE8 iface); + +/* IDirect3DResource8: */ +extern HRESULT WINAPI IDirect3DResource8Impl_GetDevice(LPDIRECT3DRESOURCE8 iface, IDirect3DDevice8** ppDevice); +extern HRESULT WINAPI IDirect3DResource8Impl_SetPrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags); +extern HRESULT WINAPI IDirect3DResource8Impl_GetPrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData); +extern HRESULT WINAPI IDirect3DResource8Impl_FreePrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid); +extern DWORD WINAPI IDirect3DResource8Impl_SetPriority(LPDIRECT3DRESOURCE8 iface, DWORD PriorityNew); +extern DWORD WINAPI IDirect3DResource8Impl_GetPriority(LPDIRECT3DRESOURCE8 iface); +extern void WINAPI IDirect3DResource8Impl_PreLoad(LPDIRECT3DRESOURCE8 iface); +extern D3DRESOURCETYPE WINAPI IDirect3DResource8Impl_GetType(LPDIRECT3DRESOURCE8 iface); + +/* ---------------------- */ +/* IDirect3DVertexBuffer8 */ +/* ---------------------- */ + +/***************************************************************************** + * Predeclare the interface implementation structures + */ +extern ICOM_VTABLE(IDirect3DVertexBuffer8) Direct3DVertexBuffer8_Vtbl; + +/***************************************************************************** + * IDirect3DVertexBuffer8 implementation structure + */ +struct IDirect3DVertexBuffer8Impl +{ + /* IUnknown fields */ + ICOM_VFIELD(IDirect3DVertexBuffer8); + DWORD ref; + + /* IDirect3DResource8 fields */ + IDirect3DDevice8Impl *Device; + D3DRESOURCETYPE ResourceType; + + /* IDirect3DVertexBuffer8 fields */ + BYTE *allocatedMemory; + D3DVERTEXBUFFER_DESC currentDesc; +}; + +/* IUnknown: */ +extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER8 iface,REFIID refiid,LPVOID *obj); +extern ULONG WINAPI IDirect3DVertexBuffer8Impl_AddRef(LPDIRECT3DVERTEXBUFFER8 iface); +extern ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 iface); + +/* IDirect3DVertexBuffer8: (Inherited from IDirect3DResource8) */ +extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDevice(LPDIRECT3DVERTEXBUFFER8 iface, IDirect3DDevice8** ppDevice); +extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags); +extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData); +extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid); +extern DWORD WINAPI IDirect3DVertexBuffer8Impl_SetPriority(LPDIRECT3DVERTEXBUFFER8 iface, DWORD PriorityNew); +extern DWORD WINAPI IDirect3DVertexBuffer8Impl_GetPriority(LPDIRECT3DVERTEXBUFFER8 iface); +extern void WINAPI IDirect3DVertexBuffer8Impl_PreLoad(LPDIRECT3DVERTEXBUFFER8 iface); +extern D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer8Impl_GetType(LPDIRECT3DVERTEXBUFFER8 iface); + +/* IDirect3DVertexBuffer8: */ +extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_Lock(LPDIRECT3DVERTEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE** ppbData, DWORD Flags); +extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_Unlock(LPDIRECT3DVERTEXBUFFER8 iface); +extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8 iface, D3DVERTEXBUFFER_DESC *pDesc); + /* --------------------- */ /* IDirect3DIndexBuffer8 */ /* --------------------- */ @@ -636,20 +638,21 @@ struct IDirect3DIndexBuffer8Impl ICOM_VFIELD(IDirect3DIndexBuffer8); DWORD ref; - /* IDirect3DIndexBuffer8 fields */ + /* IDirect3DResource8 fields */ IDirect3DDevice8Impl *Device; D3DRESOURCETYPE ResourceType; - D3DINDEXBUFFER_DESC currentDesc; + /* IDirect3DIndexBuffer8 fields */ void *allocatedMemory; + D3DINDEXBUFFER_DESC currentDesc; }; /* IUnknown: */ -extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_QueryInterface(LPDIRECT3DINDEXBUFFER8 iface,REFIID refiid,LPVOID *obj); -extern ULONG WINAPI IDirect3DIndexBuffer8Impl_AddRef(LPDIRECT3DINDEXBUFFER8 iface); -extern ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 iface); +extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_QueryInterface(LPDIRECT3DINDEXBUFFER8 iface,REFIID refiid,LPVOID *obj); +extern ULONG WINAPI IDirect3DIndexBuffer8Impl_AddRef(LPDIRECT3DINDEXBUFFER8 iface); +extern ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 iface); -/* IDirect3DIndexBuffer8 (Inherited from IDirect3DResource8) */ +/* IDirect3DIndexBuffer8: (Inherited from IDirect3DResource8) */ extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8 iface, IDirect3DDevice8** ppDevice); extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags); extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData); @@ -659,12 +662,61 @@ extern DWORD WINAPI IDirect3DIndexBuffer8Impl_GetPriority(LPDIRECT3DIN extern void WINAPI IDirect3DIndexBuffer8Impl_PreLoad(LPDIRECT3DINDEXBUFFER8 iface); extern D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer8Impl_GetType(LPDIRECT3DINDEXBUFFER8 iface); -/* IDirect3DIndexBuffer8 */ +/* IDirect3DIndexBuffer8: */ extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE** ppbData, DWORD Flags); extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBUFFER8 iface); extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 iface, D3DINDEXBUFFER_DESC *pDesc); /* --------------------- */ +/* IDirect3DBaseTexture8 */ +/* --------------------- */ + +/***************************************************************************** + * Predeclare the interface implementation structures + */ +extern ICOM_VTABLE(IDirect3DBaseTexture8) Direct3DBaseTexture8_Vtbl; + +/***************************************************************************** + * IDirect3DBaseTexture8 implementation structure + */ +struct IDirect3DBaseTexture8Impl +{ + /* IUnknown fields */ + ICOM_VFIELD(IDirect3DBaseTexture8); + DWORD ref; + + /* IDirect3DResource8 fields */ + IDirect3DDevice8Impl *Device; + D3DRESOURCETYPE ResourceType; + + /* IDirect3DBaseTexture8 fields */ + /* + *BOOL isManaged; + *DWORD lod; + */ +}; + +/* IUnknown: */ +extern HRESULT WINAPI IDirect3DBaseTexture8Impl_QueryInterface(LPDIRECT3DBASETEXTURE8 iface,REFIID refiid,LPVOID *obj); +extern ULONG WINAPI IDirect3DBaseTexture8Impl_AddRef(LPDIRECT3DBASETEXTURE8 iface); +extern ULONG WINAPI IDirect3DBaseTexture8Impl_Release(LPDIRECT3DBASETEXTURE8 iface); + +/* IDirect3DBaseTexture8: (Inherited from IDirect3DResource8) */ +extern HRESULT WINAPI IDirect3DBaseTexture8Impl_GetDevice(LPDIRECT3DBASETEXTURE8 iface, IDirect3DDevice8** ppDevice); +extern HRESULT WINAPI IDirect3DBaseTexture8Impl_SetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags); +extern HRESULT WINAPI IDirect3DBaseTexture8Impl_GetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData); +extern HRESULT WINAPI IDirect3DBaseTexture8Impl_FreePrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid); +extern DWORD WINAPI IDirect3DBaseTexture8Impl_SetPriority(LPDIRECT3DBASETEXTURE8 iface, DWORD PriorityNew); +extern DWORD WINAPI IDirect3DBaseTexture8Impl_GetPriority(LPDIRECT3DBASETEXTURE8 iface); +extern void WINAPI IDirect3DBaseTexture8Impl_PreLoad(LPDIRECT3DBASETEXTURE8 iface); +extern D3DRESOURCETYPE WINAPI IDirect3DBaseTexture8Impl_GetType(LPDIRECT3DBASETEXTURE8 iface); + +/* IDirect3DBaseTexture8: */ +extern DWORD WINAPI IDirect3DBaseTexture8Impl_SetLOD(LPDIRECT3DBASETEXTURE8 iface, DWORD LODNew); +extern DWORD WINAPI IDirect3DBaseTexture8Impl_GetLOD(LPDIRECT3DBASETEXTURE8 iface); +extern DWORD WINAPI IDirect3DBaseTexture8Impl_GetLevelCount(LPDIRECT3DBASETEXTURE8 iface); + +/* --------------------- */ /* IDirect3DCubeTexture8 */ /* --------------------- */ @@ -682,26 +734,29 @@ struct IDirect3DCubeTexture8Impl ICOM_VFIELD(IDirect3DCubeTexture8); DWORD ref; - /* IDirect3DCubeTexture8 fields */ + /* IDirect3DResource8 fields */ IDirect3DDevice8Impl *Device; D3DRESOURCETYPE ResourceType; - UINT edgeLength; - DWORD usage; - UINT levels; - D3DFORMAT format; + /* IDirect3DBaseTexture8 fields */ + + /* IDirect3DCubeTexture8 fields */ + UINT edgeLength; + DWORD usage; + UINT levels; + D3DFORMAT format; - IDirect3DDevice8Impl *device; - IDirect3DSurface8Impl *surfaces[6][MAX_LEVELS]; - BOOL Dirty; + IDirect3DDevice8Impl *device; + IDirect3DSurface8Impl *surfaces[6][MAX_LEVELS]; + BOOL Dirty; }; /* IUnknown: */ -extern HRESULT WINAPI IDirect3DCubeTexture8Impl_QueryInterface(LPDIRECT3DCUBETEXTURE8 iface,REFIID refiid,LPVOID *obj); -extern ULONG WINAPI IDirect3DCubeTexture8Impl_AddRef(LPDIRECT3DCUBETEXTURE8 iface); -extern ULONG WINAPI IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 iface); +extern HRESULT WINAPI IDirect3DCubeTexture8Impl_QueryInterface(LPDIRECT3DCUBETEXTURE8 iface,REFIID refiid,LPVOID *obj); +extern ULONG WINAPI IDirect3DCubeTexture8Impl_AddRef(LPDIRECT3DCUBETEXTURE8 iface); +extern ULONG WINAPI IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 iface); -/* IDirect3DCubeTexture8 (Inherited from IDirect3DResource8) */ +/* IDirect3DCubeTexture8: (Inherited from IDirect3DResource8) */ extern HRESULT WINAPI IDirect3DCubeTexture8Impl_GetDevice(LPDIRECT3DCUBETEXTURE8 iface, IDirect3DDevice8** ppDevice); extern HRESULT WINAPI IDirect3DCubeTexture8Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags); extern HRESULT WINAPI IDirect3DCubeTexture8Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData); @@ -711,7 +766,7 @@ extern DWORD WINAPI IDirect3DCubeTexture8Impl_GetPriority(LPDIRECT3DCU extern void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8 iface); extern D3DRESOURCETYPE WINAPI IDirect3DCubeTexture8Impl_GetType(LPDIRECT3DCUBETEXTURE8 iface); -/* IDirect3DCubeTexture8 (Inherited from IDirect3DBaseTexture8) */ +/* IDirect3DCubeTexture8: (Inherited from IDirect3DBaseTexture8) */ extern DWORD WINAPI IDirect3DCubeTexture8Impl_SetLOD(LPDIRECT3DCUBETEXTURE8 iface, DWORD LODNew); extern DWORD WINAPI IDirect3DCubeTexture8Impl_GetLOD(LPDIRECT3DCUBETEXTURE8 iface); extern DWORD WINAPI IDirect3DCubeTexture8Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE8 iface); @@ -741,27 +796,30 @@ struct IDirect3DTexture8Impl ICOM_VFIELD(IDirect3DTexture8); DWORD ref; - /* IDirect3DTexture8 fields */ + /* IDirect3DResourc8 fields */ IDirect3DDevice8Impl *Device; D3DRESOURCETYPE ResourceType; - UINT width; - UINT height; - UINT levels; - DWORD usage; - D3DFORMAT format; - IDirect3DDevice8Impl *device; - IDirect3DSurface8Impl *surfaces[MAX_LEVELS]; - BOOL Dirty; + /* IDirect3DBaseTexture8 fields */ + /* IDirect3DTexture8 fields */ + UINT width; + UINT height; + UINT levels; + DWORD usage; + D3DFORMAT format; + + IDirect3DDevice8Impl *device; + IDirect3DSurface8Impl *surfaces[MAX_LEVELS]; + BOOL Dirty; }; /* IUnknown: */ -extern HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface,REFIID refiid,LPVOID *obj); -extern ULONG WINAPI IDirect3DTexture8Impl_AddRef(LPDIRECT3DTEXTURE8 iface); -extern ULONG WINAPI IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface); +extern HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface,REFIID refiid,LPVOID *obj); +extern ULONG WINAPI IDirect3DTexture8Impl_AddRef(LPDIRECT3DTEXTURE8 iface); +extern ULONG WINAPI IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface); -/* IDirect3DTexture8 (Inherited from IDirect3DResource8) */ +/* IDirect3DTexture8: (Inherited from IDirect3DResource8) */ extern HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface, IDirect3DDevice8** ppDevice); extern HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags); extern HRESULT WINAPI IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData); @@ -771,12 +829,12 @@ extern DWORD WINAPI IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTUR extern void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface); extern D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface); -/* IDirect3DTexture8 (Inherited from IDirect3DBaseTexture8) */ +/* IDirect3DTexture8: (Inherited from IDirect3DBaseTexture8) */ extern DWORD WINAPI IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD LODNew); extern DWORD WINAPI IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface); extern DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface); -/* IDirect3DTexture8 */ +/* IDirect3DTexture8: */ extern HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level,D3DSURFACE_DESC* pDesc); extern HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level,IDirect3DSurface8** ppSurfaceLevel); extern HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags); @@ -801,9 +859,13 @@ struct IDirect3DVolumeTexture8Impl ICOM_VFIELD(IDirect3DVolumeTexture8); DWORD ref; - /* IDirect3DVolumeTexture8 fields */ + /* IDirect3DResource8 fields */ IDirect3DDevice8Impl *Device; D3DRESOURCETYPE ResourceType; + + /* IDirect3DBaseTexture8 fields */ + + /* IDirect3DVolumeTexture8 fields */ UINT width; UINT height; UINT depth; @@ -811,18 +873,17 @@ struct IDirect3DVolumeTexture8Impl DWORD usage; D3DFORMAT format; - IDirect3DDevice8Impl *device; - IDirect3DVolume8Impl *volumes[MAX_LEVELS]; - BOOL Dirty; - + IDirect3DDevice8Impl *device; + IDirect3DVolume8Impl *volumes[MAX_LEVELS]; + BOOL Dirty; }; /* IUnknown: */ -extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE8 iface,REFIID refiid,LPVOID *obj); -extern ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface); -extern ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface); +extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE8 iface,REFIID refiid,LPVOID *obj); +extern ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface); +extern ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface); -/* IDirect3DVolumeTexture8 (Inherited from IDirect3DResource8) */ +/* IDirect3DVolumeTexture8: (Inherited from IDirect3DResource8) */ extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE8 iface, IDirect3DDevice8** ppDevice); extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags); extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData); @@ -832,12 +893,12 @@ extern DWORD WINAPI IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3D extern void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8 iface); extern D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface); -/* IDirect3DVolumeTexture8 (Inherited from IDirect3DBaseTexture8) */ +/* IDirect3DVolumeTexture8: (Inherited from IDirect3DBaseTexture8) */ extern DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD LODNew); extern DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8 iface); extern DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface); -/* IDirect3DVolumeTexture8 */ +/* IDirect3DVolumeTexture8: */ extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level,D3DVOLUME_DESC *pDesc); extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level,IDirect3DVolume8** ppVolumeLevel); extern HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags); diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index b945b233a4a..d048c4a5ae4 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -29,6 +29,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); +static VERTEXSHADER8* VertexShaders[64]; +static PIXELSHADER8* PixelShaders[64]; + /* CreateVertexShader can return > 0xFFFF */ #define VS_HIGHESTFIXEDFXF 0xF0000000 @@ -90,7 +93,7 @@ void DrawPrimitiveI(LPDIRECT3DDEVICE8 iface, ICOM_THIS(IDirect3DDevice8Impl,iface); /* Dont understand how to handle multiple streams, but if a fixed - FVF is passed in rather than a handle, it must use stream 0 */ + FVF is passed in rather than a handle, it must use stream 0 */ if (This->StateBlock.VertexShader > VS_HIGHESTFIXEDFXF) { FIXME("Cant handle created shaders yet\n"); @@ -558,7 +561,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_QueryInterface(LPDIRECT3DDEVICE8 iface,REFII ICOM_THIS(IDirect3DDevice8Impl,iface); if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_IClassFactory)) { + || IsEqualGUID(riid, &IID_IDirect3DDevice8)) { IDirect3DDevice8Impl_AddRef(iface); *ppobj = This; return D3D_OK; @@ -898,8 +901,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface, *ppCubeTexture = (LPDIRECT3DCUBETEXTURE8)object; return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface, UINT Size,DWORD Usage, - DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer8** ppVertexBuffer) { +HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface, UINT Size, DWORD Usage, + DWORD FVF,D3DPOOL Pool, IDirect3DVertexBuffer8** ppVertexBuffer) { IDirect3DVertexBuffer8Impl *object; ICOM_THIS(IDirect3DDevice8Impl,iface); @@ -2185,7 +2188,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_ApplyStateBlock(LPDIRECT3DDEVICE8 iface, D if (pSB->blockType == D3DSBT_RECORDED || pSB->blockType == D3DSBT_ALL || pSB->blockType == D3DSBT_PIXELSTATE) { if (pSB->Set.pixelShader && pSB->Changed.pixelShader) - IDirect3DDevice8Impl_SetVertexShader(iface, pSB->PixelShader); + IDirect3DDevice8Impl_SetPixelShader(iface, pSB->PixelShader); /* TODO: Pixel Shader Constants */ } @@ -2336,28 +2339,28 @@ HRESULT WINAPI IDirect3DDevice8Impl_CaptureStateBlock(LPDIRECT3DDEVICE8 iface, if (updateBlock->Set.pixelShader && updateBlock->PixelShader != This->StateBlock.PixelShader) { TRACE("Updating pixel shader to %ld\n", This->StateBlock.PixelShader); updateBlock->lights[i] = This->StateBlock.lights[i]; - IDirect3DDevice8Impl_SetVertexShader(iface, updateBlock->PixelShader); + IDirect3DDevice8Impl_SetVertexShader(iface, updateBlock->PixelShader); } /* TODO: Pixel Shader Constants */ /* Others + Render & Texture */ - for (i=0; iSet.transform[i] && memcmp(&This->StateBlock.transforms[i], - &updateBlock->transforms[i], - sizeof(D3DMATRIX)) != 0) { - TRACE("Updating transform %d\n", i); - memcpy(&updateBlock->transforms[i], &This->StateBlock.transforms[i], sizeof(D3DMATRIX)); - } - } - - if (updateBlock->Set.Indices && ((updateBlock->pIndexData != This->StateBlock.pIndexData) - || (updateBlock->baseVertexIndex != This->StateBlock.baseVertexIndex))) { - TRACE("Updating pindexData to %p, baseVertexIndex to %d\n", - This->StateBlock.pIndexData, This->StateBlock.baseVertexIndex); - updateBlock->pIndexData = This->StateBlock.pIndexData; - updateBlock->baseVertexIndex = This->StateBlock.baseVertexIndex; - } + for (i=0; iSet.transform[i] && memcmp(&This->StateBlock.transforms[i], + &updateBlock->transforms[i], + sizeof(D3DMATRIX)) != 0) { + TRACE("Updating transform %d\n", i); + memcpy(&updateBlock->transforms[i], &This->StateBlock.transforms[i], sizeof(D3DMATRIX)); + } + } + + if (updateBlock->Set.Indices && ((updateBlock->pIndexData != This->StateBlock.pIndexData) + || (updateBlock->baseVertexIndex != This->StateBlock.baseVertexIndex))) { + TRACE("Updating pindexData to %p, baseVertexIndex to %d\n", + This->StateBlock.pIndexData, This->StateBlock.baseVertexIndex); + updateBlock->pIndexData = This->StateBlock.pIndexData; + updateBlock->baseVertexIndex = This->StateBlock.baseVertexIndex; + } if (updateBlock->Set.material && memcmp(&This->StateBlock.material, &updateBlock->material, @@ -2431,12 +2434,12 @@ HRESULT WINAPI IDirect3DDevice8Impl_CaptureStateBlock(LPDIRECT3DDEVICE8 iface, } HRESULT WINAPI IDirect3DDevice8Impl_DeleteStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) { ICOM_THIS(IDirect3DDevice8Impl,iface); - TRACE("(%p) : freeing token %lx\n", This, Token); + TRACE("(%p) : freeing StateBlock %lx\n", This, Token); HeapFree(GetProcessHeap(), 0, (void *)Token); return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_CreateStateBlock(LPDIRECT3DDEVICE8 iface, D3DSTATEBLOCKTYPE Type,DWORD* pToken) { +HRESULT WINAPI IDirect3DDevice8Impl_CreateStateBlock(LPDIRECT3DDEVICE8 iface, D3DSTATEBLOCKTYPE Type, DWORD* pToken) { void *memory; STATEBLOCK *s; int i,j; @@ -2446,7 +2449,12 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateStateBlock(LPDIRECT3DDEVICE8 iface, /* Allocate Storage */ memory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(STATEBLOCK)); - if (memory) memcpy(memory, &This->StateBlock, sizeof(STATEBLOCK)); + if (memory) { + memcpy(memory, &This->StateBlock, sizeof(STATEBLOCK)); + } else { + *pToken = 0xFFFFFFFF; + return E_OUTOFMEMORY; + } *pToken = (DWORD) memory; s = memory; s->blockType = Type; @@ -3069,9 +3077,42 @@ HRESULT WINAPI IDirect3DDevice8Impl_ProcessVertices(LPDIRECT3DDEVICE8 iface, U ICOM_THIS(IDirect3DDevice8Impl,iface); FIXME("(%p) : stub\n", This); return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pDeclaration,CONST DWORD* pFunction,DWORD* pHandle,DWORD Usage) { +HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pDeclaration, CONST DWORD* pFunction, DWORD* pHandle, DWORD Usage) { ICOM_THIS(IDirect3DDevice8Impl,iface); - FIXME("(%p) : stub\n", This); return D3D_OK; + VERTEXSHADER8* object; + UINT i; + + FIXME("(%p) : VertexShader not fully supported yet\n", This); + if (NULL == pDeclaration || NULL == pHandle) { /* pFunction can be NULL see MSDN */ + return D3DERR_INVALIDCALL; + } + for (i = 1; NULL != VertexShaders[i] && i < sizeof(VertexShaders) / sizeof(VERTEXSHADER8*); ++i) ; + if (i >= sizeof(VertexShaders) / sizeof(VERTEXSHADER8*)) { + return D3DERR_OUTOFVIDEOMEMORY; + } + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(VERTEXSHADER8)); + if (NULL == object) { + return D3DERR_OUTOFVIDEOMEMORY; + } + + object->usage = Usage; + object->data = NULL; /* TODO */ + + VertexShaders[i] = object; + *pHandle = VS_HIGHESTFIXEDFXF + i; + + object->decl = pDeclaration; + for (i = 0; 0xFFFFFFFF != pDeclaration[i]; ++i) ; + object->declLength = i + 1; + object->function = pFunction; + if (NULL != pFunction) { + for (i = 0; 0xFFFFFFFF != pFunction[i]; ++i) ; + object->functionLength = i + 1; + } else { + object->functionLength = 1; /* no Function defined use fixed function vertex processing */ + } + + return D3D_OK; } HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD Handle) { ICOM_THIS(IDirect3DDevice8Impl,iface); @@ -3096,30 +3137,108 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 iface, D } HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD* pHandle) { ICOM_THIS(IDirect3DDevice8Impl,iface); - TRACE("(%p) = %ld\n", This, This->StateBlock.VertexShader); + TRACE("(%p) : GetVertexShader returning %ld\n", This, This->StateBlock.VertexShader); *pHandle = This->StateBlock.VertexShader; return D3D_OK; } HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(LPDIRECT3DDEVICE8 iface, DWORD Handle) { ICOM_THIS(IDirect3DDevice8Impl,iface); - FIXME("(%p) : stub\n", This); return D3D_OK; + VERTEXSHADER8* object; + + if (Handle <= VS_HIGHESTFIXEDFXF) { /* only delete user defined shaders */ + return D3DERR_INVALIDCALL; + } + object = VertexShaders[Handle - VS_HIGHESTFIXEDFXF]; + TRACE("(%p) : freing VertexShader %p\n", This, object); + /* TODO: check validity of object */ + HeapFree(GetProcessHeap(), 0, (void *)object); + VertexShaders[Handle - VS_HIGHESTFIXEDFXF] = 0; + return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register,CONST void* pConstantData,DWORD ConstantCount) { - ICOM_THIS(IDirect3DDevice8Impl,iface); - FIXME("(%p) : stub\n", This); return D3D_OK; + +#define VERTEX_SHADER(Handle) ((Handle <= VS_HIGHESTFIXEDFXF) ? ((Handle >= sizeof(VertexShaders) / sizeof(VERTEXSHADER8*)) ? NULL : VertexShaders[Handle]) : VertexShaders[Handle - VS_HIGHESTFIXEDFXF]) + +HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, CONST void* pConstantData, DWORD ConstantCount) { + ICOM_THIS(IDirect3DDevice8Impl,iface); + VERTEXSHADER8* object; + DWORD Handle = This->UpdateStateBlock->VertexShader; + + FIXME("(%p) : VertexShader_SetConstant not fully supported yet\n", This); + + if (Register + ConstantCount > VSHADER_MAX_CONSTANTS) { + return D3DERR_INVALIDCALL; + } + object = VERTEX_SHADER(Handle); + if (NULL == object || NULL == pConstantData) { + return D3DERR_INVALIDCALL; + } + memcpy(object->data->constants + Register, pConstantData, ConstantCount * sizeof(SHADER8Vector)); + + return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register,void* pConstantData,DWORD ConstantCount) { - ICOM_THIS(IDirect3DDevice8Impl,iface); - FIXME("(%p) : stub\n", This); return D3D_OK; +HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, void* pConstantData, DWORD ConstantCount) { + ICOM_THIS(IDirect3DDevice8Impl,iface); + VERTEXSHADER8* object; + DWORD Handle = This->UpdateStateBlock->VertexShader; + + FIXME("(%p) : VertexShader_GetConstant not fully supported yet\n", This); + + if (Register + ConstantCount > VSHADER_MAX_CONSTANTS) { + return D3DERR_INVALIDCALL; + } + object = VERTEX_SHADER(Handle); + if (NULL == object || NULL == pConstantData) { + return D3DERR_INVALIDCALL; + } + memcpy(pConstantData, object->data->constants + Register, ConstantCount * sizeof(SHADER8Vector)); + + return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(LPDIRECT3DDEVICE8 iface, DWORD Handle,void* pData,DWORD* pSizeOfData) { +HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(LPDIRECT3DDEVICE8 iface, DWORD Handle, void* pData, DWORD* pSizeOfData) { ICOM_THIS(IDirect3DDevice8Impl,iface); - FIXME("(%p) : stub\n", This); return D3D_OK; + VERTEXSHADER8* object; + + object = VERTEX_SHADER(Handle); + if (NULL == object) { + return D3DERR_INVALIDCALL; + } + if (NULL == pData) { + *pSizeOfData = object->declLength; + return D3D_OK; + } + if (*pSizeOfData < object->declLength) { + *pSizeOfData = object->declLength; + return D3DERR_MOREDATA; + } + TRACE("(%p) : GetVertexShaderDeclaration copying to %p\n", This, pData); + memcpy(pData, object->decl, object->declLength); + return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD Handle,void* pData,DWORD* pSizeOfData) { +HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD Handle, void* pData, DWORD* pSizeOfData) { ICOM_THIS(IDirect3DDevice8Impl,iface); - FIXME("(%p) : stub\n", This); return D3D_OK; + VERTEXSHADER8* object; + + object = VERTEX_SHADER(Handle); + if (NULL == object) { + return D3DERR_INVALIDCALL; + } + if (NULL == pData) { + *pSizeOfData = object->functionLength; + return D3D_OK; + } + if (*pSizeOfData < object->functionLength) { + *pSizeOfData = object->functionLength; + return D3DERR_MOREDATA; + } + if (NULL == object->function) { /* no function defined */ + TRACE("(%p) : GetVertexShaderFunction no User Function defined using NULL to %p\n", This, pData); + ((DWORD *) pData) = NULL; + } else { + TRACE("(%p) : GetVertexShaderFunction copying to %p\n", This, pData); + memcpy(pData, object->function, object->functionLength); + } + return D3D_OK; } HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8* pIndexData,UINT BaseVertexIndex) { @@ -3156,9 +3275,34 @@ HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(LPDIRECT3DDEVICE8 iface, IDirec return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pFunction,DWORD* pHandle) { +HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pFunction, DWORD* pHandle) { ICOM_THIS(IDirect3DDevice8Impl,iface); - FIXME("(%p) : stub\n", This); return D3D_OK; + PIXELSHADER8* object; + UINT i; + + FIXME("(%p) : PixelShader not fully supported yet\n", This); + if (NULL == pFunction || NULL == pHandle) { + return D3DERR_INVALIDCALL; + } + for (i = 1; NULL != PixelShaders[i] && i < sizeof(PixelShaders) / sizeof(PIXELSHADER8*); ++i) ; + if (i >= sizeof(PixelShaders) / sizeof(PIXELSHADER8*)) { + return D3DERR_OUTOFVIDEOMEMORY; + } + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PIXELSHADER8)); + if (NULL == object) { + return D3DERR_OUTOFVIDEOMEMORY; + } + + object->data = NULL; /* TODO */ + + PixelShaders[i] = object; + *pHandle = VS_HIGHESTFIXEDFXF + i; + + object->function = pFunction; + for (i = 0; 0xFFFFFFFF != pFunction[i]; ++i) ; + object->functionLength = i + 1; + + return D3D_OK; } HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD Handle) { ICOM_THIS(IDirect3DDevice8Impl,iface); @@ -3175,35 +3319,65 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(LPDIRECT3DDEVICE8 iface, DW /* FIXME: Quieten when not being used */ if (Handle != 0) { - FIXME("(%p) : stub %ld\n", This, Handle); + FIXME("(%p) : stub %ld\n", This, Handle); } else { - TRACE("(%p) : stub %ld\n", This, Handle); + TRACE("(%p) : stub %ld\n", This, Handle); } return D3D_OK; } HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD* pHandle) { ICOM_THIS(IDirect3DDevice8Impl,iface); - TRACE("(%p) : returning %ld\n", This, This->StateBlock.PixelShader); + TRACE("(%p) : GetPixelShader returning %ld\n", This, This->StateBlock.PixelShader); *pHandle = This->StateBlock.PixelShader; return D3D_OK; } HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(LPDIRECT3DDEVICE8 iface, DWORD Handle) { ICOM_THIS(IDirect3DDevice8Impl,iface); - FIXME("(%p) : stub\n", This); return D3D_OK; + PIXELSHADER8* object; + + if (Handle <= VS_HIGHESTFIXEDFXF) { /* only delete user defined shaders */ + return D3DERR_INVALIDCALL; + } + object = PixelShaders[Handle - VS_HIGHESTFIXEDFXF]; + TRACE("(%p) : freeing PixelShader %p\n", This, object); + /* TODO: check validity of object before free */ + HeapFree(GetProcessHeap(), 0, (void *)object); + PixelShaders[Handle - VS_HIGHESTFIXEDFXF] = 0; + return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register,CONST void* pConstantData,DWORD ConstantCount) { +#define PIXEL_SHADER(Handle) ((Handle <= VS_HIGHESTFIXEDFXF) ? ((Handle >= sizeof(PixelShaders) / sizeof(PIXELSHADER8*)) ? NULL : PixelShaders[Handle]) : PixelShaders[Handle - VS_HIGHESTFIXEDFXF]) + +HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register,CONST void* pConstantData, DWORD ConstantCount) { ICOM_THIS(IDirect3DDevice8Impl,iface); - FIXME("(%p) : stub\n", This); return D3D_OK; + FIXME("(%p) : stub\n", This); + return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register,void* pConstantData,DWORD ConstantCount) { +HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register,void* pConstantData, DWORD ConstantCount) { ICOM_THIS(IDirect3DDevice8Impl,iface); - FIXME("(%p) : stub\n", This); return D3D_OK; + FIXME("(%p) : stub\n", This); + return D3D_OK; } -HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD Handle,void* pData,DWORD* pSizeOfData) { +HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD Handle, void* pData, DWORD* pSizeOfData) { ICOM_THIS(IDirect3DDevice8Impl,iface); - FIXME("(%p) : stub\n", This); return D3D_OK; + PIXELSHADER8* object; + + object = PIXEL_SHADER(Handle); + if (NULL == object) { + return D3DERR_INVALIDCALL; + } + if (NULL == pData) { + *pSizeOfData = object->functionLength; + return D3D_OK; + } + if (*pSizeOfData < object->functionLength) { + *pSizeOfData = object->functionLength; + return D3DERR_MOREDATA; + } + TRACE("(%p) : GetPixelShaderFunction copying to %p\n", This, pData); + memcpy(pData, object->function, object->functionLength); + return D3D_OK; } HRESULT WINAPI IDirect3DDevice8Impl_DrawRectPatch(LPDIRECT3DDEVICE8 iface, UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) { ICOM_THIS(IDirect3DDevice8Impl,iface); diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c index 46b07601f5e..f59523ab93c 100644 --- a/dlls/d3d8/directx.c +++ b/dlls/d3d8/directx.c @@ -63,7 +63,7 @@ HRESULT WINAPI IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface,REFIID riid,LPVOI ICOM_THIS(IDirect3D8Impl,iface); if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_IClassFactory)) { + || IsEqualGUID(riid, &IID_IDirect3D8)) { IDirect3D8Impl_AddRef(iface); *ppobj = This; return D3D_OK; diff --git a/dlls/d3d8/indexbuffer.c b/dlls/d3d8/indexbuffer.c index f74517f788b..7a0244b79fc 100644 --- a/dlls/d3d8/indexbuffer.c +++ b/dlls/d3d8/indexbuffer.c @@ -34,7 +34,8 @@ HRESULT WINAPI IDirect3DIndexBuffer8Impl_QueryInterface(LPDIRECT3DINDEXBUFFER8 i ICOM_THIS(IDirect3DIndexBuffer8Impl,iface); if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_IClassFactory)) { + || IsEqualGUID(riid, &IID_IDirect3DResource8) + || IsEqualGUID(riid, &IID_IDirect3DIndexBuffer8)) { IDirect3DIndexBuffer8Impl_AddRef(iface); *ppobj = This; return D3D_OK; @@ -55,8 +56,8 @@ ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 iface) { ULONG ref = --This->ref; TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref); if (ref == 0) { - HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This->allocatedMemory); + HeapFree(GetProcessHeap(), 0, This); } return ref; } @@ -106,7 +107,7 @@ HRESULT WINAPI IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 ifa } else { FIXME("(%p) : stub, offset %d, size %d, Flags=%lx\n", This, OffsetToLock, SizeToLock, Flags); } - *ppbData = This->allocatedMemory; + *ppbData = This->allocatedMemory + OffsetToLock; return D3D_OK; } diff --git a/dlls/d3d8/shader.c b/dlls/d3d8/shader.c new file mode 100644 index 00000000000..206eada5b12 --- /dev/null +++ b/dlls/d3d8/shader.c @@ -0,0 +1,337 @@ +/* + * shaders implementation + * + * Copyright 2002 Raphael Junqueira + * + * 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 "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "wingdi.h" +#include "wine/debug.h" + +#include + +#include "d3d8_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3d); + +typedef void (*shader_fct0_t)(void); +typedef void (*shader_fct1_t)(SHADER8Vector*); +typedef void (*shader_fct2_t)(SHADER8Vector*,SHADER8Vector*); +typedef void (*shader_fct3_t)(SHADER8Vector*,SHADER8Vector*,SHADER8Vector*); +typedef void (*shader_fct4_t)(SHADER8Vector*,SHADER8Vector*,SHADER8Vector*,SHADER8Vector*); + +/* +typedef union shader_fct { + shader_fct0_t fct0; + shader_fct1_t fct1; + shader_fct2_t fct2; + shader_fct3_t fct3; + shader_fct4_t fct4; +} shader_fct; +*/ +typedef void (*shader_fct)(); + +typedef struct shader_opcode { + CONST BYTE opcode; + const char* name; + CONST UINT num_params; + shader_fct soft_fct; + /* + union { + shader_fct0_t fct0; + shader_fct1_t fct1; + shader_fct2_t fct2; + shader_fct3_t fct3; + shader_fct4_t fct4; + } shader_fct; + */ +} shader_opcode; + +typedef struct vshader_input_data { + /*SHADER8Vector V[16];//0-15 */ + SHADER8Vector V0; + SHADER8Vector V1; + SHADER8Vector V2; + SHADER8Vector V3; + SHADER8Vector V4; + SHADER8Vector V5; + SHADER8Vector V6; + SHADER8Vector V7; + SHADER8Vector V8; + SHADER8Vector V9; + SHADER8Vector V10; + SHADER8Vector V11; + SHADER8Vector V12; + SHADER8Vector V13; + SHADER8Vector V14; + SHADER8Vector V15; +} vshader_input_data; + +typedef struct vshader_output_data { + SHADER8Vector oPos; + /*SHADER8Vector oD[2];//0-1 */ + SHADER8Vector oD0; + SHADER8Vector oD1; + /*SHADER8Vector oT[4];//0-3 */ + SHADER8Vector oT0; + SHADER8Vector oT1; + SHADER8Vector oT2; + SHADER8Vector oT3; + SHADER8Scalar oFog; + SHADER8Scalar oPts; +} vshader_output_data; + +/********************* + * vshader software VM + */ + +void vshader_add(SHADER8Vector* d, SHADER8Vector* s0, SHADER8Vector* s1) { + d->x = s0->x + s1->x; + d->y = s0->y + s1->y; + d->z = s0->z + s1->z; + d->w = s0->w + s1->w; +} + +void vshader_dp3(SHADER8Vector* d, SHADER8Vector* s0, SHADER8Vector* s1) { + d->x = d->y = d->z = d->w = s0->x * s1->x + s0->y * s1->y + s0->z * s1->z; +} + +void vshader_dp4(SHADER8Vector* d, SHADER8Vector* s0, SHADER8Vector* s1) { + d->x = d->y = d->z = d->w = s0->x * s1->x + s0->y * s1->y + s0->z * s1->z + s0->w * s1->w; +} + +void vshader_dst(SHADER8Vector* d, SHADER8Vector* s0, SHADER8Vector* s1) { + d->x = 1; + d->y = s0->y * s1->y; + d->z = s0->z; + d->w = s1->w; +} + +void vshader_expp(SHADER8Vector* d, SHADER8Vector* s0) { + float tmp_f = floorf(s0->w); + d->x = pow(2, tmp_f); + d->y = s0->w - tmp_f; + d->z = pow(2, s0->w); + d->w = 1; +} + +void vshader_lit(SHADER8Vector* d, SHADER8Vector* s0) { + d->x = 1; + d->y = (0 < s0->x) ? s0->x : 0; + d->z = (0 < s0->x && 0 < s0->y) ? pow(s0->y, s0->w) : 0; + d->w = 1; +} + +void vshader_logp(SHADER8Vector* d, SHADER8Vector* s0) { + d->x = d->y = d->z = d->w = (0 != s0->w) ? log(fabsf(s0->w))/log(2) : HUGE; +} + +void vshader_mad(SHADER8Vector* d, SHADER8Vector* s0, SHADER8Vector* s1, SHADER8Vector* s2) { + d->x = s0->x * s1->x + s2->x; + d->y = s0->y * s1->y + s2->y; + d->z = s0->z * s1->z + s2->z; + d->w = s0->w * s1->w + s2->w; +} + +void vshader_max(SHADER8Vector* d, SHADER8Vector* s0, SHADER8Vector* s1) { + d->x = (s0->x >= s1->x) ? s0->x : s1->x; + d->y = (s0->y >= s1->y) ? s0->y : s1->y; + d->z = (s0->z >= s1->z) ? s0->z : s1->z; + d->w = (s0->w >= s1->w) ? s0->w : s1->w; +} + +void vshader_min(SHADER8Vector* d, SHADER8Vector* s0, SHADER8Vector* s1) { + d->x = (s0->x < s1->x) ? s0->x : s1->x; + d->y = (s0->y < s1->y) ? s0->y : s1->y; + d->z = (s0->z < s1->z) ? s0->z : s1->z; + d->w = (s0->w < s1->w) ? s0->w : s1->w; +} + +void vshader_mov(SHADER8Vector* d, SHADER8Vector* s0) { + d->x = s0->x; + d->y = s0->y; + d->z = s0->z; + d->w = s0->w; +} + +void vshader_mul(SHADER8Vector* d, SHADER8Vector* s0, SHADER8Vector* s1) { + d->x = s0->x * s1->x; + d->y = s0->y * s1->y; + d->z = s0->z * s1->z; + d->w = s0->w * s1->w; +} + +void vshader_nop(void) { + /* NOPPPP ahhh too easy ;) */ +} + +void vshader_rcp(SHADER8Vector* d, SHADER8Vector* s0) { + d->x = d->y = d->z = d->w = (0 == s0->w) ? HUGE : 1 / s0->w; +} + +void vshader_rsq(SHADER8Vector* d, SHADER8Vector* s0) { + d->x = d->y = d->z = d->w = (0 == s0->w) ? HUGE : 1 / sqrt(fabsf(s0->w)); +} + +void vshader_sge(SHADER8Vector* d, SHADER8Vector* s0, SHADER8Vector* s1) { + d->x = (s0->x >= s1->x) ? 1 : 0; + d->y = (s0->y >= s1->y) ? 1 : 0; + d->z = (s0->z >= s1->z) ? 1 : 0; + d->w = (s0->w >= s1->w) ? 1 : 0; +} + +void vshader_slt(SHADER8Vector* d, SHADER8Vector* s0, SHADER8Vector* s1) { + d->x = (s0->x < s1->x) ? 1 : 0; + d->y = (s0->y < s1->y) ? 1 : 0; + d->z = (s0->z < s1->z) ? 1 : 0; + d->w = (s0->w < s1->w) ? 1 : 0; +} + +void vshader_sub(SHADER8Vector* d, SHADER8Vector* s0, SHADER8Vector* s1) { + d->x = s0->x - s1->x; + d->y = s0->y - s1->y; + d->z = s0->z - s1->z; + d->w = s0->w - s1->w; +} + +/** + * log, exp, frc, m*x* seems to be macros ins ... to see + * + * @TODO: find this fucking really opcodes values + */ +static CONST shader_opcode vshader_ins [] = + { + {0, "mov", 2, vshader_mov}, + {0, "max", 3, vshader_max}, + {0, "min", 3, vshader_min}, + {0, "sge", 3, vshader_sge}, + {0, "slt", 3, vshader_slt}, + {0, "add", 3, vshader_add}, + {0, "sub", 3, vshader_sub}, + {0, "mul", 3, vshader_mul}, + {0, "rcp", 2, vshader_rcp}, + {0, "mad", 4, vshader_mad}, + {0, "dp3", 3, vshader_dp3}, + {0, "dp4", 3, vshader_dp4}, + {0, "rsq", 2, vshader_rsq}, + {0, "dst", 3, vshader_dst}, + {0, "lit", 2, vshader_lit}, + {0, "expp", 2, vshader_expp}, + {0, "logp", 2, vshader_logp}, + {0, "nop", 0, vshader_nop}, + {0, NULL, 0, NULL} + }; + + +shader_opcode* vshader_get_opcode(const DWORD code) { + return NULL; +} + +/** + * Function parser ... + */ +BOOL vshader_parse_function(const DWORD* function) { + return TRUE; +} + +BOOL vshader_hardware_execute_function(VERTEXSHADER8* vshader, + const vshader_input_data* input, + vshader_output_data* output) { + /** + * TODO: use the GL_NV_vertex_program + * and specifics vendors variants for it + */ + return TRUE; +} + +BOOL vshader_software_execute_function(VERTEXSHADER8* vshader, + const vshader_input_data* input, + vshader_output_data* output) { + /** Vertex Shader Temporary Registers */ + /*SHADER8Vector R[12];*/ + /*SHADER8Scalar A0;*/ + /** temporary Vector for modifier management */ + /*SHADER8Vector d;*/ + /** parser datas */ + const DWORD* pToken = vshader->function; + shader_opcode* curOpcode = NULL; + + /* the first dword is the version tag */ + /* TODO: parse it */ + + ++pToken; + while (0xFFFFFFFF != *pToken) { + curOpcode = vshader_get_opcode(*pToken); + ++pToken; + if (NULL == curOpcode) { + /* unkown current opcode ... */ + return FALSE; + } + if (curOpcode->num_params > 0) { + /* TODO */ + } + } + return TRUE; +} + +/** + * Declaration Parser First draft ... + */ + +#if 0 +static CONST char* vshader_decl [] = + { + "D3DVSDT_D3DCOLOR", + "D3DVSDT_FLOAT1", + "D3DVSDT_FLOAT2", + "D3DVSDT_FLOAT3", + "D3DVSDT_FLOAT4", + "D3DVSDT_UBYTE4", + NULL + }; +#endif + +/** Vertex Shader Declaration parser tokens */ +enum D3DVSD_TOKENS { + D3DVSD_STREAM, + + D3DVSD_END +}; + +BOOL vshader_parse_declaration(VERTEXSHADER8* vshader) { + /** parser data */ + const DWORD* pToken = vshader->decl; + + ++pToken; + while (0xFFFFFFFF != *pToken) { + /** TODO */ + ++pToken; + } + return TRUE; +} + +HRESULT WINAPI ValidatePixelShader(void) { + FIXME("(void): stub\n"); + return 0; +} + +HRESULT WINAPI ValidateVertexShader(void) { + FIXME("(void): stub\n"); + return 0; +} diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c index 201d67ca623..2686002093c 100644 --- a/dlls/d3d8/surface.c +++ b/dlls/d3d8/surface.c @@ -34,7 +34,7 @@ HRESULT WINAPI IDirect3DSurface8Impl_QueryInterface(LPDIRECT3DSURFACE8 iface,REF ICOM_THIS(IDirect3DSurface8Impl,iface); if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_IClassFactory)) { + || IsEqualGUID(riid, &IID_IDirect3DSurface8)) { IDirect3DSurface8Impl_AddRef(iface); *ppobj = This; return D3D_OK; diff --git a/dlls/d3d8/swapchain.c b/dlls/d3d8/swapchain.c index 88e7b90e72d..22c55febf00 100644 --- a/dlls/d3d8/swapchain.c +++ b/dlls/d3d8/swapchain.c @@ -34,7 +34,7 @@ HRESULT WINAPI IDirect3DSwapChain8Impl_QueryInterface(LPDIRECT3DSWAPCHAIN8 iface ICOM_THIS(IDirect3DSwapChain8Impl,iface); if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_IClassFactory)) { + || IsEqualGUID(riid, &IID_IDirect3DSwapChain8)) { IDirect3DSwapChain8Impl_AddRef(iface); *ppobj = This; return D3D_OK; diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c index 8f6a34c3a02..de99c2dd54c 100644 --- a/dlls/d3d8/texture.c +++ b/dlls/d3d8/texture.c @@ -34,7 +34,9 @@ HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface,REF ICOM_THIS(IDirect3DTexture8Impl,iface); TRACE("(%p) : QueryInterface\n", This); if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_IClassFactory)) { + || IsEqualGUID(riid, &IID_IDirect3DResource8) + || IsEqualGUID(riid, &IID_IDirect3DBaseTexture8) + || IsEqualGUID(riid, &IID_IDirect3DTexture8)) { IDirect3DTexture8Impl_AddRef(iface); *ppobj = This; return D3D_OK; diff --git a/dlls/d3d8/vertexbuffer.c b/dlls/d3d8/vertexbuffer.c index 6226ac490c8..db5061bf04c 100644 --- a/dlls/d3d8/vertexbuffer.c +++ b/dlls/d3d8/vertexbuffer.c @@ -29,12 +29,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); /* IDirect3DResource IUnknown parts follow: */ -HRESULT WINAPI IDirect3DVertexBuffer8Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER8 iface,REFIID riid,LPVOID *ppobj) +HRESULT WINAPI IDirect3DVertexBuffer8Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER8 iface, REFIID riid, LPVOID *ppobj) { ICOM_THIS(IDirect3DVertexBuffer8Impl,iface); if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_IClassFactory)) { + || IsEqualGUID(riid, &IID_IDirect3DResource8) + || IsEqualGUID(riid, &IID_IDirect3DVertexBuffer8)) { IDirect3DVertexBuffer8Impl_AddRef(iface); *ppobj = This; return D3D_OK; @@ -55,7 +56,7 @@ ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 iface) { ULONG ref = --This->ref; TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref); if (ref == 0) { - HeapFree(GetProcessHeap(), 0, This->allocatedMemory); + if (NULL != This->allocatedMemory) HeapFree(GetProcessHeap(), 0, This->allocatedMemory); HeapFree(GetProcessHeap(), 0, This); } return ref; @@ -101,9 +102,9 @@ D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer8Impl_GetType(LPDIRECT3DVERTEXBUFFER /* IDirect3DVertexBuffer8 */ HRESULT WINAPI IDirect3DVertexBuffer8Impl_Lock(LPDIRECT3DVERTEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE** ppbData, DWORD Flags) { ICOM_THIS(IDirect3DVertexBuffer8Impl,iface); - if (OffsetToLock) FIXME("(%p) : with non-zero offset!!\n", This); - TRACE("(%p) : returning memory of %p\n", This, This->allocatedMemory); - *ppbData = This->allocatedMemory; + TRACE("(%p) : returning memory of %p (base:%p,offset:%u)\n", This, This->allocatedMemory + OffsetToLock, This->allocatedMemory, OffsetToLock); + /* TODO: check Flags compatibility with This->currentDesc.Usage (see MSDN) */ + *ppbData = This->allocatedMemory + OffsetToLock; return D3D_OK; } HRESULT WINAPI IDirect3DVertexBuffer8Impl_Unlock(LPDIRECT3DVERTEXBUFFER8 iface) { diff --git a/dlls/d3d8/volume.c b/dlls/d3d8/volume.c index e0d0dfca86b..6eb43fa14b7 100644 --- a/dlls/d3d8/volume.c +++ b/dlls/d3d8/volume.c @@ -34,7 +34,7 @@ HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 iface,REFII ICOM_THIS(IDirect3DVolume8Impl,iface); if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_IClassFactory)) { + || IsEqualGUID(riid, &IID_IDirect3DVolume8)) { IDirect3DVolume8Impl_AddRef(iface); *ppobj = This; return D3D_OK; diff --git a/dlls/d3dx8/.cvsignore b/dlls/d3dx8/.cvsignore new file mode 100644 index 00000000000..5d4918968b1 --- /dev/null +++ b/dlls/d3dx8/.cvsignore @@ -0,0 +1,4 @@ +Makefile +d3dx8.dll.dbg.c +d3dx8.spec.c +d3dx8.spec.def diff --git a/dlls/d3d8/Makefile.in b/dlls/d3dx8/Makefile.in similarity index 54% copy from dlls/d3d8/Makefile.in copy to dlls/d3dx8/Makefile.in index e0faaef014a..7c64074b232 100644 --- a/dlls/d3d8/Makefile.in +++ b/dlls/d3dx8/Makefile.in @@ -2,8 +2,8 @@ TOPSRCDIR = @top_srcdir@ TOPOBJDIR = ../.. SRCDIR = @srcdir@ VPATH = @srcdir@ -MODULE = d3d8.dll -IMPORTS = user32 gdi32 kernel32 +MODULE = d3dx8.dll +IMPORTS = d3d8 user32 gdi32 kernel32 EXTRAINCL = @X_CFLAGS@ EXTRALIBS = $(LIBUUID) @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@ @OPENGL_LIBS@ @@ -11,19 +11,8 @@ LDDLLFLAGS = @LDDLLFLAGS@ SYMBOLFILE = $(MODULE).tmp.o C_SRCS = \ - basetexture.c \ - cubetexture.c \ - d3d8_main.c \ - device.c \ - directx.c \ - indexbuffer.c \ - resource.c \ - surface.c \ - swapchain.c \ - texture.c \ - vertexbuffer.c \ - volume.c \ - volumetexture.c \ + d3dx8_main.c \ + d3dxbuffer.c @MAKE_DLL_RULES@ diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec new file mode 100644 index 00000000000..9ad7a79cb74 --- /dev/null +++ b/dlls/d3dx8/d3dx8.spec @@ -0,0 +1,6 @@ +@ stdcall D3DXCreateBuffer(long ptr) D3DXCreateBuffer +@ stdcall D3DXCreateFont(ptr ptr ptr) D3DXCreateFont +@ stdcall D3DXGetFVFVertexSize(long) D3DXGetFVFVertexSize +@ stdcall D3DXAssembleShader(ptr long long ptr ptr ptr) D3DXAssembleShader +@ stdcall D3DXAssembleShaderFromFileA(ptr long ptr ptr ptr) D3DXAssembleShaderFromFileA +@ stdcall D3DXAssembleShaderFromFileW(ptr long ptr ptr ptr) D3DXAssembleShaderFromFileW diff --git a/dlls/d3dx8/d3dx8_main.c b/dlls/d3dx8/d3dx8_main.c new file mode 100644 index 00000000000..18abfa93b87 --- /dev/null +++ b/dlls/d3dx8/d3dx8_main.c @@ -0,0 +1,90 @@ +/* + * Direct3D X 8 main file + * + * Copyright (C) 2002 Raphael Junqueira + * + * 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 "wine/port.h" + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "wine/debug.h" + +#include "d3dx8core.h" +#include "d3dx8core_private.h" + + +WINE_DEFAULT_DEBUG_CHANNEL(d3d); + +HRESULT D3DXCreateBuffer(DWORD NumBytes, LPD3DXBUFFER* ppBuffer) { + ID3DXBufferImpl *object; + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ID3DXBufferImpl)); + if (NULL == object) { + *ppBuffer = (LPD3DXBUFFER)NULL; + return E_OUTOFMEMORY; + } + object->lpVtbl = &D3DXBuffer_Vtbl; + object->ref = 1; + object->bufferSize = NumBytes; + object->buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, NumBytes); + if (NULL == object->buffer) { + HeapFree(GetProcessHeap(), 0, object); + *ppBuffer = (LPD3DXBUFFER)NULL; + return E_OUTOFMEMORY; + } + *ppBuffer = (LPD3DXBUFFER)object; + return D3D_OK; +} + +HRESULT D3DXCreateFont(LPDIRECT3DDEVICE8 pDevice, HFONT hFont, LPD3DXFONT* ppFont) { + FIXME("(void): stub\n"); + return D3D_OK; +} + +UINT D3DXGetFVFVertexSize(DWORD FVF) { + FIXME("(void): stub\n"); + return 0; +} + +HRESULT D3DXAssembleShader(LPCVOID pSrcData, UINT SrcDataLen, DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors) { + FIXME("(void): stub\n"); + return D3D_OK; +} + +HRESULT D3DXAssembleShaderFromFileA(LPSTR pSrcFile, DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors) { + FIXME("(void): stub\n"); + return D3D_OK; +} + +HRESULT D3DXAssembleShaderFromFileW(LPSTR pSrcFile, DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors) { + FIXME("(void): stub\n"); + return D3D_OK; +} diff --git a/dlls/d3dx8/d3dx8core_private.h b/dlls/d3dx8/d3dx8core_private.h new file mode 100644 index 00000000000..b7132d88b26 --- /dev/null +++ b/dlls/d3dx8/d3dx8core_private.h @@ -0,0 +1,91 @@ +/* + * Direct3D X 8 private include file + * + * Copyright 2002 Raphael Junqueira + * + * 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 + */ + +#ifndef __WINE_D3DX8CORE_PRIVATE_H +#define __WINE_D3DX8CORE_PRIVATE_H + +#include "d3dx8core.h" + +/* Interfaces */ +typedef struct ID3DXBufferImpl ID3DXBufferImpl; +typedef struct ID3DXFontImpl ID3DXFontImpl; + +/* ----------- */ +/* ID3DXBuffer */ +/* ----------- */ + +/***************************************************************************** + * Predeclare the interface implementation structures + */ +extern ICOM_VTABLE(ID3DXBuffer) D3DXBuffer_Vtbl; + +/***************************************************************************** + * ID3DXBufferImpl implementation structure + */ +struct ID3DXBufferImpl +{ + /* IUnknown fields */ + ICOM_VFIELD(ID3DXBuffer); + DWORD ref; + + /* ID3DXBuffer fields */ + DWORD *buffer; + DWORD bufferSize; +}; + +/* IUnknown: */ +extern HRESULT WINAPI ID3DXBufferImpl_QueryInterface(LPD3DXBUFFER iface, REFIID refiid, LPVOID *obj); +extern ULONG WINAPI ID3DXBufferImpl_AddRef(LPD3DXBUFFER iface); +extern ULONG WINAPI ID3DXBufferImpl_Release(LPD3DXBUFFER iface); + +/* ID3DXBuffer: */ +extern LPVOID WINAPI ID3DXBufferImpl_GetBufferPointer(LPD3DXBUFFER iface); +extern DWORD WINAPI ID3DXBufferImpl_GetBufferSize(LPD3DXBUFFER iface); + +/* --------- */ +/* ID3DXFont */ +/* --------- */ + +/***************************************************************************** + * Predeclare the interface implementation structures + */ +extern ICOM_VTABLE(ID3DXFont) D3DXFont_Vtbl; + +/***************************************************************************** + * ID3DXFontImpl implementation structure + */ +struct ID3DXFontImpl +{ + /* IUnknown fields */ + ICOM_VFIELD(ID3DXFont); + DWORD ref; + + /* ID3DXFont fields */ +}; + +/* IUnknown: */ +extern HRESULT WINAPI ID3DXFontImpl_QueryInterface(LPD3DXFONT iface, REFIID refiid, LPVOID *obj); +extern ULONG WINAPI ID3DXFontImpl_AddRef(LPD3DXFONT iface); +extern ULONG WINAPI ID3DXFontImpl_Release(LPD3DXFONT iface); + +/* ID3DXFont: */ +extern INT WINAPI ID3DXFontImpl_DrawTextA(LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color); + +#endif /*__WINE_D3DX8CORE_PRIVATE_H */ diff --git a/dlls/d3dx8/d3dxbuffer.c b/dlls/d3dx8/d3dxbuffer.c new file mode 100644 index 00000000000..ad2e50a7c7a --- /dev/null +++ b/dlls/d3dx8/d3dxbuffer.c @@ -0,0 +1,86 @@ +/* + * ID3DXBuffer implementation + * + * Copyright 2002 Raphael Junqueira + * + * 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 "wine/port.h" + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "wingdi.h" +#include "wine/debug.h" + +#include "d3d8.h" +#include "d3dx8core_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3d); + +/* ID3DXBuffer IUnknown parts follow: */ +HRESULT WINAPI ID3DXBufferImpl_QueryInterface(LPD3DXBUFFER iface, REFIID riid, LPVOID* ppobj) { + ICOM_THIS(ID3DXBufferImpl,iface); + + if (IsEqualGUID(riid, &IID_IUnknown) + || IsEqualGUID(riid, &IID_ID3DXBuffer)) { + ID3DXBufferImpl_AddRef(iface); + *ppobj = This; + return D3D_OK; + } + + WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj); + return E_NOINTERFACE; +} + +ULONG WINAPI ID3DXBufferImpl_AddRef(LPD3DXBUFFER iface) { + ICOM_THIS(ID3DXBufferImpl,iface); + TRACE("(%p) : AddRef from %ld\n", This, This->ref); + return ++(This->ref); +} + +ULONG WINAPI ID3DXBufferImpl_Release(LPD3DXBUFFER iface) { + ICOM_THIS(ID3DXBufferImpl,iface); + ULONG ref = --This->ref; + TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref); + if (ref == 0) { + if (NULL != This->buffer) HeapFree(GetProcessHeap(), 0, This->buffer); + HeapFree(GetProcessHeap(), 0, This); + } + return ref; +} + +/* ID3DXBuffer Interface follow: */ +LPVOID WINAPI ID3DXBufferImpl_GetBufferPointer(LPD3DXBUFFER iface) { + ICOM_THIS(ID3DXBufferImpl,iface); + return This->buffer; +} + +DWORD WINAPI ID3DXBufferImpl_GetBufferSize(LPD3DXBUFFER iface) { + ICOM_THIS(ID3DXBufferImpl,iface); + return This->bufferSize; +} + +ICOM_VTABLE(ID3DXBuffer) D3DXBuffer_Vtbl = +{ + ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE + ID3DXBufferImpl_QueryInterface, + ID3DXBufferImpl_AddRef, + ID3DXBufferImpl_Release, + ID3DXBufferImpl_GetBufferPointer, + ID3DXBufferImpl_GetBufferSize +}; diff --git a/dlls/make_dlls b/dlls/make_dlls index fddb3cdda4a..a660a1d3908 100755 --- a/dlls/make_dlls +++ b/dlls/make_dlls @@ -36,6 +36,7 @@ my %special_dlls = "glu32" => "GLU32FILES", "opengl32" => "OPENGLFILES", "d3d8" => "OPENGLFILES", + "d3dx8" => "OPENGLFILES", "x11drv" => "XFILES" ); diff --git a/include/Makefile.in b/include/Makefile.in index 0c3e2410882..afe612c1ee5 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -27,6 +27,7 @@ WINDOWS_INCLUDES = \ d3dhal.h \ d3dtypes.h \ d3dvec.inl \ + d3dx8core.h \ dde.h \ ddeml.h \ ddraw.h \ diff --git a/include/d3d8.h b/include/d3d8.h index 80c970ca9e7..82daa4fbe66 100644 --- a/include/d3d8.h +++ b/include/d3d8.h @@ -78,25 +78,25 @@ typedef struct IDirect3DVertexBuffer8 IDirect3DVertexBuffer8, *LPDIRECT3DVERTEX DEFINE_GUID(IID_IDirect3DVolume8, 0XBD7349F5,0X14F1,0X42E4,0X9C,0X79,0X97,0X23,0X80,0XDB,0X40,0XC0); typedef struct IDirect3DVolume8 IDirect3DVolume8, *LPDIRECT3DVOLUME8, *PDIRECT3DVOLUME8; -DEFINE_GUID(IID_IDIRECT3DSWAPCHAIN8, 0X928C088B,0X76B9,0X4C6B,0XA5,0X36,0XA5,0X90,0X85,0X38,0X76,0XCD); +DEFINE_GUID(IID_IDirect3DSwapChain8, 0X928C088B,0X76B9,0X4C6B,0XA5,0X36,0XA5,0X90,0X85,0X38,0X76,0XCD); typedef struct IDirect3DSwapChain8 IDirect3DSwapChain8, *LPDIRECT3DSWAPCHAIN8, *PDIRECT3DSWAPCHAIN8; DEFINE_GUID(IID_IDirect3DSurface8, 0XB96EEBCA,0XB326,0X4EA5,0X88,0X2F,0X2F,0XF5,0XBA,0XE0,0X21,0XDD); typedef struct IDirect3DSurface8 IDirect3DSurface8, *LPDIRECT3DSURFACE8, *PDIRECT3DSURFACE8; -DEFINE_GUID(IID_IDIRECT3DINDEXBUFFER8, 0X0E689C9A,0X053D,0X44A0,0X9D,0X92,0XDB,0X0E,0X3D,0X75,0X0F,0X86); +DEFINE_GUID(IID_IDirect3DIndexBuffer8, 0X0E689C9A,0X053D,0X44A0,0X9D,0X92,0XDB,0X0E,0X3D,0X75,0X0F,0X86); typedef struct IDirect3DIndexBuffer8 IDirect3DIndexBuffer8, *LPDIRECT3DINDEXBUFFER8, *PDIRECT3DINDEXBUFFER8; -DEFINE_GUID(IID_IDIRECT3DBASETEXTURE8, 0XB4211CFA,0X51B9,0X4A9F,0XAB,0X78,0XDB,0X99,0XB2,0XBB,0X67,0X8E); +DEFINE_GUID(IID_IDirect3DBaseTexture8, 0XB4211CFA,0X51B9,0X4A9F,0XAB,0X78,0XDB,0X99,0XB2,0XBB,0X67,0X8E); typedef struct IDirect3DBaseTexture8 IDirect3DBaseTexture8, *LPDIRECT3DBASETEXTURE8, *PDIRECT3DBASETEXTURE8; -DEFINE_GUID(IID_IDIRECT3DTEXTURE8, 0XE4CDD575,0X2866,0X4F01,0XB1,0X2E,0X7E,0XEC,0XE1,0XEC,0X93,0X58); +DEFINE_GUID(IID_IDirect3DTexture8, 0XE4CDD575,0X2866,0X4F01,0XB1,0X2E,0X7E,0XEC,0XE1,0XEC,0X93,0X58); typedef struct IDirect3DTexture8 IDirect3DTexture8, *LPDIRECT3DTEXTURE8, *PDIRECT3DTEXTURE8; -DEFINE_GUID(IID_IDIRECT3DCUBETEXTURE8, 0X3EE5B968,0X2ACA,0X4C34,0X8B,0XB5,0X7E,0X0C,0X3D,0X19,0XB7,0X50); +DEFINE_GUID(IID_IDirect3DCubeTexture8, 0X3EE5B968,0X2ACA,0X4C34,0X8B,0XB5,0X7E,0X0C,0X3D,0X19,0XB7,0X50); typedef struct IDirect3DCubeTexture8 IDirect3DCubeTexture8, *LPDIRECT3DCUBETEXTURE8, *PDIRECT3DCUBETEXTURE8; -DEFINE_GUID(IID_IDIRECT3DVOLUMETEXTURE8,0X4B8AAAFA,0X140F,0X42BA,0X91,0X31,0X59,0X7E,0XAF,0XAA,0X2E,0XAD); +DEFINE_GUID(IID_IDirect3DVolumeTexture8,0X4B8AAAFA,0X140F,0X42BA,0X91,0X31,0X59,0X7E,0XAF,0XAA,0X2E,0XAD); typedef struct IDirect3DVolumeTexture8 IDirect3DVolumeTexture8, *LPDIRECT3DVOLUMETEXTURE8, *PDIRECT3DVOLUMETEXTURE8; /***************************************************************************** @@ -354,77 +354,6 @@ ICOM_DEFINE(IDirect3DDevice8,IUnknown) #define IDirect3DDevice8_DeletePatch(p,a) ICOM_CALL1(DeletePatch,p,a) /***************************************************************************** - * IDirect3DResource8 interface - */ -#define ICOM_INTERFACE IDirect3DResource8 -#define IDirect3DResource8_METHODS \ - /*** IDirect3DResource8 methods ***/ \ - ICOM_METHOD1(HRESULT, GetDevice, IDirect3DDevice8**, ppDevice) \ - ICOM_METHOD4(HRESULT, SetPrivateData, REFGUID, refguid, CONST void*, pData, DWORD, SizeOfData, DWORD, Flags) \ - ICOM_METHOD3(HRESULT, GetPrivateData, REFGUID, refguid, void*, pData, DWORD*, pSizeOfData) \ - ICOM_METHOD1(HRESULT, FreePrivateData, REFGUID, refguid) \ - ICOM_METHOD1(DWORD, SetPriority, DWORD, PriorityNew) \ - ICOM_METHOD (DWORD, GetPriority) \ - ICOM_METHOD (void, PreLoad) \ - ICOM_METHOD (D3DRESOURCETYPE, GetType) - - /*** IDirect3DResource8 methods ***/ -#define IDirect3DResource8_IMETHODS \ - IUnknown_IMETHODS \ - IDirect3DResource8_METHODS -ICOM_DEFINE(IDirect3DResource8,IUnknown) -#undef ICOM_INTERFACE - -/*** IUnknown methods ***/ -#define IDirect3DResource8_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) -#define IDirect3DResource8_AddRef(p) ICOM_CALL (AddRef,p) -#define IDirect3DResource8_Release(p) ICOM_CALL (Release,p) -/*** IDirect3DResource8 methods ***/ -#define IDirect3DResource8_GetDevice(p,a) ICOM_CALL1(GetDevice,p,a) -#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) ICOM_CALL4(SetPrivateData,p,a,b,c,d) -#define IDirect3DResource8_GetPrivateData(p,a,b,c) ICOM_CALL3(GetPrivateData,p,a,b,c) -#define IDirect3DResource8_FreePrivateData(p,a) ICOM_CALL1(FreePrivateData,p,a) -#define IDirect3DResource8_SetPriority(p,a) ICOM_CALL1(SetPriority,p,a) -#define IDirect3DResource8_GetPriority(p) ICOM_CALL (GetPriority,p) -#define IDirect3DResource8_PreLoad(p) ICOM_CALL (PreLoad,p) -#define IDirect3DResource8_GetType(p) ICOM_CALL (GetType,p) - -/***************************************************************************** - * IDirect3DVertexBuffer8 interface - */ -#define ICOM_INTERFACE IDirect3DVertexBuffer8 -#define IDirect3DVertexBuffer8_METHODS \ - /*** IDirect3DVertexBuffer8 methods ***/ \ - ICOM_METHOD4(HRESULT,Lock, UINT, OffsetToLock, UINT, SizeToLock, BYTE**, ppbData, DWORD, Flags) \ - ICOM_METHOD (HRESULT,Unlock) \ - ICOM_METHOD1(HRESULT,GetDesc, D3DVERTEXBUFFER_DESC *, pDesc) - - /*** IDirect3DVertexBuffer8 methods ***/ -#define IDirect3DVertexBuffer8_IMETHODS \ - IUnknown_IMETHODS \ - IDirect3DResource8_METHODS \ - IDirect3DVertexBuffer8_METHODS -ICOM_DEFINE(IDirect3DVertexBuffer8,IDirect3DResource8) -#undef ICOM_INTERFACE - -/*** IUnknown methods ***/ -#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) -#define IDirect3DVertexBuffer8_AddRef(p) ICOM_CALL (AddRef,p) -#define IDirect3DVertexBuffer8_Release(p) ICOM_CALL (Release,p) -/*** IDirect3DVertexBuffer8 methods ***/ -#define IDirect3DVertexBuffer8_GetDevice(p,a) ICOM_CALL1(GetDevice,p,a) -#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) ICOM_CALL4(SetPrivateData,p,a,b,c,d) -#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) ICOM_CALL3(GetPrivateData,p,a,b,c) -#define IDirect3DVertexBuffer8_FreePrivateData(p,a) ICOM_CALL1(FreePrivateData,p,a) -#define IDirect3DVertexBuffer8_SetPriority(p,a) ICOM_CALL1(SetPriority,p,a) -#define IDirect3DVertexBuffer8_GetPriority(p) ICOM_CALL (GetPriority,p) -#define IDirect3DVertexBuffer8_PreLoad(p) ICOM_CALL (PreLoad,p) -#define IDirect3DVertexBuffer8_GetType(p) ICOM_CALL (GetType,p) -#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) ICOM_CALL4(Lock,p,a,b,c,d) -#define IDirect3DVertexBuffer8_Unlock(p) ICOM_CALL (Unlock,p) -#define IDirect3DVertexBuffer8_GetDesc(p,a) ICOM_CALL1(GetDesc,p,a) - -/***************************************************************************** * IDirect3DVolume8 interface */ #define ICOM_INTERFACE IDirect3DVolume8 @@ -521,6 +450,78 @@ ICOM_DEFINE(IDirect3DSurface8,IUnknown) #define IDirect3DSurface8_UnlockRect(p) ICOM_CALL (UnlockRect,p) /***************************************************************************** + * IDirect3DResource8 interface + */ +#define ICOM_INTERFACE IDirect3DResource8 +#define IDirect3DResource8_METHODS \ + /*** IDirect3DResource8 methods ***/ \ + ICOM_METHOD1(HRESULT, GetDevice, IDirect3DDevice8**, ppDevice) \ + ICOM_METHOD4(HRESULT, SetPrivateData, REFGUID, refguid, CONST void*, pData, DWORD, SizeOfData, DWORD, Flags) \ + ICOM_METHOD3(HRESULT, GetPrivateData, REFGUID, refguid, void*, pData, DWORD*, pSizeOfData) \ + ICOM_METHOD1(HRESULT, FreePrivateData, REFGUID, refguid) \ + ICOM_METHOD1(DWORD, SetPriority, DWORD, PriorityNew) \ + ICOM_METHOD (DWORD, GetPriority) \ + ICOM_METHOD (void, PreLoad) \ + ICOM_METHOD (D3DRESOURCETYPE, GetType) + + /*** IDirect3DResource8 methods ***/ +#define IDirect3DResource8_IMETHODS \ + IUnknown_IMETHODS \ + IDirect3DResource8_METHODS +ICOM_DEFINE(IDirect3DResource8,IUnknown) +#undef ICOM_INTERFACE + +/*** IUnknown methods ***/ +#define IDirect3DResource8_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) +#define IDirect3DResource8_AddRef(p) ICOM_CALL (AddRef,p) +#define IDirect3DResource8_Release(p) ICOM_CALL (Release,p) +/*** IDirect3DResource8 methods ***/ +#define IDirect3DResource8_GetDevice(p,a) ICOM_CALL1(GetDevice,p,a) +#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) ICOM_CALL4(SetPrivateData,p,a,b,c,d) +#define IDirect3DResource8_GetPrivateData(p,a,b,c) ICOM_CALL3(GetPrivateData,p,a,b,c) +#define IDirect3DResource8_FreePrivateData(p,a) ICOM_CALL1(FreePrivateData,p,a) +#define IDirect3DResource8_SetPriority(p,a) ICOM_CALL1(SetPriority,p,a) +#define IDirect3DResource8_GetPriority(p) ICOM_CALL (GetPriority,p) +#define IDirect3DResource8_PreLoad(p) ICOM_CALL (PreLoad,p) +#define IDirect3DResource8_GetType(p) ICOM_CALL (GetType,p) + +/***************************************************************************** + * IDirect3DVertexBuffer8 interface + */ +#define ICOM_INTERFACE IDirect3DVertexBuffer8 +#define IDirect3DVertexBuffer8_METHODS \ + /*** IDirect3DVertexBuffer8 methods ***/ \ + ICOM_METHOD4(HRESULT,Lock, UINT, OffsetToLock, UINT, SizeToLock, BYTE**, ppbData, DWORD, Flags) \ + ICOM_METHOD (HRESULT,Unlock) \ + ICOM_METHOD1(HRESULT,GetDesc, D3DVERTEXBUFFER_DESC *, pDesc) + + /*** IDirect3DVertexBuffer8 methods ***/ +#define IDirect3DVertexBuffer8_IMETHODS \ + IUnknown_IMETHODS \ + IDirect3DResource8_METHODS \ + IDirect3DVertexBuffer8_METHODS +ICOM_DEFINE(IDirect3DVertexBuffer8,IDirect3DResource8) +#undef ICOM_INTERFACE + +/*** IUnknown methods ***/ +#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) +#define IDirect3DVertexBuffer8_AddRef(p) ICOM_CALL (AddRef,p) +#define IDirect3DVertexBuffer8_Release(p) ICOM_CALL (Release,p) +/*** IDirect3DVertexBuffer8 methods: IDirect3DResource8 ***/ +#define IDirect3DVertexBuffer8_GetDevice(p,a) ICOM_CALL1(GetDevice,p,a) +#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) ICOM_CALL4(SetPrivateData,p,a,b,c,d) +#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) ICOM_CALL3(GetPrivateData,p,a,b,c) +#define IDirect3DVertexBuffer8_FreePrivateData(p,a) ICOM_CALL1(FreePrivateData,p,a) +#define IDirect3DVertexBuffer8_SetPriority(p,a) ICOM_CALL1(SetPriority,p,a) +#define IDirect3DVertexBuffer8_GetPriority(p) ICOM_CALL (GetPriority,p) +#define IDirect3DVertexBuffer8_PreLoad(p) ICOM_CALL (PreLoad,p) +#define IDirect3DVertexBuffer8_GetType(p) ICOM_CALL (GetType,p) +/*** IDirect3DVertexBuffer8 methods ***/ +#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) ICOM_CALL4(Lock,p,a,b,c,d) +#define IDirect3DVertexBuffer8_Unlock(p) ICOM_CALL (Unlock,p) +#define IDirect3DVertexBuffer8_GetDesc(p,a) ICOM_CALL1(GetDesc,p,a) + +/***************************************************************************** * IDirect3DIndexBuffer8 interface */ #define ICOM_INTERFACE IDirect3DIndexBuffer8 @@ -542,7 +543,7 @@ ICOM_DEFINE(IDirect3DIndexBuffer8,IDirect3DResource8) #define IDirect3DIndexBuffer8_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) #define IDirect3DIndexBuffer8_AddRef(p) ICOM_CALL (AddRef,p) #define IDirect3DIndexBuffer8_Release(p) ICOM_CALL (Release,p) -/*** IDirect3DIndexBuffer8 methods ***/ +/*** IDirect3DIndexBuffer8 methods: IDirect3DResource8 ***/ #define IDirect3DIndexBuffer8_GetDevice(p,a) ICOM_CALL1(GetDevice,p,a) #define IDirect3DIndexBuffer8_SetPrivateData(p,a,b,c,d) ICOM_CALL4(SetPrivateData,p,a,b,c,d) #define IDirect3DIndexBuffer8_GetPrivateData(p,a,b,c) ICOM_CALL3(GetPrivateData,p,a,b,c) @@ -551,6 +552,7 @@ ICOM_DEFINE(IDirect3DIndexBuffer8,IDirect3DResource8) #define IDirect3DIndexBuffer8_GetPriority(p) ICOM_CALL (GetPriority,p) #define IDirect3DIndexBuffer8_PreLoad(p) ICOM_CALL (PreLoad,p) #define IDirect3DIndexBuffer8_GetType(p) ICOM_CALL (GetType,p) +/*** IDirect3DIndexBuffer8 methods ***/ #define IDirect3DIndexBuffer8_Lock(p,a,b,c,d) ICOM_CALL4(Lock,p,a,b,c,d) #define IDirect3DIndexBuffer8_Unlock(p) ICOM_CALL (Unlock,p) #define IDirect3DIndexBuffer8_GetDesc(p,a) ICOM_CALL1(GetDesc,p,a) @@ -577,7 +579,7 @@ ICOM_DEFINE(IDirect3DBaseTexture8,IDirect3DResource8) #define IDirect3DBaseTexture8_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) #define IDirect3DBaseTexture8_AddRef(p) ICOM_CALL (AddRef,p) #define IDirect3DBaseTexture8_Release(p) ICOM_CALL (Release,p) -/*** IDirect3DBaseTexture8 methods ***/ +/*** IDirect3DBaseTexture8 methods: IDirect3DResource8 ***/ #define IDirect3DBaseTexture8_GetDevice(p,a) ICOM_CALL1(GetDevice,p,a) #define IDirect3DBaseTexture8_SetPrivateData(p,a,b,c,d) ICOM_CALL4(SetPrivateData,p,a,b,c,d) #define IDirect3DBaseTexture8_GetPrivateData(p,a,b,c) ICOM_CALL3(GetPrivateData,p,a,b,c) @@ -586,6 +588,7 @@ ICOM_DEFINE(IDirect3DBaseTexture8,IDirect3DResource8) #define IDirect3DBaseTexture8_GetPriority(p) ICOM_CALL (GetPriority,p) #define IDirect3DBaseTexture8_PreLoad(p) ICOM_CALL (PreLoad,p) #define IDirect3DBaseTexture8_GetType(p) ICOM_CALL (GetType,p) +/*** IDirect3DBaseTexture8 methods ***/ #define IDirect3DBaseTexture8_SetLOD(p,a) ICOM_CALL1(SetLOD,p,a) #define IDirect3DBaseTexture8_GetLOD(p) ICOM_CALL (GetLOD,p) #define IDirect3DBaseTexture8_GetLevelCount(p) ICOM_CALL (GetLevelCount,p) @@ -615,7 +618,7 @@ ICOM_DEFINE(IDirect3DCubeTexture8,IDirect3DBaseTexture8) #define IDirect3DCubeTexture8_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) #define IDirect3DCubeTexture8_AddRef(p) ICOM_CALL (AddRef,p) #define IDirect3DCubeTexture8_Release(p) ICOM_CALL (Release,p) -/*** IDirect3DCubeTexture8 methods: Resource8 ***/ +/*** IDirect3DCubeTexture8 methods: IDirect3DResource8 ***/ #define IDirect3DCubeTexture8_GetDevice(p,a) ICOM_CALL1(GetDevice,p,a) #define IDirect3DCubeTexture8_SetPrivateData(p,a,b,c,d) ICOM_CALL4(SetPrivateData,p,a,b,c,d) #define IDirect3DCubeTexture8_GetPrivateData(p,a,b,c) ICOM_CALL3(GetPrivateData,p,a,b,c) @@ -624,7 +627,7 @@ ICOM_DEFINE(IDirect3DCubeTexture8,IDirect3DBaseTexture8) #define IDirect3DCubeTexture8_GetPriority(p) ICOM_CALL (GetPriority,p) #define IDirect3DCubeTexture8_PreLoad(p) ICOM_CALL (PreLoad,p) #define IDirect3DCubeTexture8_GetType(p) ICOM_CALL (GetType,p) -/*** IDirect3DCubeTexture8 methods: BaseTexture8 ***/ +/*** IDirect3DCubeTexture8 methods: IDirect3DBaseTexture8 ***/ #define IDirect3DCubeTexture8_SetLOD(p,a) ICOM_CALL1(SetLOD,p,a) #define IDirect3DCubeTexture8_GetLOD(p) ICOM_CALL (GetLOD,p) #define IDirect3DCubeTexture8_GetLevelCount(p) ICOM_CALL (GetLevelCount,p) @@ -660,7 +663,7 @@ ICOM_DEFINE(IDirect3DTexture8,IDirect3DBaseTexture8) #define IDirect3DTexture8_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) #define IDirect3DTexture8_AddRef(p) ICOM_CALL (AddRef,p) #define IDirect3DTexture8_Release(p) ICOM_CALL (Release,p) -/*** IDirect3DTexture8 methods: Resource8 ***/ +/*** IDirect3DTexture8 methods: IDirect3DResource8 ***/ #define IDirect3DTexture8_GetDevice(p,a) ICOM_CALL1(GetDevice,p,a) #define IDirect3DTexture8_SetPrivateData(p,a,b,c,d) ICOM_CALL4(SetPrivateData,p,a,b,c,d) #define IDirect3DTexture8_GetPrivateData(p,a,b,c) ICOM_CALL3(GetPrivateData,p,a,b,c) @@ -669,7 +672,7 @@ ICOM_DEFINE(IDirect3DTexture8,IDirect3DBaseTexture8) #define IDirect3DTexture8_GetPriority(p) ICOM_CALL (GetPriority,p) #define IDirect3DTexture8_PreLoad(p) ICOM_CALL (PreLoad,p) #define IDirect3DTexture8_GetType(p) ICOM_CALL (GetType,p) -/*** IDirect3DTexture8 methods: BaseTexture8 ***/ +/*** IDirect3DTexture8 methods: IDirect3DBaseTexture8 ***/ #define IDirect3DTexture8_SetLOD(p,a) ICOM_CALL1(SetLOD,p,a) #define IDirect3DTexture8_GetLOD(p) ICOM_CALL (GetLOD,p) #define IDirect3DTexture8_GetLevelCount(p) ICOM_CALL (GetLevelCount,p) @@ -705,7 +708,7 @@ ICOM_DEFINE(IDirect3DVolumeTexture8,IDirect3DBaseTexture8) #define IDirect3DVolumeTexture8_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) #define IDirect3DVolumeTexture8_AddRef(p) ICOM_CALL (AddRef,p) #define IDirect3DVolumeTexture8_Release(p) ICOM_CALL (Release,p) -/*** IDirect3DVolumeTexture8 methods: Resource8 ***/ +/*** IDirect3DVolumeTexture8 methods: IDirect3DResource8 ***/ #define IDirect3DVolumeTexture8_GetDevice(p,a) ICOM_CALL1(GetDevice,p,a) #define IDirect3DVolumeTexture8_SetPrivateData(p,a,b,c,d) ICOM_CALL4(SetPrivateData,p,a,b,c,d) #define IDirect3DVolumeTexture8_GetPrivateData(p,a,b,c) ICOM_CALL3(GetPrivateData,p,a,b,c) @@ -714,7 +717,7 @@ ICOM_DEFINE(IDirect3DVolumeTexture8,IDirect3DBaseTexture8) #define IDirect3DVolumeTexture8_GetPriority(p) ICOM_CALL (GetPriority,p) #define IDirect3DVolumeTexture8_PreLoad(p) ICOM_CALL (PreLoad,p) #define IDirect3DVolumeTexture8_GetType(p) ICOM_CALL (GetType,p) -/*** IDirect3DVolumeTexture8 methods: BaseTexture8 ***/ +/*** IDirect3DVolumeTexture8 methods: IDirect3DBaseTexture8 ***/ #define IDirect3DVolumeTexture8_SetLOD(p,a) ICOM_CALL1(SetLOD,p,a) #define IDirect3DVolumeTexture8_GetLOD(p) ICOM_CALL (GetLOD,p) #define IDirect3DVolumeTexture8_GetLevelCount(p) ICOM_CALL (GetLevelCount,p) diff --git a/include/d3d8types.h b/include/d3d8types.h index 7284463a783..70002e81877 100644 --- a/include/d3d8types.h +++ b/include/d3d8types.h @@ -151,6 +151,83 @@ ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) + +/** VertexShader Declaration */ +typedef enum _D3DVSD_TOKENTYPE { + D3DVSD_TOKEN_NOP, + D3DVSD_TOKEN_STREAM, + D3DVSD_TOKEN_STREAMDATA, + D3DVSD_TOKEN_TESSELLATOR, + D3DVSD_TOKEN_CONSTMEM, + D3DVSD_TOKEN_EXT, + D3DVSD_TOKEN_END, + D3DVSD_FORCE_DWORD = 0x7FFFFFFF +} D3DVSD_TOKENTYPE; + +/* Address of the vertex register. 0 - 16 */ +typedef enum _D3DVSDE_REGISTER { + D3DVSDE_POSITION = 0, + D3DVSDE_BLENDWEIGHT = 1, + D3DVSDE_BLENDINDICES = 2, + D3DVSDE_NORMAL = 3, + D3DVSDE_PSIZE = 4, + D3DVSDE_DIFFUSE = 5, + D3DVSDE_SPECULAR = 6, + D3DVSDE_TEXCOORD0 = 7, + D3DVSDE_TEXCOORD1 = 8, + D3DVSDE_TEXCOORD2 = 9, + D3DVSDE_TEXCOORD3 = 10, + D3DVSDE_TEXCOORD4 = 11, + D3DVSDE_TEXCOORD5 = 12, + D3DVSDE_TEXCOORD6 = 13, + D3DVSDE_TEXCOORD7 = 14, + D3DVSDE_POSITION2 = 15, + D3DVSDE_NORMAL2 = 16 +} D3DVSDE_REGISTER; + +typedef enum _D3DVSDT_TYPE { + D3DVSDT_FLOAT1 = 0x00, + D3DVSDT_FLOAT2 = 0x01, + D3DVSDT_FLOAT3 = 0x02, + D3DVSDT_FLOAT4 = 0x03, + D3DVSDT_D3DCOLOR = 0x04, + D3DVSDT_UBYTE4 = 0x05, + D3DVSDT_SHORT2 = 0x06, + D3DVSDT_SHORT4 = 0x07 +} D3DVSDT_TYPE; + +#define D3DVSD_DATATYPESHIFT 16 +#define D3DVSD_CONSTCOUNTSHIFT 25 +#define D3DVSD_TOKENTYPESHIFT 26 + +#define D3DVSD_MAKETOKENTYPE(TokenType) \ + ((TokenType << D3DVSD_TOKENTYPESHIFT) & D3DVSD_TOKENTYPEMASK) + +#define D3DVSD_CONST(ConstantAddress, Count) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_CONSTMEM) | ((Count) << D3DVSD_CONSTCOUNTSHIFT) | (ConstantAddress)) + +#define D3DVSD_END() 0xFFFFFFFF + +#define D3DVSD_NOP() 0x00000000 + +#define D3DVSD_REG(VertexRegister, Type) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) | ((Type) << D3DVSD_DATATYPESHIFT) | (VertexRegister)) + +#define D3DVSD_SKIP(Count) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) | 0x10000000 | ((Count) << D3DVSD_SKIPCOUNTSHIFT)) + +#define D3DVSD_STREAM(StreamNumber) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAM) | (StreamNumber)) + +#define D3DVSD_STREAM_TESS() \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAM) | (D3DVSD_STREAMTESSMASK)) + +#define D3DVSD_TESSNORMAL(VertexRegisterIn, VertexRegisterOut) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) | ((VertexRegisterIn) << D3DVSD_VERTEXREGINSHIFT) | ((0x02) << D3DVSD_DATATYPESHIFT) | (VertexRegisterOut)) + +#define D3DVSD_TESSUV(VertexRegister) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) | 0x10000000 | ((0x01) << D3DVSD_DATATYPESHIFT) | (_VertexRegister)) + /***************************************************************************** * Direct 3D v8 enumerated types */ diff --git a/include/d3dx8core.h b/include/d3dx8core.h new file mode 100644 index 00000000000..f54b9615da0 --- /dev/null +++ b/include/d3dx8core.h @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2002 Raphael Junqueira + * + * 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 + */ + +#ifndef __WINE_D3DX8CORE_H +#define __WINE_D3DX8CORE_H + +#include "objbase.h" + +#include "d3d8.h" +#include "d3d8types.h" +#include "d3d8caps.h" + +/***************************************************************************** + * #defines and error codes + */ +#define D3DXASM_DEBUG 1 +#define D3DXASM_SKIPVALIDATION 2 + +#define _FACD3D 0x876 +#define MAKE_D3DXHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code ) + +/* + * Direct3D Errors + */ +#define D3DXERR_CANNOTATTRSORT MAKE_D3DXHRESULT(2158) +#define D3DXERR_CANNOTMODIFYINDEXBUFFER MAKE_D3DXHRESULT(2159) +#define D3DXERR_INVALIDMESH MAKE_D3DXHRESULT(2160) +#define D3DXERR_SKINNINGNOTSUPPORTED MAKE_D3DXHRESULT(2161) +#define D3DXERR_TOOMANYINFLUENCES MAKE_D3DXHRESULT(2162) +#define D3DXERR_INVALIDDATA MAKE_D3DXHRESULT(2163) + +/***************************************************************************** + * Predeclare the interfaces + */ +DEFINE_GUID(IID_ID3DXBuffer, 0x1,0x1,0x4,0xB0,0xCF,0x98,0xFE,0xFD,0xFF,0x95,0x12);/* FIXME */ +typedef struct ID3DXBuffer ID3DXBuffer, *LPD3DXBUFFER; +DEFINE_GUID(IID_ID3DXFont, 0x1,0x1,0x4,0xB0,0xCF,0x98,0xFE,0xFD,0xFF,0x95,0x13);/* FIXME */ +typedef struct ID3DXFont ID3DXFont, *LPD3DXFONT; + +/***************************************************************************** + * ID3DXBuffer interface + */ +#undef ICOM_INTERFACE +#define ICOM_INTERFACE ID3DXBuffer +#define ID3DXBuffer_METHODS \ + /*** ID3DXBuffer methods ***/ \ + ICOM_METHOD (LPVOID, GetBufferPointer) \ + ICOM_METHOD (DWORD, GetBufferSize) + + /*** ID3DXBuffer methods ***/ +#define ID3DXBuffer_IMETHODS \ + IUnknown_IMETHODS \ + ID3DXBuffer_METHODS +ICOM_DEFINE(ID3DXBuffer,IUnknown) +#undef ICOM_INTERFACE + +/*** IUnknown methods ***/ +#define ID3DXBuffer_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) +#define ID3DXBuffer_AddRef(p) ICOM_CALL (AddRef,p) +#define ID3DXBuffer_Release(p) ICOM_CALL (Release,p) +/*** ID3DXBuffer methods ***/ +#define ID3DXBuffer_GetBufferPointer(p) ICOM_CALL (GetBufferPointer,p) +#define ID3DXBuffer_GetBufferSize(p) ICOM_CALL (GetBufferSize,p) + +/***************************************************************************** + * ID3DXFont interface + */ +#undef ICOM_INTERFACE +#define ICOM_INTERFACE ID3DXFont +#define ID3DXFont_METHODS \ + /*** ID3DXFont methods ***/ \ + ICOM_METHOD (HRESULT, Begin) \ + ICOM_METHOD (HRESULT, DrawTextA) \ + ICOM_METHOD (HRESULT, End) + + /*** ID3DXFont methods ***/ +#define ID3DXFont_IMETHODS \ + IUnknown_IMETHODS \ + ID3DXFont_METHODS +ICOM_DEFINE(ID3DXFont,IUnknown) +#undef ICOM_INTERFACE + +/*** IUnknown methods ***/ +#define ID3DXFont_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) +#define ID3DXFont_AddRef(p) ICOM_CALL (AddRef,p) +#define ID3DXFont_Release(p) ICOM_CALL (Release,p) +/*** ID3DXFont methods ***/ +#define ID3DXFont_Begin(p) ICOM_CALL (Begin,p) +#define ID3DXFont_DrawTextA(p,a,b,c,d,e)ICOM_CALL5(DrawText,p,a,b,c,d,e) +#define ID3DXFont_End(p) ICOM_CALL (End,p) + +/************************************************************************************* + * Define entrypoints + */ +HRESULT D3DXCreateBuffer(DWORD NumBytes, LPD3DXBUFFER* ppBuffer); +HRESULT D3DXCreateFont(LPDIRECT3DDEVICE8 pDevice, HFONT hFont, LPD3DXFONT* ppFont); +UINT D3DXGetFVFVertexSize(DWORD FVF); +HRESULT D3DXAssembleShader(LPCVOID pSrcData, UINT SrcDataLen, DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); +HRESULT D3DXAssembleShaderFromFileA(LPSTR pSrcFile, DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); +HRESULT D3DXAssembleShaderFromFileW(LPSTR pSrcFile, DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +#endif /* __WINE_D3DX8CORE_H */ -- 2.11.4.GIT