Signed-off-by: Hans-Kristian Arntzen post@arntzen-software.no --- include/private/vkd3d_threads.h | 167 ++++++++++++++++++++++++++++++++ libs/vkd3d/device.c | 2 +- libs/vkd3d/utils.c | 8 +- libs/vkd3d/vkd3d_private.h | 17 ++-- 4 files changed, 179 insertions(+), 15 deletions(-) create mode 100644 include/private/vkd3d_threads.h
diff --git a/include/private/vkd3d_threads.h b/include/private/vkd3d_threads.h new file mode 100644 index 0000000..736bf6e --- /dev/null +++ b/include/private/vkd3d_threads.h @@ -0,0 +1,167 @@ +/* + * Copyright 2019 Hans-Kristian Arntzen for Valve + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __VKD3D_THREADS_H +#define __VKD3D_THREADS_H + +#include "config.h" +#include "vkd3d_memory.h" + +#if defined(HAVE_PTHREAD_H) +#include <pthread.h> + +#elif defined(_WIN32) /* HAVE_PTHREAD_H */ + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +/* pthread_t is passed by value in some functions, + * which implies we need pthread_t to be a pointer type here. */ +struct pthread +{ + HANDLE thread; + DWORD id; + void * (*routine)(void *); + void *arg; +}; +typedef struct pthread *pthread_t; + +/* pthread_mutex_t is not copyable, so embed CS inline. */ +typedef struct pthread_mutex +{ + CRITICAL_SECTION lock; +} pthread_mutex_t; + +/* pthread_cond_t is not copyable, so embed CV inline. */ +typedef struct pthread_cond +{ + CONDITION_VARIABLE cond; +} pthread_cond_t; + +static DWORD WINAPI win32_thread_wrapper_routine(void *arg) +{ + pthread_t thread = arg; + thread->routine(thread->arg); + return 0; +} + +static inline int pthread_create(pthread_t *out_thread, void *attr, void * (*thread_fun)(void *), void *arg) +{ + pthread_t thread = vkd3d_calloc(1, sizeof(*thread)); + if (!thread) + return -1; + + (void)attr; + thread->routine = thread_fun; + thread->arg = arg; + thread->thread = CreateThread(NULL, 0, win32_thread_wrapper_routine, thread, 0, &thread->id); + if (!thread->thread) + { + vkd3d_free(thread); + return -1; + } + *out_thread = thread; + return 0; +} + +static inline int pthread_join(pthread_t thread, void **ret) +{ + (void)ret; + int success = WaitForSingleObject(thread->thread, INFINITE) == WAIT_OBJECT_0; + if (success) + { + CloseHandle(thread->thread); + vkd3d_free(thread); + } + return success ? 0 : -1; +} + +static inline int pthread_mutex_init(pthread_mutex_t *lock, void *attr) +{ + (void)attr; + InitializeCriticalSection(&lock->lock); + return 0; +} + +static inline int pthread_mutex_lock(pthread_mutex_t *lock) +{ + EnterCriticalSection(&lock->lock); + return 0; +} + +static inline int pthread_mutex_unlock(pthread_mutex_t *lock) +{ + LeaveCriticalSection(&lock->lock); + return 0; +} + +static inline int pthread_mutex_destroy(pthread_mutex_t *lock) +{ + DeleteCriticalSection(&lock->lock); + return 0; +} + +static inline int pthread_cond_init(pthread_cond_t *cond, void *attr) +{ + (void)attr; + InitializeConditionVariable(&cond->cond); + return 0; +} + +static inline int pthread_cond_destroy(pthread_cond_t *cond) +{ + (void)cond; + return 0; +} + +static inline int pthread_cond_signal(pthread_cond_t *cond) +{ + WakeConditionVariable(&cond->cond); + return 0; +} + +static inline int pthread_cond_broadcast(pthread_cond_t *cond) +{ + WakeAllConditionVariable(&cond->cond); + return 0; +} + +static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *lock) +{ + BOOL ret = SleepConditionVariableCS(&cond->cond, &lock->lock, INFINITE); + return ret ? 0 : -1; +} + +#else /* HAVE_PTHREAD_H */ +#error "Threads are not supported. Cannot build." +#endif /* HAVE_PTHREAD_H */ + +static inline void vkd3d_set_thread_name(const char *name) +{ +#if defined(_MSC_VER) + (void)name; +#elif defined(HAVE_PTHREAD_SETNAME_NP_2) + pthread_setname_np(pthread_self(), name); +#elif defined(HAVE_PTHREAD_SETNAME_NP_1) + pthread_setname_np(name); +#else + (void)name; +#endif +} + +#endif /* __VKD3D_THREADS_H */ diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 0624318..cc8e282 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -453,7 +453,7 @@ static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance, bool *user_extension_supported = NULL; VkApplicationInfo application_info; VkInstanceCreateInfo instance_info; - char application_name[PATH_MAX]; + char application_name[VKD3D_PATH_MAX]; uint32_t extension_count; const char **extensions; VkInstance vk_instance; diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c index cf0448d..64eb845 100644 --- a/libs/vkd3d/utils.c +++ b/libs/vkd3d/utils.c @@ -830,7 +830,7 @@ HRESULT vkd3d_load_vk_device_procs(struct vkd3d_vk_device_procs *procs,
#if HAVE_DECL_PROGRAM_INVOCATION_NAME
-bool vkd3d_get_program_name(char program_name[PATH_MAX]) +bool vkd3d_get_program_name(char program_name[VKD3D_PATH_MAX]) { char *name, *p, *real_path = NULL;
@@ -856,15 +856,15 @@ bool vkd3d_get_program_name(char program_name[PATH_MAX]) name = program_invocation_name; }
- strncpy(program_name, name, PATH_MAX); - program_name[PATH_MAX - 1] = '\0'; + strncpy(program_name, name, VKD3D_PATH_MAX); + program_name[VKD3D_PATH_MAX - 1] = '\0'; free(real_path); return true; }
#else
-bool vkd3d_get_program_name(char program_name[PATH_MAX]) +bool vkd3d_get_program_name(char program_name[VKD3D_PATH_MAX]) { *program_name = '\0'; return false; diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 84b5ff2..76ce709 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -31,11 +31,11 @@
#include "vkd3d.h" #include "vkd3d_shader.h" +#include "vkd3d_threads.h"
#include <assert.h> #include <inttypes.h> #include <limits.h> -#include <pthread.h> #include <stdbool.h>
#define VK_CALL(f) (vk_procs->f) @@ -1271,16 +1271,13 @@ HRESULT vkd3d_load_vk_device_procs(struct vkd3d_vk_device_procs *procs,
extern const char vkd3d_build[];
-bool vkd3d_get_program_name(char program_name[PATH_MAX]) DECLSPEC_HIDDEN; - -static inline void vkd3d_set_thread_name(const char *name) -{ -#if defined(HAVE_PTHREAD_SETNAME_NP_2) - pthread_setname_np(pthread_self(), name); -#elif defined(HAVE_PTHREAD_SETNAME_NP_1) - pthread_setname_np(name); +#ifdef _WIN32 +/* This value isn't really used for anything useful on Windows, just need some kind of value. */ +#define VKD3D_PATH_MAX _MAX_PATH +#else +#define VKD3D_PATH_MAX PATH_MAX #endif -} +bool vkd3d_get_program_name(char program_name[VKD3D_PATH_MAX]) DECLSPEC_HIDDEN;
VkResult vkd3d_set_vk_object_name_utf8(struct d3d12_device *device, uint64_t vk_object, VkDebugReportObjectTypeEXT vk_object_type, const char *name) DECLSPEC_HIDDEN;
Useful to be able to run unit tests on Windows.
Signed-off-by: Hans-Kristian Arntzen post@arntzen-software.no --- libs/vkd3d-utils/vkd3d_utils_main.c | 1 + libs/vkd3d-utils/vkd3d_utils_private.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-utils/vkd3d_utils_main.c b/libs/vkd3d-utils/vkd3d_utils_main.c index d06a750..0e7ac21 100644 --- a/libs/vkd3d-utils/vkd3d_utils_main.c +++ b/libs/vkd3d-utils/vkd3d_utils_main.c @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#include "vkd3d_common.h" #include "vkd3d_utils_private.h"
VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG"); diff --git a/libs/vkd3d-utils/vkd3d_utils_private.h b/libs/vkd3d-utils/vkd3d_utils_private.h index 6b5851e..e3ed921 100644 --- a/libs/vkd3d-utils/vkd3d_utils_private.h +++ b/libs/vkd3d-utils/vkd3d_utils_private.h @@ -23,7 +23,7 @@ #define NONAMELESSUNION #define VK_NO_PROTOTYPES
-#include <pthread.h> +#include "vkd3d_threads.h" #include <vkd3d.h>
#include "vkd3d_memory.h"
When testing vkd3d on Windows, we were only able to use the native D3D12 path. Add an ifdef to configure this.
Signed-off-by: Hans-Kristian Arntzen post@arntzen-software.no --- tests/d3d12_crosstest.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tests/d3d12_crosstest.h b/tests/d3d12_crosstest.h index 7b59471..7592000 100644 --- a/tests/d3d12_crosstest.h +++ b/tests/d3d12_crosstest.h @@ -52,17 +52,17 @@ typedef int HRESULT; #include <math.h> #include <time.h>
-#ifdef _WIN32 +#if defined(_WIN32) && !defined(VKD3D_FORCE_UTILS_WRAPPER) # include "vkd3d_dxgi1_4.h" #else -# include <pthread.h> +# include "vkd3d_threads.h" # include "vkd3d.h" # include "vkd3d_utils.h" #endif
#include "d3d12_test_utils.h"
-#ifdef _WIN32 +#if defined(_WIN32) && !defined(VKD3D_FORCE_UTILS_WRAPPER) static inline HANDLE create_event(void) { return CreateEventA(NULL, FALSE, FALSE, NULL); @@ -124,7 +124,7 @@ struct test_thread_data void *user_data; };
-#ifdef _WIN32 +#if defined(_WIN32) && !defined(VKD3D_FORCE_UTILS_WRAPPER) static inline DWORD WINAPI test_thread_main(void *untyped_data) { struct test_thread_data *data = untyped_data; @@ -242,7 +242,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 +#if defined(_WIN32) && !defined(VKD3D_FORCE_UTILS_WRAPPER) static IUnknown *create_warp_adapter(IDXGIFactory4 *factory) { IUnknown *adapter;
On Mon, 18 Nov 2019 at 18:14, Hans-Kristian Arntzen post@arntzen-software.no wrote:
When testing vkd3d on Windows, we were only able to use the native D3D12 path. Add an ifdef to configure this.
I'm not against this in principle, but you'd have to properly integrate it into the build system.
On Windows, it is not ideal to rely on Vulkan being available as a linkable library as a full install of the Vulkan SDK must be present and set up, be friendly and load Vulkan dynamically instead.
Signed-off-by: Hans-Kristian Arntzen post@arntzen-software.no --- libs/vkd3d/device.c | 22 +++++++++++++ tests/d3d12_crosstest.h | 70 +++++++++++++++++++++++++++++++++++------ 2 files changed, 83 insertions(+), 9 deletions(-)
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index cc8e282..f2f1aca 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -40,6 +40,28 @@ static const char *vkd3d_dlerror(void) { return dlerror(); } +#elif defined(_WIN32) +#include <windows.h> +static void *vkd3d_dlopen(const char *name) +{ + return LoadLibraryA(name); +} + +static void *vkd3d_dlsym(void *handle, const char *symbol) +{ + return GetProcAddress(handle, symbol); +} + +static int vkd3d_dlclose(void *handle) +{ + FreeLibrary(handle); + return 0; +} + +static const char *vkd3d_dlerror(void) +{ + return "Not implemented for this platform.\n"; +} #else static void *vkd3d_dlopen(const char *name) { diff --git a/tests/d3d12_crosstest.h b/tests/d3d12_crosstest.h index 7592000..1bf8976 100644 --- a/tests/d3d12_crosstest.h +++ b/tests/d3d12_crosstest.h @@ -60,6 +60,10 @@ typedef int HRESULT; # include "vkd3d_utils.h" #endif
+#if !defined(_WIN32) +#include <dlfcn.h> +#endif + #include "d3d12_test_utils.h"
#if defined(_WIN32) && !defined(VKD3D_FORCE_UTILS_WRAPPER) @@ -401,7 +405,39 @@ static inline bool is_depth_clip_enable_supported(ID3D12Device *device)
#else
-static bool check_device_extension(VkPhysicalDevice vk_physical_device, const char *name) +static PFN_vkGetInstanceProcAddr pfn_vkGetInstanceProcAddr; +static bool init_vulkan_loader(void) +{ + if (pfn_vkGetInstanceProcAddr) + return true; + +#ifdef _WIN32 + HMODULE mod = LoadLibrary(SONAME_LIBVULKAN); + if (!mod) + return false; + + pfn_vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)GetProcAddress(mod, "vkGetInstanceProcAddr"); +#else + void *mod = dlopen(SONAME_LIBVULKAN, RTLD_LAZY); + if (!mod) + return false; + + pfn_vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(mod, "vkGetInstanceProcAddr"); +#endif + + return pfn_vkGetInstanceProcAddr != NULL; +} + +#define get_vk_instance_proc(instance, sym) (PFN_##sym)get_vk_instance_proc_(instance, #sym) +static PFN_vkVoidFunction get_vk_instance_proc_(VkInstance instance, const char *sym) +{ + if (!init_vulkan_loader()) + return NULL; + + return pfn_vkGetInstanceProcAddr(instance, sym); +} + +static bool check_device_extension(VkInstance instance, VkPhysicalDevice vk_physical_device, const char *name) { VkExtensionProperties *properties; bool ret = false; @@ -409,7 +445,12 @@ static bool check_device_extension(VkPhysicalDevice vk_physical_device, const ch uint32_t count; VkResult vr;
- vr = vkEnumerateDeviceExtensionProperties(vk_physical_device, NULL, &count, NULL); + PFN_vkEnumerateDeviceExtensionProperties pfn_vkEnumerateDeviceExtensionProperties; + pfn_vkEnumerateDeviceExtensionProperties = get_vk_instance_proc(instance, vkEnumerateDeviceExtensionProperties); + if (!pfn_vkEnumerateDeviceExtensionProperties) + return false; + + vr = pfn_vkEnumerateDeviceExtensionProperties(vk_physical_device, NULL, &count, NULL); ok(vr == VK_SUCCESS, "Got unexpected VkResult %d.\n", vr); if (!count) return false; @@ -417,7 +458,7 @@ static bool check_device_extension(VkPhysicalDevice vk_physical_device, const ch properties = calloc(count, sizeof(*properties)); ok(properties, "Failed to allocate memory.\n");
- vr = vkEnumerateDeviceExtensionProperties(vk_physical_device, NULL, &count, properties); + vr = pfn_vkEnumerateDeviceExtensionProperties(vk_physical_device, NULL, &count, properties); ok(vr == VK_SUCCESS, "Got unexpected VkResult %d.\n", vr); for (i = 0; i < count; ++i) { @@ -463,10 +504,14 @@ static VkPhysicalDevice select_physical_device(struct vkd3d_instance *instance) VkInstance vk_instance; uint32_t count; VkResult vr; - + PFN_vkEnumeratePhysicalDevices pfn_vkEnumeratePhysicalDevices; vk_instance = vkd3d_instance_get_vk_instance(instance);
- vr = vkEnumeratePhysicalDevices(vk_instance, &count, NULL); + pfn_vkEnumeratePhysicalDevices = get_vk_instance_proc(vk_instance, vkEnumeratePhysicalDevices); + if (!pfn_vkEnumeratePhysicalDevices) + return VK_NULL_HANDLE; + + vr = pfn_vkEnumeratePhysicalDevices(vk_instance, &count, NULL); ok(vr == VK_SUCCESS, "Got unexpected VkResult %d.\n", vr);
if (use_adapter_idx >= count) @@ -477,7 +522,7 @@ static VkPhysicalDevice select_physical_device(struct vkd3d_instance *instance)
vk_physical_devices = calloc(count, sizeof(*vk_physical_devices)); ok(vk_physical_devices, "Failed to allocate memory.\n"); - vr = vkEnumeratePhysicalDevices(vk_instance, &count, vk_physical_devices); + vr = pfn_vkEnumeratePhysicalDevices(vk_instance, &count, vk_physical_devices); ok(vr == VK_SUCCESS, "Got unexpected VkResult %d.\n", vr);
vk_physical_device = vk_physical_devices[use_adapter_idx]; @@ -537,19 +582,24 @@ static bool get_driver_properties(ID3D12Device *device, VkPhysicalDeviceDriverPr PFN_vkGetPhysicalDeviceProperties2KHR pfn_vkGetPhysicalDeviceProperties2KHR; VkPhysicalDeviceProperties2 device_properties2; VkPhysicalDevice vk_physical_device; + VkInstance vk_instance;
memset(driver_properties, 0, sizeof(*driver_properties)); driver_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR;
vk_physical_device = vkd3d_get_vk_physical_device(device); + vk_instance = vkd3d_instance_get_vk_instance(vkd3d_instance_from_device(device)); + + if (!init_vulkan_loader()) + return false;
- if (check_device_extension(vk_physical_device, VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME)) + if (check_device_extension(vk_instance, vk_physical_device, VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME)) { struct vkd3d_instance *instance = vkd3d_instance_from_device(device); VkInstance vk_instance = vkd3d_instance_get_vk_instance(instance);
pfn_vkGetPhysicalDeviceProperties2KHR - = (void *)vkGetInstanceProcAddr(vk_instance, "vkGetPhysicalDeviceProperties2KHR"); + = (void *)pfn_vkGetInstanceProcAddr(vk_instance, "vkGetPhysicalDeviceProperties2KHR"); ok(pfn_vkGetPhysicalDeviceProperties2KHR, "vkGetPhysicalDeviceProperties2KHR is NULL.\n");
memset(&device_properties2, 0, sizeof(device_properties2)); @@ -628,8 +678,10 @@ static inline bool is_radv_device(ID3D12Device *device)
static inline bool is_depth_clip_enable_supported(ID3D12Device *device) { + struct vkd3d_instance *instance = vkd3d_instance_from_device(device); + VkInstance vk_instance = vkd3d_instance_get_vk_instance(instance); VkPhysicalDevice vk_physical_device = vkd3d_get_vk_physical_device(device); - return check_device_extension(vk_physical_device, VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME); + return check_device_extension(vk_instance, vk_physical_device, VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME); } #endif
On Mon, 18 Nov 2019 at 18:14, Hans-Kristian Arntzen post@arntzen-software.no wrote:
On Windows, it is not ideal to rely on Vulkan being available as a linkable library as a full install of the Vulkan SDK must be present and set up, be friendly and load Vulkan dynamically instead.
Is that an issue? I'd somewhat expect people doing Vulkan development to have the Vulkan SDK installed, but then, the last time I did serious software development on Windows is more than 15 years ago. You'd still need the headers in any case.
MinGW does not ship d3d12 properly, so link against d3d12.dll dynamically instead.
Signed-off-by: Hans-Kristian Arntzen post@arntzen-software.no --- tests/d3d12.c | 5 +++++ tests/d3d12_crosstest.h | 14 ++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index 0f843b4..e8a6261 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 { @@ -32356,6 +32358,9 @@ static void test_bufinfo_instruction(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 1bf8976..0fad48f 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);
On Mon, 18 Nov 2019 at 18:14, Hans-Kristian Arntzen post@arntzen-software.no wrote:
MinGW does not ship d3d12 properly, so link against d3d12.dll dynamically instead.
That's a fairly broad claim. What is the issue exactly?
On 11/18/19 4:36 PM, Henri Verbeet wrote:
On Mon, 18 Nov 2019 at 18:14, Hans-Kristian Arntzen post@arntzen-software.no wrote:
MinGW does not ship d3d12 properly, so link against d3d12.dll dynamically instead.
That's a fairly broad claim. What is the issue exactly?
There are no d3d12 headers or -ld3d12 available in MinGW-w64 on msys2 at least.
Cheers, Hans-Kristian
On Mon, 18 Nov 2019 at 20:24, Hans-Kristian Arntzen post@arntzen-software.no wrote:
There are no d3d12 headers or -ld3d12 available in MinGW-w64 on msys2 at least.
Vkd3d builds its own d3d12 import libraries, d3d12.cross32.a and d3d12.cross64.a, as part of the crosstest target.
On 11/18/19 6:17 PM, Henri Verbeet wrote:
On Mon, 18 Nov 2019 at 20:24, Hans-Kristian Arntzen post@arntzen-software.no wrote:
There are no d3d12 headers or -ld3d12 available in MinGW-w64 on msys2 at least.
Vkd3d builds its own d3d12 import libraries, d3d12.cross32.a and d3d12.cross64.a, as part of the crosstest target.
Sounds like we can remove those then? (This came up in a CMake build since autotools doesn't work when building on Windows.)
Cheers, Hans-Kristian
On 11/18/19 6:52 PM, Hans-Kristian Arntzen wrote:
On 11/18/19 6:17 PM, Henri Verbeet wrote:
On Mon, 18 Nov 2019 at 20:24, Hans-Kristian Arntzen post@arntzen-software.no wrote:
There are no d3d12 headers or -ld3d12 available in MinGW-w64 on msys2 at least.
Vkd3d builds its own d3d12 import libraries, d3d12.cross32.a and d3d12.cross64.a, as part of the crosstest target.
Sounds like we can remove those then? (This came up in a CMake build since autotools doesn't work when building on Windows.)
To clarify, it's mostly minor inconvenient things, and I need debugging in CLion/MSVC for some things, so ideally, I'd prefer a solution which can work without having to go through autotools, and dynamically loading d3d12 would make it simpler in all cases I think as there is no longer a reason to build stub import libraries.
Cheers, Hans-Kristian
On Mon, 18 Nov 2019 at 21:22, Hans-Kristian Arntzen post@arntzen-software.no wrote:
On 11/18/19 6:17 PM, Henri Verbeet wrote:
On Mon, 18 Nov 2019 at 20:24, Hans-Kristian Arntzen post@arntzen-software.no wrote:
There are no d3d12 headers or -ld3d12 available in MinGW-w64 on msys2 at least.
Vkd3d builds its own d3d12 import libraries, d3d12.cross32.a and d3d12.cross64.a, as part of the crosstest target.
Sounds like we can remove those then? (This came up in a CMake build since autotools doesn't work when building on Windows.)
No, that would break the demos. But ignoring that, an out-of-tree build system doesn't seem like a very good reason to make things uglier. I must say I'm slightly confused about what you're trying to do though. It's true that MSVC doesn't play all that well with autotools unless you use some kind of wrapper script like cccl, but this patch is supposed to be for MinGW-w64, which should work fine with autotools.
On Mon, 18 Nov 2019 at 21:46, Hans-Kristian Arntzen post@arntzen-software.no wrote:
To clarify, it's mostly minor inconvenient things, and I need debugging in CLion/MSVC for some things, so ideally, I'd prefer a solution which can work without having to go through autotools, and dynamically loading d3d12 would make it simpler in all cases I think as there is no longer a reason to build stub import libraries.
For the case where you're building with MSVC, the platform SDK comes with d3d12 import libraries of course, but I don't think MSVC should have an issue with building the vkd3d version of the import libraries either. If the only reason to use MSVC is PDB support though, it may be much easier to build with Clang instead, which should have PDB support as well these days.
On 11/20/19 11:48 AM, Henri Verbeet wrote:
On Mon, 18 Nov 2019 at 21:22, Hans-Kristian Arntzen post@arntzen-software.no wrote:
On 11/18/19 6:17 PM, Henri Verbeet wrote:
On Mon, 18 Nov 2019 at 20:24, Hans-Kristian Arntzen post@arntzen-software.no wrote:
There are no d3d12 headers or -ld3d12 available in MinGW-w64 on msys2 at least.
Vkd3d builds its own d3d12 import libraries, d3d12.cross32.a and d3d12.cross64.a, as part of the crosstest target.
Sounds like we can remove those then? (This came up in a CMake build since autotools doesn't work when building on Windows.)
No, that would break the demos. But ignoring that, an out-of-tree build system doesn't seem like a very good reason to make things uglier. I must say I'm slightly confused about what you're trying to do though. It's true that MSVC doesn't play all that well with autotools unless you use some kind of wrapper script like cccl, but this patch is supposed to be for MinGW-w64, which should work fine with autotools.
On Mon, 18 Nov 2019 at 21:46, Hans-Kristian Arntzen post@arntzen-software.no wrote:
To clarify, it's mostly minor inconvenient things, and I need debugging in CLion/MSVC for some things, so ideally, I'd prefer a solution which can work without having to go through autotools, and dynamically loading d3d12 would make it simpler in all cases I think as there is no longer a reason to build stub import libraries.
For the case where you're building with MSVC, the platform SDK comes with d3d12 import libraries of course, but I don't think MSVC should have an issue with building the vkd3d version of the import libraries either. If the only reason to use MSVC is PDB support though, it may be much easier to build with Clang instead, which should have PDB support as well these days.
I guess I'll just add the stub libraries to my build system instead.
Cheers, Hans-Kristian
On Mon, 18 Nov 2019 at 18:14, Hans-Kristian Arntzen post@arntzen-software.no wrote:
create mode 100644 include/private/vkd3d_threads.h
You'd have to add this to libvkd3d_la_SOURCES.
+#ifdef _WIN32 +/* This value isn't really used for anything useful on Windows, just need some kind of value. */ +#define VKD3D_PATH_MAX _MAX_PATH +#else +#define VKD3D_PATH_MAX PATH_MAX #endif
That looks like an unrelated change.
On 11/18/19 4:36 PM, Henri Verbeet wrote:
On Mon, 18 Nov 2019 at 18:14, Hans-Kristian Arntzen post@arntzen-software.no wrote:
create mode 100644 include/private/vkd3d_threads.h
You'd have to add this to libvkd3d_la_SOURCES.
+#ifdef _WIN32 +/* This value isn't really used for anything useful on Windows, just need some kind of value. */ +#define VKD3D_PATH_MAX _MAX_PATH +#else +#define VKD3D_PATH_MAX PATH_MAX #endif
That looks like an unrelated change.
Yes. Fallout from last rebase.
Cheers, Hans-Kristian