-- v6: tests: Print DLL versions when running tests on Windows.
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
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
--- tests/shader_runner.c | 92 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 2 deletions(-)
diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 4750b946..b050f6e5 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -1064,13 +1064,101 @@ 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 +#if defined(VKD3D_CROSSTEST) + trace("Running tests from a Windows cross build\n"); + + trace("Compiling shaders with d3dcompiler_47.dll and executing with d3d9.dll\n"); + run_shader_tests_d3d9(argc, argv); + + trace("Compiling shaders with d3dcompiler_47.dll and executing with d3d11.dll\n"); + run_shader_tests_d3d11(argc, argv); + + trace("Compiling shaders with d3dcompiler_47.dll and executing with d3d12.dll\n"); + run_shader_tests_d3d12(argc, argv); + + print_dll_version("d3dcompiler_47.dll"); + print_dll_version("dxgi.dll"); + print_dll_version("d3d9.dll"); + print_dll_version("d3d11.dll"); + print_dll_version("d3d12.dll"); +#elif defined(_WIN32) + trace("Running tests from a Windows non-cross build\n"); + + trace("Compiling shaders with vkd3d-shader and executing with d3d9.dll\n"); run_shader_tests_d3d9(argc, argv); + + trace("Compiling shaders with vkd3d-shader and executing with d3d11.dll\n"); run_shader_tests_d3d11(argc, argv); + + trace("Compiling shaders with vkd3d-shader and executing with vkd3d\n"); + run_shader_tests_d3d12(argc, argv); + + print_dll_version("d3d9.dll"); + print_dll_version("d3d11.dll"); #else + trace("Running tests from a Unix build\n"); + + trace("Compiling shaders with vkd3d-shader and executing with Vulkan\n"); run_shader_tests_vulkan(argc, argv); -#endif + + trace("Compiling shaders with vkd3d-shader and executing with vkd3d\n"); run_shader_tests_d3d12(argc, argv); +#endif }
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).
Yes, although a future where vkd3d supports additional Direct3D APIs doesn't seem that hard to imagine.
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.
Right, ultimately we'll probably want some more control at runtime over what specific configurations get run.
This merge request was approved by Henri Verbeet.