From: Elizabeth Figura zfigura@codeweavers.com
This reflects native, and may be necessary to reflect changes in behaviour before version 33 (although no such differences are yet known to matter).
This patch does implement one notable change in behaviour, namely, that versions before 42 correctly no longer accept effects or sm4 profiles. --- dlls/d3dx9_24/Makefile.in | 3 +- dlls/d3dx9_25/Makefile.in | 3 +- dlls/d3dx9_26/Makefile.in | 3 +- dlls/d3dx9_27/Makefile.in | 3 +- dlls/d3dx9_28/Makefile.in | 3 +- dlls/d3dx9_29/Makefile.in | 3 +- dlls/d3dx9_30/Makefile.in | 3 +- dlls/d3dx9_31/Makefile.in | 3 +- dlls/d3dx9_32/Makefile.in | 3 +- dlls/d3dx9_33/Makefile.in | 3 +- dlls/d3dx9_34/Makefile.in | 3 +- dlls/d3dx9_35/Makefile.in | 3 +- dlls/d3dx9_36/Makefile.in | 3 +- dlls/d3dx9_36/d3dx9_private.h | 1 + dlls/d3dx9_36/shader.c | 227 ++++++++++++++++++++++++++++++++-- dlls/d3dx9_37/Makefile.in | 3 +- dlls/d3dx9_38/Makefile.in | 3 +- dlls/d3dx9_39/Makefile.in | 3 +- dlls/d3dx9_40/Makefile.in | 3 +- dlls/d3dx9_41/Makefile.in | 3 +- dlls/d3dx9_42/Makefile.in | 1 + dlls/d3dx9_43/Makefile.in | 1 + 22 files changed, 255 insertions(+), 29 deletions(-)
diff --git a/dlls/d3dx9_24/Makefile.in b/dlls/d3dx9_24/Makefile.in index d0fef3bebd0..63c674ff41a 100644 --- a/dlls/d3dx9_24/Makefile.in +++ b/dlls/d3dx9_24/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=24 MODULE = d3dx9_24.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_25/Makefile.in b/dlls/d3dx9_25/Makefile.in index 869c1162904..03f8a839861 100644 --- a/dlls/d3dx9_25/Makefile.in +++ b/dlls/d3dx9_25/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=25 MODULE = d3dx9_25.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_26/Makefile.in b/dlls/d3dx9_26/Makefile.in index ae3f2e18953..449ad48ac9e 100644 --- a/dlls/d3dx9_26/Makefile.in +++ b/dlls/d3dx9_26/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=26 MODULE = d3dx9_26.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_27/Makefile.in b/dlls/d3dx9_27/Makefile.in index 4f2993638f3..51188b01599 100644 --- a/dlls/d3dx9_27/Makefile.in +++ b/dlls/d3dx9_27/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=27 MODULE = d3dx9_27.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_28/Makefile.in b/dlls/d3dx9_28/Makefile.in index 3c7ddb93c2e..e5631b8d354 100644 --- a/dlls/d3dx9_28/Makefile.in +++ b/dlls/d3dx9_28/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=28 MODULE = d3dx9_28.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_29/Makefile.in b/dlls/d3dx9_29/Makefile.in index 75eb3e73243..24862be1fae 100644 --- a/dlls/d3dx9_29/Makefile.in +++ b/dlls/d3dx9_29/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=29 MODULE = d3dx9_29.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_30/Makefile.in b/dlls/d3dx9_30/Makefile.in index 9b8eb133611..7419cfc3194 100644 --- a/dlls/d3dx9_30/Makefile.in +++ b/dlls/d3dx9_30/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=30 MODULE = d3dx9_30.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_31/Makefile.in b/dlls/d3dx9_31/Makefile.in index 52d3a3d0986..354f96ea7b3 100644 --- a/dlls/d3dx9_31/Makefile.in +++ b/dlls/d3dx9_31/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=31 MODULE = d3dx9_31.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_32/Makefile.in b/dlls/d3dx9_32/Makefile.in index 70a1696de97..da5f4c5a934 100644 --- a/dlls/d3dx9_32/Makefile.in +++ b/dlls/d3dx9_32/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=32 MODULE = d3dx9_32.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_33/Makefile.in b/dlls/d3dx9_33/Makefile.in index 2c01e9da3d9..39e14fdb5f6 100644 --- a/dlls/d3dx9_33/Makefile.in +++ b/dlls/d3dx9_33/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=33 MODULE = d3dx9_33.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_34/Makefile.in b/dlls/d3dx9_34/Makefile.in index 1e317f37226..3bfedf13e3f 100644 --- a/dlls/d3dx9_34/Makefile.in +++ b/dlls/d3dx9_34/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=34 MODULE = d3dx9_34.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_35/Makefile.in b/dlls/d3dx9_35/Makefile.in index 859cef9b1ce..b598c8bf083 100644 --- a/dlls/d3dx9_35/Makefile.in +++ b/dlls/d3dx9_35/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=35 MODULE = d3dx9_35.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_36/Makefile.in b/dlls/d3dx9_36/Makefile.in index 5370b3e7e7a..5433f1ebabc 100644 --- a/dlls/d3dx9_36/Makefile.in +++ b/dlls/d3dx9_36/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=36 MODULE = d3dx9_36.dll IMPORTLIB = d3dx9 -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h index 001a7f26f4f..4678f32206f 100644 --- a/dlls/d3dx9_36/d3dx9_private.h +++ b/dlls/d3dx9_36/d3dx9_private.h @@ -22,6 +22,7 @@ #ifndef __WINE_D3DX9_PRIVATE_H #define __WINE_D3DX9_PRIVATE_H
+#include <stdbool.h> #include <stdint.h> #include "wine/debug.h" #include "wine/rbtree.h" diff --git a/dlls/d3dx9_36/shader.c b/dlls/d3dx9_36/shader.c index 88c4916b74d..bbc8fb63940 100644 --- a/dlls/d3dx9_36/shader.c +++ b/dlls/d3dx9_36/shader.c @@ -24,6 +24,8 @@ #include "d3dcommon.h" #include "d3dcompiler.h"
+#include <vkd3d_shader.h> + WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
static inline BOOL is_valid_bytecode(DWORD token) @@ -431,6 +433,213 @@ HRESULT WINAPI D3DXAssembleShaderFromResourceW(HMODULE module, const WCHAR *reso shader, error_messages); }
+#if D3DX_SDK_VERSION < 42 +static HRESULT hresult_from_vkd3d_result(int vkd3d_result) +{ + switch (vkd3d_result) + { + case VKD3D_OK: + return S_OK; + case VKD3D_ERROR_INVALID_SHADER: + WARN("Invalid shader bytecode.\n"); + /* fall-through */ + case VKD3D_ERROR: + return E_FAIL; + case VKD3D_ERROR_OUT_OF_MEMORY: + return E_OUTOFMEMORY; + case VKD3D_ERROR_INVALID_ARGUMENT: + return E_INVALIDARG; + case VKD3D_ERROR_NOT_IMPLEMENTED: + return E_NOTIMPL; + default: + FIXME("Unhandled vkd3d result %d.\n", vkd3d_result); + return E_FAIL; + } +} + +static int open_include(const char *filename, bool local, const char *parent_data, void *context, + struct vkd3d_shader_code *code) +{ + ID3DXInclude *iface = context; + unsigned int size = 0; + + if (!iface) + return VKD3D_ERROR; + + memset(code, 0, sizeof(*code)); + if (FAILED(ID3DXInclude_Open(iface, local ? D3DXINC_LOCAL : D3DXINC_SYSTEM, + filename, parent_data, &code->code, &size))) + return VKD3D_ERROR; + + code->size = size; + return VKD3D_OK; +} + +static void close_include(const struct vkd3d_shader_code *code, void *context) +{ + ID3DXInclude *iface = context; + + ID3DXInclude_Close(iface, code->code); +} + +static const char *get_line(const char **ptr) +{ + const char *p, *q; + + p = *ptr; + if (!(q = strstr(p, "\n"))) + { + if (!*p) + return NULL; + *ptr += strlen(p); + return p; + } + *ptr = q + 1; + + return p; +} + +static HRESULT compile_shader(const void *data, UINT data_size, const D3DXMACRO *macros, + ID3DXInclude *include, const char *entry_point, const char *profile, + DWORD flags, ID3DXBuffer **shader_blob, ID3DXBuffer **messages_blob) +{ + struct vkd3d_shader_preprocess_info preprocess_info; + struct vkd3d_shader_hlsl_source_info hlsl_info; + struct vkd3d_shader_compile_option options[4]; + struct vkd3d_shader_compile_info compile_info; + struct vkd3d_shader_compile_option *option; + struct vkd3d_shader_code byte_code; + const D3DXMACRO *macro; + char *messages; + HRESULT hr; + int ret; + + if (flags & ~(D3DXSHADER_DEBUG | D3DXSHADER_PACKMATRIX_ROWMAJOR | D3DXSHADER_PACKMATRIX_COLUMNMAJOR + | D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY)) + { + FIXME("Ignoring flags %#lx.\n", flags); + } + + if (shader_blob) + *shader_blob = NULL; + if (messages_blob) + *messages_blob = NULL; + + option = &options[0]; + option->name = VKD3D_SHADER_COMPILE_OPTION_API_VERSION; + option->value = VKD3D_SHADER_API_VERSION_1_3; + + compile_info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO; + compile_info.next = &preprocess_info; + compile_info.source.code = data; + compile_info.source.size = data_size; + compile_info.source_type = VKD3D_SHADER_SOURCE_HLSL; + compile_info.target_type = VKD3D_SHADER_TARGET_D3D_BYTECODE; + compile_info.options = options; + compile_info.option_count = 1; + compile_info.log_level = VKD3D_SHADER_LOG_INFO; + compile_info.source_name = NULL; + + preprocess_info.type = VKD3D_SHADER_STRUCTURE_TYPE_PREPROCESS_INFO; + preprocess_info.next = &hlsl_info; + preprocess_info.macros = (const struct vkd3d_shader_macro *)macros; + preprocess_info.macro_count = 0; + if (macros) + { + for (macro = macros; macro->Name; ++macro) + ++preprocess_info.macro_count; + } + preprocess_info.pfn_open_include = open_include; + preprocess_info.pfn_close_include = close_include; + preprocess_info.include_context = include; + + hlsl_info.type = VKD3D_SHADER_STRUCTURE_TYPE_HLSL_SOURCE_INFO; + hlsl_info.next = NULL; + hlsl_info.profile = profile; + hlsl_info.entry_point = entry_point; + hlsl_info.secondary_code.code = NULL; + hlsl_info.secondary_code.size = 0; + + if (!(flags & D3DXSHADER_DEBUG)) + { + option = &options[compile_info.option_count++]; + option->name = VKD3D_SHADER_COMPILE_OPTION_STRIP_DEBUG; + option->value = true; + } + + if (flags & D3DXSHADER_PACKMATRIX_ROWMAJOR) + { + option = &options[compile_info.option_count++]; + option->name = VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ORDER; + option->value = VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ROW_MAJOR; + } + else if (flags & D3DXSHADER_PACKMATRIX_COLUMNMAJOR) + { + option = &options[compile_info.option_count++]; + option->name = VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ORDER; + option->value = VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_COLUMN_MAJOR; + } + + if (flags & D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY) + { + option = &options[compile_info.option_count++]; + option->name = VKD3D_SHADER_COMPILE_OPTION_BACKWARD_COMPATIBILITY; + option->value = VKD3D_SHADER_COMPILE_OPTION_BACKCOMPAT_MAP_SEMANTIC_NAMES; + } + + ret = vkd3d_shader_compile(&compile_info, &byte_code, &messages); + + if (ret) + ERR("Failed to compile shader, vkd3d result %d.\n", ret); + + if (messages) + { + if (*messages && ERR_ON(d3dx)) + { + const char *ptr = messages; + const char *line; + + ERR("Shader log:\n"); + while ((line = get_line(&ptr))) + { + ERR(" %.*s", (int)(ptr - line), line); + } + ERR("\n"); + } + + if (messages_blob) + { + size_t size = strlen(messages); + if (FAILED(hr = D3DXCreateBuffer(size, messages_blob))) + { + vkd3d_shader_free_messages(messages); + vkd3d_shader_free_shader_code(&byte_code); + return hr; + } + memcpy(ID3DXBuffer_GetBufferPointer(*messages_blob), messages, size); + } + + vkd3d_shader_free_messages(messages); + } + + if (ret) + return hresult_from_vkd3d_result(ret); + + if (!shader_blob) + { + vkd3d_shader_free_shader_code(&byte_code); + return S_OK; + } + + if (SUCCEEDED(hr = D3DXCreateBuffer(byte_code.size, shader_blob))) + memcpy(ID3DXBuffer_GetBufferPointer(*shader_blob), byte_code.code, byte_code.size); + + vkd3d_shader_free_shader_code(&byte_code); + + return hr; +} +#endif + HRESULT WINAPI D3DXCompileShader(const char *data, UINT length, const D3DXMACRO *defines, ID3DXInclude *include, const char *function, const char *profile, DWORD flags, ID3DXBuffer **shader, ID3DXBuffer **error_msgs, ID3DXConstantTable **constant_table) @@ -443,10 +652,14 @@ HRESULT WINAPI D3DXCompileShader(const char *data, UINT length, const D3DXMACRO flags, shader, error_msgs, constant_table);
if (D3DX_SDK_VERSION <= 36) - flags |= D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY; + flags |= D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY;
+#if D3DX_SDK_VERSION < 42 + hr = compile_shader(data, length, defines, include, function, profile, flags, shader, error_msgs); +#else hr = D3DCompile(data, length, NULL, (D3D_SHADER_MACRO *)defines, (ID3DInclude *)include, function, profile, flags, 0, (ID3DBlob **)shader, (ID3DBlob **)error_msgs); +#endif
if (SUCCEEDED(hr) && constant_table) { @@ -526,16 +739,8 @@ HRESULT WINAPI D3DXCompileShaderFromFileW(const WCHAR *filename, const D3DXMACRO return D3DXERR_INVALIDDATA; }
- if (D3DX_SDK_VERSION <= 36) - flags |= D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY; - - hr = D3DCompile(buffer, len, filename_a, (const D3D_SHADER_MACRO *)defines, - (ID3DInclude *)include, entrypoint, profile, flags, 0, - (ID3DBlob **)shader, (ID3DBlob **)error_messages); - - if (SUCCEEDED(hr) && constant_table) - hr = D3DXGetShaderConstantTable(ID3DXBuffer_GetBufferPointer(*shader), - constant_table); + hr = D3DXCompileShader(buffer, len, defines, include, entrypoint, + profile, flags, shader, error_messages, constant_table);
ID3DXInclude_Close(include, buffer); LeaveCriticalSection(&from_file_mutex); diff --git a/dlls/d3dx9_37/Makefile.in b/dlls/d3dx9_37/Makefile.in index 150f1ceb215..0cc0595af60 100644 --- a/dlls/d3dx9_37/Makefile.in +++ b/dlls/d3dx9_37/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=37 MODULE = d3dx9_37.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_38/Makefile.in b/dlls/d3dx9_38/Makefile.in index 5706fe9b203..c8b499221bc 100644 --- a/dlls/d3dx9_38/Makefile.in +++ b/dlls/d3dx9_38/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=38 MODULE = d3dx9_38.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_39/Makefile.in b/dlls/d3dx9_39/Makefile.in index 9e8f8f6199e..5f2546fdc9f 100644 --- a/dlls/d3dx9_39/Makefile.in +++ b/dlls/d3dx9_39/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=39 MODULE = d3dx9_39.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_40/Makefile.in b/dlls/d3dx9_40/Makefile.in index fe10a5d3dcb..dc7b8afbe29 100644 --- a/dlls/d3dx9_40/Makefile.in +++ b/dlls/d3dx9_40/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=40 MODULE = d3dx9_40.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_41/Makefile.in b/dlls/d3dx9_41/Makefile.in index bc02a280d33..6a34e3e04d3 100644 --- a/dlls/d3dx9_41/Makefile.in +++ b/dlls/d3dx9_41/Makefile.in @@ -1,8 +1,9 @@ EXTRADEFS = -DD3DX_SDK_VERSION=41 MODULE = d3dx9_41.dll -IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 +IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 wined3d PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_42/Makefile.in b/dlls/d3dx9_42/Makefile.in index 5efa6cc00cd..747837fc5dc 100644 --- a/dlls/d3dx9_42/Makefile.in +++ b/dlls/d3dx9_42/Makefile.in @@ -3,6 +3,7 @@ MODULE = d3dx9_42.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dx9_43/Makefile.in b/dlls/d3dx9_43/Makefile.in index e28429c5236..1c706d4ed01 100644 --- a/dlls/d3dx9_43/Makefile.in +++ b/dlls/d3dx9_43/Makefile.in @@ -3,6 +3,7 @@ MODULE = d3dx9_43.dll IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 PARENTSRC = ../d3dx9_36 DELAYIMPORTS = windowscodecs +EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
From: Elizabeth Figura zfigura@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=33770 --- dlls/d3dx9_36/shader.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dx9_36/shader.c b/dlls/d3dx9_36/shader.c index bbc8fb63940..9322650cecc 100644 --- a/dlls/d3dx9_36/shader.c +++ b/dlls/d3dx9_36/shader.c @@ -505,7 +505,7 @@ static HRESULT compile_shader(const void *data, UINT data_size, const D3DXMACRO { struct vkd3d_shader_preprocess_info preprocess_info; struct vkd3d_shader_hlsl_source_info hlsl_info; - struct vkd3d_shader_compile_option options[4]; + struct vkd3d_shader_compile_option options[5]; struct vkd3d_shader_compile_info compile_info; struct vkd3d_shader_compile_option *option; struct vkd3d_shader_code byte_code; @@ -528,6 +528,9 @@ static HRESULT compile_shader(const void *data, UINT data_size, const D3DXMACRO option = &options[0]; option->name = VKD3D_SHADER_COMPILE_OPTION_API_VERSION; option->value = VKD3D_SHADER_API_VERSION_1_3; + option = &options[1]; + option->name = VKD3D_SHADER_COMPILE_OPTION_WARN_IMPLICIT_TRUNCATION; + option->value = false;
compile_info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO; compile_info.next = &preprocess_info; @@ -536,7 +539,7 @@ static HRESULT compile_shader(const void *data, UINT data_size, const D3DXMACRO compile_info.source_type = VKD3D_SHADER_SOURCE_HLSL; compile_info.target_type = VKD3D_SHADER_TARGET_D3D_BYTECODE; compile_info.options = options; - compile_info.option_count = 1; + compile_info.option_count = 2; compile_info.log_level = VKD3D_SHADER_LOG_INFO; compile_info.source_name = NULL;
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/d3dcompiler_43/compiler.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c index 6fffcfb82ab..7e837ff4b39 100644 --- a/dlls/d3dcompiler_43/compiler.c +++ b/dlls/d3dcompiler_43/compiler.c @@ -457,7 +457,7 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen struct d3dcompiler_include_from_file include_from_file; struct vkd3d_shader_preprocess_info preprocess_info; struct vkd3d_shader_hlsl_source_info hlsl_info; - struct vkd3d_shader_compile_option options[6]; + struct vkd3d_shader_compile_option options[7]; struct vkd3d_shader_compile_info compile_info; struct vkd3d_shader_compile_option *option; struct vkd3d_shader_code byte_code; @@ -530,6 +530,13 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen hlsl_info.secondary_code.code = secondary_data; hlsl_info.secondary_code.size = secondary_data_size;
+ if (D3D_COMPILER_VERSION < 42) + { + option = &options[compile_info.option_count++]; + option->name = VKD3D_SHADER_COMPILE_OPTION_WARN_IMPLICIT_TRUNCATION; + option->value = false; + } + if (!(flags & D3DCOMPILE_DEBUG)) { option = &options[compile_info.option_count++];
Commit 1/3 isn't precisely necessary; we could simply forward to the corresponding (or lowest) version of d3dcompiler.
On the other hand it would be necessary if we wanted to, as native does, automatically promote ps 1.x to 2.0, while still allowing versions 31 and lower to compile them.
Nikolay Sivov (@nsivov) commented about dlls/d3dx9_36/shader.c:
option->name = VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ORDER;
option->value = VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ROW_MAJOR;
- }
- else if (flags & D3DXSHADER_PACKMATRIX_COLUMNMAJOR)
- {
option = &options[compile_info.option_count++];
option->name = VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ORDER;
option->value = VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_COLUMN_MAJOR;
- }
- if (flags & D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY)
- {
option = &options[compile_info.option_count++];
option->name = VKD3D_SHADER_COMPILE_OPTION_BACKWARD_COMPATIBILITY;
option->value = VKD3D_SHADER_COMPILE_OPTION_BACKCOMPAT_MAP_SEMANTIC_NAMES;
- }
I don't think this makes sense for d3dx9.
On Sat Jun 8 23:15:39 2024 +0000, Elizabeth Figura wrote:
Commit 1/3 isn't precisely necessary; we could simply forward to the corresponding (or lowest) version of d3dcompiler. On the other hand it would be necessary if we wanted to, as native does, automatically promote ps 1.x to 2.0, while still allowing versions 31 and lower to compile them.
If we ever want to do that, we should consider using PARENTSRC instead of duplicating the whole thing, in principle at least. Right now that's already reserved for d3dx9_xx -> d3dx9_36, although the only reason for that is to avoid forwarded exports (bug 21817) which can now be alternatively solved via -import in the .spec file.
So I guess I'd prefer forwarding to d3dcompiler for the time being, assuming that works properly, and reevaluating once we actually need a separate implementation for d3dx9 (whether it's really separate or mostly shared via PARENTSRC). That said, I'm not really opposed to 1/3.
On Sat Jun 8 22:43:18 2024 +0000, Nikolay Sivov wrote:
I don't think this makes sense for d3dx9.
Ah right, that's an sm4-specific option. I'll remove it.
On Sat Jun 8 23:15:39 2024 +0000, Matteo Bruni wrote:
If we ever want to do that, we should consider using PARENTSRC instead of duplicating the whole thing, in principle at least. Right now that's already reserved for d3dx9_xx -> d3dx9_36, although the only reason for that is to avoid forwarded exports (bug 21817) which can now be alternatively solved via -import in the .spec file. So I guess I'd prefer forwarding to d3dcompiler for the time being, assuming that works properly, and reevaluating once we actually need a separate implementation for d3dx9 (whether it's really separate or mostly shared via PARENTSRC). That said, I'm not really opposed to 1/3.
I guess PARENTSRC seems a little excessive for 200 lines of code...
I can't say I'm thrilled about redoing this, when this is probably going to be the final form, but I suppose that's on me for not consulting first.
On Sun Jun 9 16:57:02 2024 +0000, Elizabeth Figura wrote:
I guess PARENTSRC seems a little excessive for 200 lines of code... I can't say I'm thrilled about redoing this, when this is probably going to be the final form, but I suppose that's on me for not consulting first.
200 lines aren't a ton, but it's more about not needing to duplicate all the changes / fixes to come, and eventually forgetting to update one side.
On Sun Jun 9 17:07:40 2024 +0000, Matteo Bruni wrote:
200 lines aren't a ton, but it's more about not needing to duplicate all the changes / fixes to come, and eventually forgetting to update one side.
True.
One thing we could also consider is using the vkd3d-utils implementation (and adding a vkd3d-utils implementation for d3dx9, which could share code). I think the main blocker there is that we can't have version-dependent behaviour, but we could add a separate export like "D3DCompileVKD3D()" for that.
On Sun Jun 9 21:14:44 2024 +0000, Elizabeth Figura wrote:
True. One thing we could also consider is using the vkd3d-utils implementation (and adding a vkd3d-utils implementation for d3dx9, which could share code). I think the main blocker there is that we can't have version-dependent behaviour, but we could add a separate export like "D3DCompileVKD3D()" for that.
Yeah, maybe that's actually the final form :slight_smile:
At any rate, I'm cool with this approach. I guess I'm just pushing the possibility that we'll ever need to generate PS 1.x shaders out of my mind :sweat_smile:
Why is wined3d library being imported for pre-42 d3dx9 versions? This could possibly limit native Windows compatibility (which would be necessary for Wine's own DirectX redistributable)
On Fri Jun 14 06:43:10 2024 +0000, Aida Jonikienė wrote:
Why is wined3d library being imported for pre-42 d3dx9 versions? This could possibly limit native Windows compatibility (which would be necessary for Wine's own DirectX redistributable)
It's for the vkd3d-shader calls. Currently vkd3d-shader is imported (by default statically) by wined3d, which is then imported by the various d3dcompiler_xx versions. This would do the same for the d3dx9_xx DLLs. I don't love this whole "let's dynamically import wined3d everywhere" thing but I don't think there is an obviously better alternative in general.
On Fri Jun 14 12:03:50 2024 +0000, Matteo Bruni wrote:
It's for the vkd3d-shader calls. Currently vkd3d-shader is imported (by default statically) by wined3d, which is then imported by the various d3dcompiler_xx versions. This would do the same for the d3dx9_xx DLLs. I don't love this whole "let's dynamically import wined3d everywhere" thing but I don't think there is an obviously better alternative in general.
Compiling our bundled libraries as shared would at least be an improvement. I don't think there's any reason not to do this, and it would remove the need to import wined3d. It's still an extra library that you'd have to copy to use wine's d3dx* on Windows, if that's something you want to do, though I suppose I don't have a great idea of what the problems with that are?
On Fri Jun 14 16:31:46 2024 +0000, Elizabeth Figura wrote:
Compiling our bundled libraries as shared would at least be an improvement. I don't think there's any reason not to do this, and it would remove the need to import wined3d. It's still an extra library that you'd have to copy to use wine's d3dx* on Windows, if that's something you want to do, though I suppose I don't have a great idea of what the problems with that are?
(FWIW I agree with @zfigura; building bundled libs as shared would be nice IMHO, and likely deserving of its own MR)
On Thu Dec 5 16:56:52 2024 +0000, Matteo Bruni wrote:
Yeah, maybe that's actually the final form :slight_smile: At any rate, I'm cool with this approach. I guess I'm just pushing the possibility that we'll ever need to generate PS 1.x shaders out of my mind :sweat_smile:
We have that `D3DCompile2VKD3D()` now, right? Although I guess we'd need to plug in vkd3d-utils as well and the annoyances with importing vkd3d (or static libs in general) mentioned in the other comment below still remain...
We have that `D3DCompile2VKD3D()` now, right? Although I guess we'd need to plug in vkd3d-utils as well and the annoyances with importing vkd3d (or static libs in general) mentioned in the other comment below still remain...
We do, but we don't have the d3dx9 version. I suppose we could just call D3DCompile2VKD3D() from d3dx9, though, now that I think about it?