-- v5: tests: Print DLL versions when running tests on Windows. tests: Run d3d9 and d3d12 tests on non-cross builds too.
From: Giovanni Mascellani gmascellani@codeweavers.com
On cross builds, shaders are compiled with d3dcompiler_47.dll and run with d3dN.dll. On non-cross builds, shaders are compiled with vkd3d-shader and run with d3dN.dll (on Windows) or Vulkan and vkd3d (on Linux). --- Makefile.am | 2 ++ tests/shader_runner.c | 2 +- tests/shader_runner_d3d11.c | 7 +++++-- tests/shader_runner_d3d9.c | 4 ++++ tests/shader_runner_vulkan.c | 4 ++++ 5 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/Makefile.am b/Makefile.am index ee1c49e5..c9b7d5df 100644 --- a/Makefile.am +++ b/Makefile.am @@ -330,6 +330,8 @@ tests_hlsl_d3d12_LDADD = $(LDADD) @DL_LIBS@ tests_shader_runner_LDADD = $(LDADD) @DL_LIBS@ tests_shader_runner_SOURCES = \ tests/shader_runner.c \ + tests/shader_runner_d3d9.c \ + tests/shader_runner_d3d11.c \ tests/shader_runner_d3d12.c \ tests/shader_runner_vulkan.c tests_vkd3d_api_LDADD = libvkd3d.la @DL_LIBS@ diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 56ac82f2..4750b946 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -1066,7 +1066,7 @@ out:
START_TEST(shader_runner) { -#ifdef VKD3D_CROSSTEST +#ifdef _WIN32 run_shader_tests_d3d9(argc, argv); run_shader_tests_d3d11(argc, argv); #else diff --git a/tests/shader_runner_d3d11.c b/tests/shader_runner_d3d11.c index d2b4807c..ba9e3179 100644 --- a/tests/shader_runner_d3d11.c +++ b/tests/shader_runner_d3d11.c @@ -18,8 +18,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#ifdef _WIN32 + #define COBJMACROS #define CONST_VTABLE +#define INITGUID #define VKD3D_TEST_NO_DEFS #include <d3d11_4.h> #define __vkd3d_d3dcommon_h__ @@ -29,8 +32,6 @@ #include "shader_runner.h" #include "vkd3d_test.h"
-const GUID IID_IDXGIDevice = {0x54ec77fa, 0x1377, 0x44e6, {0x8c, 0x32, 0x88, 0xfd, 0x5f, 0x44, 0xc8, 0x4c}}; - static HRESULT (WINAPI *pCreateDXGIFactory1)(REFIID iid, void **factory);
static HRESULT (WINAPI *pD3D11CreateDevice)(IDXGIAdapter *adapter, D3D_DRIVER_TYPE driver_type, @@ -711,3 +712,5 @@ void run_shader_tests_d3d11(int argc, char **argv) FreeLibrary(d3d11_module); FreeLibrary(dxgi_module); } + +#endif diff --git a/tests/shader_runner_d3d9.c b/tests/shader_runner_d3d9.c index e425da1b..fbeee8f9 100644 --- a/tests/shader_runner_d3d9.c +++ b/tests/shader_runner_d3d9.c @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#ifdef _WIN32 + #define COBJMACROS #define CONST_VTABLE #define VKD3D_TEST_NO_DEFS @@ -533,3 +535,5 @@ void run_shader_tests_d3d9(int argc, char **argv) } FreeLibrary(d3d9_module); } + +#endif diff --git a/tests/shader_runner_vulkan.c b/tests/shader_runner_vulkan.c index 39dbd787..74d3f09a 100644 --- a/tests/shader_runner_vulkan.c +++ b/tests/shader_runner_vulkan.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#ifndef _WIN32 + #define VK_NO_PROTOTYPES #define VKD3D_TEST_NO_DEFS #include "config.h" @@ -1285,3 +1287,5 @@ void run_shader_tests_vulkan(int argc, char **argv)
cleanup_vulkan_runner(&runner); } + +#endif
From: Giovanni Mascellani gmascellani@codeweavers.com
Now the tests compile correctly on non-cross Win32 builds. --- Makefile.am | 2 +- tests/d3d12_crosstest.h | 4 ++-- tests/shader_runner.c | 2 +- tests/vkd3d_api.c | 17 +++++++++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 9459bad9..ee1c49e5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -411,7 +411,7 @@ dummy-vkd3d-version: ## Cross-compile tests cross_implibs = crosslibs/d3d12 CROSS_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/include/private -I$(builddir)/include -CROSS_CFLAGS = -g -O2 -Wall -municode ${CROSS_CPPFLAGS} -D__USE_MINGW_ANSI_STDIO=0 +CROSS_CFLAGS = -g -O2 -Wall -municode ${CROSS_CPPFLAGS} -D__USE_MINGW_ANSI_STDIO=0 -DVKD3D_CROSSTEST=1 EXTRA_DIST += $(cross_implibs:=.cross32.def) $(cross_implibs:=.cross64.def) EXTRA_DIST += tests/shader_runner_d3d11.c tests/shader_runner_d3d9.c
diff --git a/tests/d3d12_crosstest.h b/tests/d3d12_crosstest.h index e6dc7a6c..26f70018 100644 --- a/tests/d3d12_crosstest.h +++ b/tests/d3d12_crosstest.h @@ -56,7 +56,7 @@ typedef int HRESULT; #include <stddef.h> #include <time.h>
-#ifdef _WIN32 +#ifdef VKD3D_CROSSTEST # include "vkd3d_dxgi1_4.h" #else # define VKD3D_UTILS_API_VERSION VKD3D_API_VERSION_1_2 @@ -261,7 +261,7 @@ static void wait_queue_idle_(unsigned int line, ID3D12Device *device, ID3D12Comm static bool use_warp_device; static unsigned int use_adapter_idx;
-#ifdef _WIN32 +#ifdef VKD3D_CROSSTEST static IUnknown *create_warp_adapter(IDXGIFactory4 *factory) { IUnknown *adapter; diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 4750b946..56ac82f2 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -1066,7 +1066,7 @@ out:
START_TEST(shader_runner) { -#ifdef _WIN32 +#ifdef VKD3D_CROSSTEST run_shader_tests_d3d9(argc, argv); run_shader_tests_d3d11(argc, argv); #else diff --git a/tests/vkd3d_api.c b/tests/vkd3d_api.c index ab266c4b..5a585fec 100644 --- a/tests/vkd3d_api.c +++ b/tests/vkd3d_api.c @@ -16,6 +16,23 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+/* Hack for MinGW-w64 headers. + * + * We want to use WIDL C inline wrappers because some methods + * in D3D12 interfaces return aggregate objects. Unfortunately, + * WIDL C inline wrappers are broken when used with MinGW-w64 + * headers because FORCEINLINE expands to extern inline + * which leads to the "multiple storage classes in declaration + * specifiers" compiler error. + */ +#ifdef __MINGW32__ +# include <_mingw.h> +# ifdef __MINGW64_VERSION_MAJOR +# undef __forceinline +# define __forceinline __inline__ __attribute__((__always_inline__,__gnu_inline__)) +# endif +#endif + #define VK_NO_PROTOTYPES #define COBJMACROS #define INITGUID
From: Giovanni Mascellani gmascellani@codeweavers.com
--- tests/shader_runner.c | 70 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 4750b946..96321667 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -1064,8 +1064,78 @@ out: vkd3d_test_set_context(NULL); }
+#ifdef _WIN32 +static void print_dll_version(const char *file_name) +{ + BOOL (WINAPI *GetFileVersionInfoA)(const char *, DWORD, DWORD, void *); + BOOL (WINAPI *VerQueryValueA)(void *, char *, void **, UINT*); + DWORD (WINAPI *GetFileVersionInfoSizeA)(const char *, DWORD *); + HMODULE version_module; + DWORD size, handle; + bool done = false; + + version_module = LoadLibraryA("version.dll"); + if (!version_module) + goto out; + +#define X(name) name = (void *)GetProcAddress(version_module, #name); + X(GetFileVersionInfoSizeA); + X(GetFileVersionInfoA); + X(VerQueryValueA); +#undef X + + if (!GetFileVersionInfoSizeA || !GetFileVersionInfoA || !VerQueryValueA) + { + FreeLibrary(version_module); + goto out; + } + + size = GetFileVersionInfoSizeA(file_name, &handle); + if (size) + { + char *data = malloc(size); + + if (GetFileVersionInfoA(file_name, handle, size, data)) + { + VS_FIXEDFILEINFO *info; + UINT len; + + if (VerQueryValueA(data, "\", (void **)&info, &len)) + { + trace("%s version: %lu.%lu.%lu.%lu\n", file_name, + info->dwFileVersionMS >> 16, info->dwFileVersionMS & 0xffff, + info->dwFileVersionLS >> 16, info->dwFileVersionLS & 0xffff); + done = true; + } + } + free(data); + } + + FreeLibrary(version_module); + +out: + if (!done) + trace("%s version: unknown\n", file_name); +} +#endif + START_TEST(shader_runner) { +#ifdef _WIN32 +# ifdef VKD3D_CROSSTEST + trace("Running tests from a Windows cross build: shaders are compiled with d3dcompiler_47.dll and executed with d3dN.dll\n"); + print_dll_version("d3dcompiler_47.dll"); +# else + trace("Running tests from a Windows non-cross build: shaders are compiled with vkd3d-shader and executed with d3dN.dll\n"); +# endif + print_dll_version("dxgi.dll"); + print_dll_version("d3d9.dll"); + print_dll_version("d3d11.dll"); + print_dll_version("d3d12.dll"); +#else + trace("Running tests from a Unix build: shaders are compiled with vkd3d-shader and executed with vkd3d and Vulkan\n"); +#endif + #ifdef _WIN32 run_shader_tests_d3d9(argc, argv); run_shader_tests_d3d11(argc, argv);
In the last version D3D9 and D3D11 tests are executed on non-cross builds too. I also added some additional logging so that it's easier to follow what's happening (especially, say, if a log trace is shared and it's not clear what was executed in the first place). How do you both see that?
Eventually it would be nice to run Vulkan tests on Windows too, I guess, but I won't tackle that this time.
Unfortunately there is a warning in non-cross builds I don't completely understand how to get rid of: ``` In file included from ../vkd3d/tests/d3d12_crosstest.h:46, from ../vkd3d/tests/d3d12.c:24: ../vkd3d/include/private/vkd3d_test.h:323:5: warning: no previous prototype for ‘wmain’ [-Wmissing-prototypes] 323 | int wmain(int argc, WCHAR **wargv) | ^~~~~ ``` Any suggestion for that?
In the last version D3D9 and D3D11 tests are executed on non-cross builds too. I also added some additional logging so that it's easier to follow what's happening (especially, say, if a log trace is shared and it's not clear what was executed in the first place). How do you both see that?
Generally I'm in favour, although the nested #ifdef's do look a bit messy.
Unfortunately there is a warning in non-cross builds I don't completely understand how to get rid of:
In file included from ../vkd3d/tests/d3d12_crosstest.h:46, from ../vkd3d/tests/d3d12.c:24: ../vkd3d/include/private/vkd3d_test.h:323:5: warning: no previous prototype for ‘wmain’ [-Wmissing-prototypes] 323 | int wmain(int argc, WCHAR **wargv) | ^~~~~
Any suggestion for that?
We probably need to add -municode, much like 59d918fd50e6a4fad4052b563bfd248d8ff87013 did for the demos.
On 1/18/23 10:14, Henri Verbeet (@hverbeet) wrote:
In the last version D3D9 and D3D11 tests are executed on non-cross builds too. I also added some additional logging so that it's easier to follow what's happening (especially, say, if a log trace is shared and it's not clear what was executed in the first place). How do you both see that?
Generally I'm in favour, although the nested #ifdef's do look a bit messy.
Unfortunately there is a warning in non-cross builds I don't completely understand how to get rid of:
In file included from ../vkd3d/tests/d3d12_crosstest.h:46, from ../vkd3d/tests/d3d12.c:24: ../vkd3d/include/private/vkd3d_test.h:323:5: warning: no previous prototype for ‘wmain’ [-Wmissing-prototypes] 323 | int wmain(int argc, WCHAR **wargv) | ^~~~~
Any suggestion for that?
We probably need to add -municode, much like 59d918fd50e6a4fad4052b563bfd248d8ff87013 did for the demos.
Do we actually need a Unicode main()? Could we just do something like the attached diff?
I'm not sure I completely follow the logic. I guess the interesting thing about the d3d9 and d3d11 tests is that it would be much easier to end up with the Windows D3D + vkd3d-shader configuration, while for the d3d12 tests you'd typically either have Windows D3D + d3dcompiler or vkd3d + vkd3d-shader. (Note though that Wine and the possibility of using native DLLs does complicate that picture a little.) That means we may need to do a better job of distinguishing between Windows D3D and wined3d/vkd3d, separately from distinguishing between d3dcompiler and vkd3d-shader, instead of lumping these together, but that might not be a bad thing anyway?
I was thinking of a division between vkd3d+vkd3d-shader and native (d3d*+d3dcompiler), where "crosstest" means native and normal test means vkd3d. I hadn't really considered the idea of mixing and matching the two. It seems interesting enough to try, but the way v4 of this series does it seems inconsistent—if we're going to build the d3d11 runner to use vkd3d's HLSL compiler with native vkd3d, I'd expect the d3d12 runner from the same executalbe to be built the same way. Granted, there's a printed warning that's *not* what's happening...
Ultimately we are probably going to have to abandon "crosstests" for the shader runner; they're not going to be expressive enough.
On Thu Jan 19 10:53:42 2023 +0000, Zebediah Figura wrote:
I'm not sure I completely follow the logic. I guess the interesting
thing about the d3d9 and d3d11 tests is that it would be much easier to end up with the Windows D3D + vkd3d-shader configuration, while for the d3d12 tests you'd typically either have Windows D3D + d3dcompiler or vkd3d + vkd3d-shader. (Note though that Wine and the possibility of using native DLLs does complicate that picture a little.) That means we may need to do a better job of distinguishing between Windows D3D and wined3d/vkd3d, separately from distinguishing between d3dcompiler and vkd3d-shader, instead of lumping these together, but that might not be a bad thing anyway? I was thinking of a division between vkd3d+vkd3d-shader and native (d3d*+d3dcompiler), where "crosstest" means native and normal test means vkd3d. I hadn't really considered the idea of mixing and matching the two. It seems interesting enough to try, but the way v4 of this series does it seems inconsistent—if we're going to build the d3d11 runner to use vkd3d's HLSL compiler with native vkd3d, I'd expect the d3d12 runner from the same executalbe to be built the same way. Granted, there's a printed warning that's *not* what's happening... Ultimately we are probably going to have to abandon "crosstests" for the shader runner; they're not going to be expressive enough.
Yeah, d3d12 is different because for d3d9 and d3d11 we can't do other then using the native thing, while for d3d12 in principle we can use either the native library or our own implementation. For testing I usually feel rather maximalist, so I would consider it ideal to have a way to run all the possible combinations: * compile the shaders with vkd3d-shader and execute them with vkd3d (via its D3D12 interface): this is already happening on non-cross builds (though it's true that with my patch the shader runner would falsely pretend that they're being run with d3d12.dll, so I'll fix the message); * compile the shaders with vkd3d-shader and execute them with d3d12.dll: this is neither happening currently nor with my patch; * compile the shaders with vkd3d-shader and execute them with d3d11.dll: this is not currently happening, but would with my patch on non-cross builds; * compile the shaders with vkd3d-shader and execute them with d3d9.dll: this is not currently happening, but would with my patch on non-cross builds; * compile the shaders with vkd3d-shader and execute them with Vulkan (via the custom shader runner): this is neither happening currently nor with my patch; * compile the shaders with d3dcompiler_47.dll and execute them with vkd3d: this is neither happening currently nor with my patch; * compile the shaders with d3dcompiler_47.dll and execute them with d3d12.dll: this is already happening on cross builds; * compile the shaders with d3dcompiler_47.dll and execute them with d3d11.dll: this is already happening on cross builds; * compile the shaders with d3dcompiler_47.dll and execute them with d3d9.dll: this is already happening on cross builds; * compile the shaders with d3dcompiler_47.dll and execute them with Vulkan (this would involve another recompilation step DXBC->SPIR-V with vkd3d-shader): this is neither happening currently nor with my patch.
All of this of course only makes sense for Win32 (cross) builds. On Unix we can only compile with vkd3d-shader and execute with vkd3d or Vulkan (and we already do both). In principle one could also add other rows/columns to the matrix (i.e., use d3dcompiler_N.dll or d3d10.dll), but maybe that's not terribly meaningful. Also, for tests that are not the shader runner only four lines of those make sense, if I am not mistaken (specifically, compiling with either vkd3d-shader or d3dcompiler_47.dll and executing with either vkd3d or d3d12.dll).
As I said, I feel rather maximalist, so in principle I'd implement all the lines above (though I acknowledge that some lines make more sense than others). Possibly with some options to disable some of them at runtime, for testing speed reasons. Also I'd rig things so that the non-cross builds is able to run all the combinations in a single executable, for convenience reasons.
However, I don't think that this is in scope for this specific MR, so I would ask for it to be accepted as it is (modulo perhaps warnings and code style), and other combinations (if considered desirable) can be added later.