[PATCH 0/2] MR10662: d3dcompiler: Handle filenames with forward slashes in the default ID3DInclude implementation.
Native's default ID3DInclude implementation treats forward slashes in filenames identically to backward slashes. Thought it was better to create a separate test function but I'm not 100% sure on that. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10662
From: Victor Chiletto <vchiletto@codeweavers.com> Native's default ID3DInclude implementation treats forward slashes in filenames identically to backward slashes. --- dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c index a0cc1367424..ce64e8f3041 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c @@ -1788,6 +1788,44 @@ static void test_include(void) delete_directory(L"include"); } +static void test_forward_slash_includes(void) +{ +#if D3D_COMPILER_VERSION >= 46 + WCHAR filename[MAX_PATH], directory[MAX_PATH]; + ID3D10Blob *blob = NULL, *errors = NULL; + HRESULT hr; + static const char ps_code[] = + "#include \"include1.h\"\n" + "\n" + "float4 main() : COLOR\n" + "{\n" + " return LIGHT;\n" + "}"; + static const char include1[] = + "#define LIGHT 1\n"; + + create_directory(L"sources"); + create_file(L"sources\\source.ps", ps_code, strlen(ps_code), filename); + create_file(L"sources\\include1.h", include1, strlen(include1), NULL); + + GetCurrentDirectoryW(MAX_PATH, directory); + SetCurrentDirectoryW(temp_dir); + + hr = D3DCompileFromFile(L"sources/source.ps", NULL, D3D_COMPILE_STANDARD_FILE_INCLUDE, "main", "ps_2_0", 0, 0, &blob, &errors); + todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + todo_wine ok(!!blob, "Got unexpected blob.\n"); + todo_wine ok(!errors, "Got unexpected errors.\n"); + ID3D10Blob_Release(blob); + blob = NULL; + + SetCurrentDirectoryW(directory); + + delete_file(L"sources\\source.ps"); + delete_file(L"sources\\include1.h"); + delete_directory(L"sources"); +#endif +} + static void test_no_output_blob(void) { static const char vs_source[] = @@ -1878,4 +1916,5 @@ START_TEST(hlsl_d3d9) test_include(); test_no_output_blob(); test_hlsl_double(); + test_forward_slash_includes(); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10662
From: Victor Chiletto <vchiletto@codeweavers.com> --- dlls/d3dcompiler_43/compiler.c | 3 ++- dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c index f5c259191b4..a9cb535c629 100644 --- a/dlls/d3dcompiler_43/compiler.c +++ b/dlls/d3dcompiler_43/compiler.c @@ -86,7 +86,8 @@ static HRESULT WINAPI d3dcompiler_include_from_file_open(ID3DInclude *iface, D3D ULONG read; DWORD len; - if ((initial_dir = strrchr(include->initial_filename, '\\'))) + if ((initial_dir = strrchr(include->initial_filename, '\\')) || + (initial_dir = strrchr(include->initial_filename, '/'))) { len = initial_dir - include->initial_filename + 1; initial_dir = include->initial_filename; diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c index ce64e8f3041..9ea999029cd 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c @@ -1812,9 +1812,9 @@ static void test_forward_slash_includes(void) SetCurrentDirectoryW(temp_dir); hr = D3DCompileFromFile(L"sources/source.ps", NULL, D3D_COMPILE_STANDARD_FILE_INCLUDE, "main", "ps_2_0", 0, 0, &blob, &errors); - todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - todo_wine ok(!!blob, "Got unexpected blob.\n"); - todo_wine ok(!errors, "Got unexpected errors.\n"); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(!!blob, "Got unexpected blob.\n"); + ok(!errors, "Got unexpected errors.\n"); ID3D10Blob_Release(blob); blob = NULL; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10662
Alfred Agrell (@Alcaro) commented about dlls/d3dcompiler_43/tests/hlsl_d3d9.c:
+ "{\n" + " return LIGHT;\n" + "}"; + static const char include1[] = + "#define LIGHT 1\n"; + + create_directory(L"sources"); + create_file(L"sources\\source.ps", ps_code, strlen(ps_code), filename); + create_file(L"sources\\include1.h", include1, strlen(include1), NULL); + + GetCurrentDirectoryW(MAX_PATH, directory); + SetCurrentDirectoryW(temp_dir); + + hr = D3DCompileFromFile(L"sources/source.ps", NULL, D3D_COMPILE_STANDARD_FILE_INCLUDE, "main", "ps_2_0", 0, 0, &blob, &errors); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(!!blob, "Got unexpected blob.\n"); Shouldn't that be 'Got unexpected lack of blob' or something?
Probably copypasted from some other test, feel free to change there too. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10662#note_136213
Alfred Agrell (@Alcaro) commented about dlls/d3dcompiler_43/tests/hlsl_d3d9.c:
delete_directory(L"include"); }
+static void test_forward_slash_includes(void) +{ +#if D3D_COMPILER_VERSION >= 46 + WCHAR filename[MAX_PATH], directory[MAX_PATH]; + ID3D10Blob *blob = NULL, *errors = NULL; + HRESULT hr; + static const char ps_code[] = + "#include \"include1.h\"\n"
What happens if this path contains a / or \\, and the target contains another #include? Where would the inner include look? (Fair chance that's out of scope for this MR, though.) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10662#note_136215
Alfred Agrell (@Alcaro) commented about dlls/d3dcompiler_43/compiler.c:
ULONG read; DWORD len;
- if ((initial_dir = strrchr(include->initial_filename, '\\'))) + if ((initial_dir = strrchr(include->initial_filename, '\\')) || + (initial_dir = strrchr(include->initial_filename, '/')))
What is the expected behavior if the path contains both / and \\? We should add tests for that. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10662#note_136214
On Tue Apr 14 21:29:59 2026 +0000, Alfred Agrell wrote:
Shouldn't that be 'Got unexpected lack of blob' or something? Probably copypasted from some other test, feel free to change there too. That's our usual `ok()` message, although generally we also trace the value, so something like:
ok(!!blob, "Got unexpected blob %p.\n", blob);
I.e. "blob" is a very literal reference to the variable name. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10662#note_136499
On Tue Apr 14 21:29:59 2026 +0000, Alfred Agrell wrote:
What happens if this path contains a / or \\, and the target contains another #include? Where would the inner include look? (Fair chance that's out of scope for this MR, though.) I think it would be an interesting thing to test as well. It doesn't have to be fixed in the same MR, necessarily.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10662#note_136500
As per the discussion on #vkd3d, I'll close and move the code handling this to vkd3d. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10662#note_136578
This merge request was closed by Victor Chiletto. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10662
On Thu Apr 16 20:24:58 2026 +0000, Victor Chiletto wrote:
As per the discussion on #vkd3d, I'll close and move the code handling this to vkd3d. Ack. Feel free to resubmit the test part of this MR when you'll get to update d3dcompiler to make use of vkd3d-shader's default include implementation.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10662#note_136579
participants (4)
-
Alfred Agrell (@Alcaro) -
Matteo Bruni (@Mystral) -
Victor Chiletto -
Victor Chiletto (@vitorhnn)