Following your comment I understand that you will be implementing the
hard core of D3DXCompileShaderxx.
Nevertheless, I have already a simplification of the
D3DXCompileShaderFromFilexx functionsStefan Dösinger escribió. This are
being work referring to D3DXCompileShaderFromFileExW on the basement, i.e:
D3DXCompileShaderFromFileA --> D3DXCompileShaderFromFileW
D3DXCompileShaderFromFileExA --> D3DXCompileShaderFromFileExW
D3DXCompileShaderFromFileW --> D3DXCompileShaderFromFileExW
Please find the patch attached. I have tested it with Civilizqation4, which as explained calls D3DXCompileShaderFromFileA. To test 3DXCompileShaderFromFileExA I tried a temporary path of
D3DXCompileShaderFromFileA --> D3DXCompileShaderFromFileExA
All this using the work around of implementing the three calling functions
(D3DXCompileShaderFromFileA, D3DXCompileShaderFromFileW,
D3DXCompileShaderFromFileExA) in d3dx9_32 for testing and now setting the code
on d3dx9_36 obviously. The tests have been ok.
Please let me know your comments and if you think that it can be submitted to
wine-patches.
Am Donnerstag, 13. März 2008 18:26:17 schrieb Luis C. Busquets Pérez:
Proposing another thing if implementing d3dx9_36.dll is too much I
propose to implement:
1 D3DXAssembleShader
2 D3DXAssembleShaderFromFileA
3 D3DXCompileShader
4 D3DXCompileShaderFromFileA
I plan to implement those as a university project now(I already got the
general approval for it, just need to sort out the details)
5 D3DXCreateCubeTextureFromFileExA
6 D3DXCreateCubeTextureFromFileInMemory
7 D3DXCreateEffectCompilerFromFileA
8 D3DXCreateEffectFromFileA
9 D3DXCreateTextureFromFileExA
10 D3DXCreateTextureFromFileInMemory
11 D3DXCreateVolumeTextureFromFileExA
12 D3DXCreateVolumeTextureFromFileInMemory
13 D3DXGetImageInfoFromFileInMemory
14 D3DXGetPixelShaderProfile
15 D3DXGetShaderConstantTable
16 D3DXGetShaderInputSemantics
17 D3DXGetShaderVersion
18 D3DXGetVertexShaderProfile
19 D3DXLoadSurfaceFromSurface
20 D3DXSaveSurfaceToFileA
21 D3DXSaveTextureToFileA
That's a long enough list in itself I think. You shouldn't cap it off at
specifically the functions CIV4 calls, but rather look for blocks of
functionality.
diff --git a/dlls/d3dx9_36/Makefile.in b/dlls/d3dx9_36/Makefile.in
index 3b0f062..d10561c 100644
--- a/dlls/d3dx9_36/Makefile.in
+++ b/dlls/d3dx9_36/Makefile.in
@@ -7,7 +7,8 @@ IMPORTLIB = d3dx9
IMPORTS = d3d9 d3dx8 kernel32
C_SRCS = \
- d3dx9_36_main.c
+ d3dx9_36_main.c \
+ effect.c
@MAKE_DLL_RULES@
diff --git a/dlls/d3dx9_36/d3dx9_36.spec b/dlls/d3dx9_36/d3dx9_36.spec
index c859e94..d4e9d76 100644
--- a/dlls/d3dx9_36/d3dx9_36.spec
+++ b/dlls/d3dx9_36/d3dx9_36.spec
@@ -53,10 +53,10 @@
@ stub D3DXCreateEffectCompilerFromResourceA
@ stub D3DXCreateEffectCompilerFromResourceW
@ stub D3DXCreateEffectEx
-@ stub D3DXCreateEffectFromFileA
-@ stub D3DXCreateEffectFromFileExA
-@ stub D3DXCreateEffectFromFileExW
-@ stub D3DXCreateEffectFromFileW
+@ stdcall D3DXCreateEffectFromFileA(ptr ptr ptr ptr long ptr ptr ptr)
+@ stdcall D3DXCreateEffectFromFileExA(ptr ptr ptr ptr ptr long ptr ptr ptr)
+@ stdcall D3DXCreateEffectFromFileExW(ptr ptr ptr ptr ptr long ptr ptr ptr)
+@ stdcall D3DXCreateEffectFromFileW(ptr ptr ptr ptr long ptr ptr ptr)
@ stub D3DXCreateEffectFromResourceA
@ stub D3DXCreateEffectFromResourceExA
@ stub D3DXCreateEffectFromResourceExW
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c
new file mode 100644
index 0000000..2ee7769
--- /dev/null
+++ b/dlls/d3dx9_36/effect.c
@@ -0,0 +1,128 @@
+/*
+ * Direct3D X 9 effect file
+ *
+ * Copyright (C) 2008 Luis Busquets
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#include "config.h"
+#include "wine/port.h"
+#include <stdarg.h>
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "wine/debug.h"
+#include "wine/unicode.h"
+#include "d3dx9.h"
+
+typedef struct D3DXMACRO {
+ LPCSTR Name;
+ LPCSTR Definition;
+} D3DXMACRO, *LPD3DXMACRO;
+
+typedef interface ID3DXInclude *LPD3DXINCLUDE;
+typedef interface ID3DXEffectPool *LPD3DXEFFECTPOOL;
+typedef interface ID3DXEffect *LPD3DXEFFECT;
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
+
+HRESULT WINAPI D3DXCreateEffectFromFileExW(
+ LPDIRECT3DDEVICE9 pDevice,
+ LPWSTR pSrcFile,
+ CONST D3DXMACRO * pDefines,
+ LPD3DXINCLUDE pInclude,
+ LPWSTR pSkipConstants,
+ DWORD Flags,
+ LPD3DXEFFECTPOOL pPool,
+ LPD3DXEFFECT * ppEffect,
+ LPD3DXBUFFER * ppCompilationErrors
+)
+{
+ FIXME("Stub\n");
+ return E_OUTOFMEMORY;
+}
+
+HRESULT WINAPI D3DXCreateEffectFromFileW(
+ LPDIRECT3DDEVICE9 pDevice,
+ LPWSTR pSrcFileW,
+ CONST D3DXMACRO * pDefines,
+ LPD3DXINCLUDE pInclude,
+ DWORD Flags,
+ LPD3DXEFFECTPOOL pPool,
+ LPD3DXEFFECT * ppEffect,
+ LPD3DXBUFFER * ppCompilationErrors
+)
+{
+ HRESULT hr;
+ LPWSTR pSkipConstants;
+ pSkipConstants = HeapAlloc( GetProcessHeap(), 0, 1 * sizeof(WCHAR) );
+ pSkipConstants=NULL;
+ hr=D3DXCreateEffectFromFileExW(pDevice, pSrcFileW, pDefines, pInclude, pSkipConstants, Flags, pPool, ppEffect, ppCompilationErrors);
+ HeapFree( GetProcessHeap(), 0, pSkipConstants);
+ return hr;
+}
+
+HRESULT D3DXCreateEffectFromFileExA(
+ LPDIRECT3DDEVICE9 pDevice,
+ LPCSTR pSrcFile,
+ CONST D3DXMACRO * pDefines,
+ LPD3DXINCLUDE pInclude,
+ LPCSTR pSkipConstants,
+ DWORD Flags,
+ LPD3DXEFFECTPOOL pPool,
+ LPD3DXEFFECT * ppEffect,
+ LPD3DXBUFFER * ppCompilationErrors
+)
+{
+ HRESULT hr;
+ LPWSTR pSrcFileW;
+ LPWSTR pSkipConstantsW;
+ DWORD len;
+ if (!pSrcFile) return D3DXERR_INVALIDDATA;
+ len = MultiByteToWideChar( CP_ACP, 0, pSrcFile, -1, NULL, 0 );
+ pSrcFileW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
+ MultiByteToWideChar( CP_ACP, 0, pSrcFile, -1, pSrcFileW, len );
+ len = MultiByteToWideChar( CP_ACP, 0, pSkipConstants, -1, NULL, 0 );
+ pSkipConstantsW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
+ MultiByteToWideChar( CP_ACP, 0, pSrcFile, -1, pSrcFileW, len );
+ hr=D3DXCreateEffectFromFileExW(pDevice, pSrcFileW, pDefines, pInclude, pSkipConstantsW, Flags, pPool, ppEffect, ppCompilationErrors);
+ return hr;
+}
+
+HRESULT WINAPI D3DXCreateEffectFromFileA(
+ LPDIRECT3DDEVICE9 pDevice,
+ LPSTR pSrcFile,
+ CONST D3DXMACRO * pDefines,
+ LPD3DXINCLUDE pInclude,
+ DWORD Flags,
+ LPD3DXEFFECTPOOL pPool,
+ LPD3DXEFFECT * ppEffect,
+ LPD3DXBUFFER * ppCompilationErrors
+)
+{
+ HRESULT hr;
+ LPWSTR pSrcFileW = NULL;
+ DWORD len;
+ TRACE ("Reading Shader file %s \n", pSrcFile);
+ if (!pSrcFile) return D3DXERR_INVALIDDATA;
+ len = MultiByteToWideChar( CP_ACP, 0, pSrcFile, -1, NULL, 0 );
+ pSrcFileW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
+ MultiByteToWideChar( CP_ACP, 0, pSrcFile, -1, pSrcFileW, len );
+ hr=D3DXCreateEffectFromFileW(pDevice, pSrcFileW, pDefines, pInclude, Flags, pPool, ppEffect, ppCompilationErrors);
+ return hr;
+}