From b3523a447c6b094897f175475bbf53042c315388 Mon Sep 17 00:00:00 2001 From: Owen Rudge Date: Mon, 17 May 2010 10:50:29 -0500 Subject: [PATCH] d3dx9: Implement D3DXCreateEffectCompilerFromFile/Resource. --- dlls/d3dx9_36/d3dx9_36.spec | 8 +-- dlls/d3dx9_36/effect.c | 97 +++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 4 deletions(-) diff --git a/dlls/d3dx9_36/d3dx9_36.spec b/dlls/d3dx9_36/d3dx9_36.spec index d2437b89000..e6ad5593d15 100644 --- a/dlls/d3dx9_36/d3dx9_36.spec +++ b/dlls/d3dx9_36/d3dx9_36.spec @@ -48,10 +48,10 @@ @ stub D3DXCreateCylinder @ stdcall D3DXCreateEffect(ptr ptr long ptr ptr long ptr ptr ptr) @ stdcall D3DXCreateEffectCompiler(ptr long ptr ptr long ptr ptr) -@ stub D3DXCreateEffectCompilerFromFileA -@ stub D3DXCreateEffectCompilerFromFileW -@ stub D3DXCreateEffectCompilerFromResourceA -@ stub D3DXCreateEffectCompilerFromResourceW +@ stdcall D3DXCreateEffectCompilerFromFileA(str ptr ptr long ptr ptr) +@ stdcall D3DXCreateEffectCompilerFromFileW(wstr ptr ptr long ptr ptr) +@ stdcall D3DXCreateEffectCompilerFromResourceA(long str ptr ptr long ptr ptr) +@ stdcall D3DXCreateEffectCompilerFromResourceW(long wstr ptr ptr long ptr ptr) @ stdcall D3DXCreateEffectEx(ptr ptr long ptr ptr ptr long ptr ptr ptr) @ stub D3DXCreateEffectFromFileA @ stub D3DXCreateEffectFromFileExA diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index 4633d887e46..fd761b41129 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -998,3 +998,100 @@ HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL* pool) return S_OK; } + +HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include, + DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors) +{ + LPVOID buffer; + HRESULT ret; + DWORD size; + + TRACE("(%s): relay\n", debugstr_w(srcfile)); + + if (!srcfile || !defines) + return D3DERR_INVALIDCALL; + + ret = map_view_of_file(srcfile, &buffer, &size); + + if (FAILED(ret)) + return D3DXERR_INVALIDDATA; + + ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors); + UnmapViewOfFile(buffer); + + return ret; +} + +HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include, + DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors) +{ + LPWSTR srcfileW; + HRESULT ret; + DWORD len; + + TRACE("(void): relay\n"); + + if (!srcfile || !defines) + return D3DERR_INVALIDCALL; + + len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0); + srcfileW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len); + + ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors); + HeapFree(GetProcessHeap(), 0, srcfileW); + + return ret; +} + +HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines, + LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors) +{ + HRSRC resinfo; + + TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource)); + + resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA); + + if (resinfo) + { + LPVOID buffer; + HRESULT ret; + DWORD size; + + ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size); + + if (FAILED(ret)) + return D3DXERR_INVALIDDATA; + + return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors); + } + + return D3DXERR_INVALIDDATA; +} + +HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines, + LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors) +{ + HRSRC resinfo; + + TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource)); + + resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA); + + if (resinfo) + { + LPVOID buffer; + HRESULT ret; + DWORD size; + + ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size); + + if (FAILED(ret)) + return D3DXERR_INVALIDDATA; + + return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors); + } + + return D3DXERR_INVALIDDATA; +}