Roderick Colenbrander : winevulkan: Allow vkGetDeviceProcAddr to load instance functions for broken games.

Alexandre Julliard julliard at winehq.org
Thu Mar 15 19:12:12 CDT 2018


Module: wine
Branch: master
Commit: 76275505e0f05113b4be7851f2d877e1f1ee4cfc
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=76275505e0f05113b4be7851f2d877e1f1ee4cfc

Author: Roderick Colenbrander <thunderbird2k at gmail.com>
Date:   Thu Mar 15 10:26:32 2018 +0100

winevulkan: Allow vkGetDeviceProcAddr to load instance functions for broken games.

Doom and Wolfenstein II use vkGetDeviceProcAddr to load all their function pointers,
while they are supposed to use vkGetInstanceProcAddr for the instance ones.
For now we need to allow this broken behavior.

Signed-off-by: Roderick Colenbrander <thunderbird2k at gmail.com>
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winevulkan/vulkan.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c
index c0fc810..5062701 100644
--- a/dlls/winevulkan/vulkan.c
+++ b/dlls/winevulkan/vulkan.c
@@ -902,7 +902,26 @@ PFN_vkVoidFunction WINAPI wine_vkGetDeviceProcAddr(VkDevice device, const char *
     if (func)
         return func;
 
-    TRACE("Function %s not found\n", debugstr_a(name));
+    /* vkGetDeviceProcAddr was intended for loading device and subdevice functions.
+     * idTech 6 titles such as Doom and Wolfenstein II, however use it also for
+     * loading of instance functions. This is undefined behavior as the specification
+     * disallows using any of the returned function pointers outside of device /
+     * subdevice objects. The games don't actually use the function pointers and if they
+     * did, they would crash as VkInstance / VkPhysicalDevice parameters need unwrapping.
+     * Khronos clarified behavior in the Vulkan spec and expects drivers to get updated,
+     * however it would require both driver and game fixes. Since it are major titles
+     * it is not clear what will happen. At least for now we need the hack below.
+     * https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/issues/2323
+     * https://github.com/KhronosGroup/Vulkan-Docs/issues/655
+     */
+    func = wine_vk_get_instance_proc_addr(name);
+    if (func)
+    {
+        WARN("Returning instance function '%s'.\n", debugstr_a(name));
+        return func;
+    }
+
+    TRACE("Function %s not found.\n", debugstr_a(name));
     return NULL;
 }
 




More information about the wine-cvs mailing list