From 96925f8a70c0c368f22364e4b092456982d9c9c0 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Fri, 15 Nov 2019 16:37:52 +0100 Subject: [PATCH] vkd3d: Load d3d12 dynamically in d3d12 tests. MinGW does not ship d3d12 properly, so link against d3d12.dll dynamically instead. Signed-off-by: Hans-Kristian Arntzen --- tests/d3d12.c | 5 +++++ tests/d3d12_crosstest.h | 14 ++++++++++---- tests/d3d12_invalid_usage.c | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/d3d12.c b/tests/d3d12.c index 964741d8..7c21b41c 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -25,6 +25,8 @@ static PFN_D3D12_CREATE_VERSIONED_ROOT_SIGNATURE_DESERIALIZER pfn_D3D12CreateVersionedRootSignatureDeserializer; static PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE pfn_D3D12SerializeVersionedRootSignature; +PFN_D3D12_CREATE_DEVICE pfn_D3D12CreateDevice; +PFN_D3D12_GET_DEBUG_INTERFACE pfn_D3D12GetDebugInterface; struct vec2 { @@ -33266,6 +33268,9 @@ static void test_write_buffer_immediate(void) START_TEST(d3d12) { + pfn_D3D12CreateDevice = get_d3d12_pfn(D3D12CreateDevice); + pfn_D3D12GetDebugInterface = get_d3d12_pfn(D3D12GetDebugInterface); + parse_args(argc, argv); enable_d3d12_debug_layer(argc, argv); init_adapter_info(); diff --git a/tests/d3d12_crosstest.h b/tests/d3d12_crosstest.h index 1bf89762..0fad48fa 100644 --- a/tests/d3d12_crosstest.h +++ b/tests/d3d12_crosstest.h @@ -66,6 +66,9 @@ typedef int HRESULT; #include "d3d12_test_utils.h" +extern PFN_D3D12_CREATE_DEVICE pfn_D3D12CreateDevice; +extern PFN_D3D12_GET_DEBUG_INTERFACE pfn_D3D12GetDebugInterface; + #if defined(_WIN32) && !defined(VKD3D_FORCE_UTILS_WRAPPER) static inline HANDLE create_event(void) { @@ -90,7 +93,10 @@ static inline void destroy_event(HANDLE event) #define get_d3d12_pfn(name) get_d3d12_pfn_(#name) static inline void *get_d3d12_pfn_(const char *name) { - return GetProcAddress(GetModuleHandleA("d3d12.dll"), name); + static HMODULE d3d12_module; + if (!d3d12_module) + d3d12_module = LoadLibraryA("d3d12.dll"); + return GetProcAddress(d3d12_module, name); } #else #define INFINITE VKD3D_INFINITE @@ -293,7 +299,7 @@ static ID3D12Device *create_device(void) return NULL; } - hr = D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_11_0, &IID_ID3D12Device, (void **)&device); + hr = pfn_D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_11_0, &IID_ID3D12Device, (void **)&device); if (adapter) IUnknown_Release(adapter); @@ -715,7 +721,7 @@ static void enable_d3d12_debug_layer(int argc, char **argv) if (enable_gpu_based_validation) { - if (SUCCEEDED(D3D12GetDebugInterface(&IID_ID3D12Debug1, (void **)&debug1))) + if (SUCCEEDED(pfn_D3D12GetDebugInterface(&IID_ID3D12Debug1, (void **)&debug1))) { ID3D12Debug1_SetEnableGPUBasedValidation(debug1, true); ID3D12Debug1_Release(debug1); @@ -727,7 +733,7 @@ static void enable_d3d12_debug_layer(int argc, char **argv) } } - if (enable_debug_layer && SUCCEEDED(D3D12GetDebugInterface(&IID_ID3D12Debug, (void **)&debug))) + if (enable_debug_layer && SUCCEEDED(pfn_D3D12GetDebugInterface(&IID_ID3D12Debug, (void **)&debug))) { ID3D12Debug_EnableDebugLayer(debug); ID3D12Debug_Release(debug); diff --git a/tests/d3d12_invalid_usage.c b/tests/d3d12_invalid_usage.c index c6465d0b..04b603ae 100644 --- a/tests/d3d12_invalid_usage.c +++ b/tests/d3d12_invalid_usage.c @@ -17,6 +17,8 @@ */ #include "d3d12_crosstest.h" +PFN_D3D12_CREATE_DEVICE pfn_D3D12CreateDevice; +PFN_D3D12_GET_DEBUG_INTERFACE pfn_D3D12GetDebugInterface; #define recreate_command_list(a, b, c) recreate_command_list_(__LINE__, a, b, c) static void recreate_command_list_(unsigned int line, ID3D12Device *device,