diff --git a/meson.build b/meson.build index e4f56856..23e848ed 100644 --- a/meson.build +++ b/meson.build @@ -26,7 +26,7 @@ else endif if meson.get_cross_property('winelib', false) - lib_vulkan = declare_dependency(link_args: [ '-lvulkan-1' ]) + lib_vulkan = declare_dependency(link_args: [ '-lwinevulkan' ]) lib_d3d11 = declare_dependency(link_args: [ '-ld3d11' ]) lib_dxgi = declare_dependency(link_args: [ '-ldxgi' ]) lib_d3dcompiler_43 = declare_dependency(link_args: [ '-L'+dxvk_library_path, '-ld3dcompiler_43' ]) diff --git a/src/dxvk/vulkan/dxvk_vulkan_loader.cpp b/src/dxvk/vulkan/dxvk_vulkan_loader.cpp index 70df7aa4..d3a1ca11 100644 --- a/src/dxvk/vulkan/dxvk_vulkan_loader.cpp +++ b/src/dxvk/vulkan/dxvk_vulkan_loader.cpp @@ -1,9 +1,21 @@ #include "dxvk_vulkan_loader.h" namespace dxvk::vk { - + +#if defined(__WINE__) + + extern "C" + PFN_vkVoidFunction native_vkGetInstanceProcAddrWINE(VkInstance instance, const char *name); + static const PFN_vkGetInstanceProcAddr GetInstanceProcAddr = native_vkGetInstanceProcAddrWINE; + +#else + + static const PFN_vkGetInstanceProcAddr GetInstanceProcAddr = vkGetInstanceProcAddr; + +#endif + PFN_vkVoidFunction LibraryLoader::sym(const char* name) const { - return ::vkGetInstanceProcAddr(nullptr, name); + return dxvk::vk::GetInstanceProcAddr(nullptr, name); } @@ -12,13 +24,13 @@ namespace dxvk::vk { PFN_vkVoidFunction InstanceLoader::sym(const char* name) const { - return ::vkGetInstanceProcAddr(m_instance, name); + return dxvk::vk::GetInstanceProcAddr(m_instance, name); } DeviceLoader::DeviceLoader(VkInstance instance, VkDevice device) : m_getDeviceProcAddr(reinterpret_cast( - ::vkGetInstanceProcAddr(instance, "vkGetDeviceProcAddr"))), + dxvk::vk::GetInstanceProcAddr(instance, "vkGetDeviceProcAddr"))), m_device(device) { } diff --git a/src/dxvk/vulkan/dxvk_vulkan_loader_fn.h b/src/dxvk/vulkan/dxvk_vulkan_loader_fn.h index 105d0d9f..ecdd82a3 100644 --- a/src/dxvk/vulkan/dxvk_vulkan_loader_fn.h +++ b/src/dxvk/vulkan/dxvk_vulkan_loader_fn.h @@ -1,8 +1,23 @@ #pragma once +/* + * In 32-bit winelib build, alignment of Vulkan structures may be different than what + * native C++ compiler expects. Wine exposes an extension, intended for winelib + * applications, that exposes native Vulkan APIs with win32 additions, but using + * native ABI. + */ +#ifdef __WINE__ +#pragma push_macro("_WIN32") +#undef _WIN32 +#endif + #define VK_USE_PLATFORM_WIN32_KHR 1 #include +#ifdef __WINE__ +#pragma pop_macro("_WIN32") +#endif + #define VULKAN_FN(name) \ VulkanFn<::PFN_ ## name> name = sym(#name)