From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: use default include handler v3 (Matteo): move the function out of d3dx10_43_main.c, make a few tweaks.
dlls/d3dx10_43/Makefile.in | 1 + dlls/d3dx10_43/compiler.c | 62 +++++++++++++++++++++++++++++++++ dlls/d3dx10_43/d3dx10_43_main.c | 13 ------- 3 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 dlls/d3dx10_43/compiler.c
diff --git a/dlls/d3dx10_43/Makefile.in b/dlls/d3dx10_43/Makefile.in index 1108dcb0948..1fae34191ee 100644 --- a/dlls/d3dx10_43/Makefile.in +++ b/dlls/d3dx10_43/Makefile.in @@ -7,6 +7,7 @@ EXTRADLLFLAGS = -mno-cygwin -Wb,--prefer-native
C_SRCS = \ async.c \ + compiler.c \ d3dx10_43_main.c \ texture.c
diff --git a/dlls/d3dx10_43/compiler.c b/dlls/d3dx10_43/compiler.c new file mode 100644 index 00000000000..1ccb0e45a69 --- /dev/null +++ b/dlls/d3dx10_43/compiler.c @@ -0,0 +1,62 @@ +/* + * Copyright 2021 Nikolay Sivov for CodeWeavers + * + * 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 "wine/debug.h" + +#define COBJMACROS + +#include "d3d10_1.h" +#include "d3dx10.h" +#include "d3dcompiler.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); + + +HRESULT WINAPI D3DX10CreateEffectFromMemory(const void *data, SIZE_T datasize, const char *filename, + const D3D10_SHADER_MACRO *defines, ID3D10Include *include, const char *profile, + UINT shader_flags, UINT effect_flags, ID3D10Device *device, ID3D10EffectPool *effect_pool, + ID3DX10ThreadPump *pump, ID3D10Effect **effect, ID3D10Blob **errors, HRESULT *hresult) +{ + ID3D10Blob *code; + HRESULT hr; + + TRACE("data %p, datasize %lu, filename %s, defines %p, include %p, profile %s, shader_flags %#x," + "effect_flags %#x, device %p, effect_pool %p, pump %p, effect %p, errors %p, hresult %p.\n", + data, datasize, debugstr_a(filename), defines, include, debugstr_a(profile), + shader_flags, effect_flags, device, effect_pool, pump, effect, errors, hresult); + + if (pump) + FIXME("Asynchronous mode is not supported.\n"); + + if (!include) + include = D3D_COMPILE_STANDARD_FILE_INCLUDE; + + if (FAILED(hr = D3DCompile(data, datasize, filename, defines, include, "main", profile, + shader_flags, effect_flags, &code, errors))) + { + WARN("Effect compilation failed, hr %#x.\n", hr); + return hr; + } + + hr = D3D10CreateEffectFromMemory(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code), + effect_flags, device, effect_pool, effect); + ID3D10Blob_Release(code); + + return hr; +} diff --git a/dlls/d3dx10_43/d3dx10_43_main.c b/dlls/d3dx10_43/d3dx10_43_main.c index 06b00cb0393..2bbfac9c632 100644 --- a/dlls/d3dx10_43/d3dx10_43_main.c +++ b/dlls/d3dx10_43/d3dx10_43_main.c @@ -74,19 +74,6 @@ HRESULT WINAPI D3DX10CreateEffectFromFileW(const WCHAR *filename, const D3D10_SH return E_NOTIMPL; }
-HRESULT WINAPI D3DX10CreateEffectFromMemory(const void *data, SIZE_T datasize, const char *filename, - const D3D10_SHADER_MACRO *defines, ID3D10Include *include, const char *profile, UINT hlslflags, - UINT fxflags, ID3D10Device *device, ID3D10EffectPool *effectpool, ID3DX10ThreadPump *pump, - ID3D10Effect **effect, ID3D10Blob **errors, HRESULT *hresult) -{ - FIXME("data %p, datasize %lu, filename %s, defines %p, include %p, profile %s, hlslflags %#x, fxflags %#x, " - "device %p, effectpool %p, pump %p, effect %p, errors %p, hresult %p\n", - data, datasize, debugstr_a(filename), defines, include, debugstr_a(profile), hlslflags, fxflags, device, - effectpool, pump, effect, errors, hresult); - - return E_NOTIMPL; -} - HRESULT WINAPI D3DX10CreateEffectPoolFromMemory(const void *data, SIZE_T datasize, const char *filename, const D3D10_SHADER_MACRO *defines, ID3D10Include *include, const char *profile, UINT hlslflags, UINT fxflags, ID3D10Device *device, ID3DX10ThreadPump *pump, ID3D10EffectPool **effectpool,