From 3642377ce7111221a9b20549352489ada2a3d392 Mon Sep 17 00:00:00 2001 From: Roderick Colenbrander Date: Mon, 15 Jan 2018 15:51:35 -0800 Subject: [PATCH] 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. This is in violation of the Vulkan spec, but so far the loader allows this, but Khronos is thinking about fixing the spec and potentially the loader. https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/issues/2323 --- dlls/winevulkan/vulkan.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index 92e5c369c0..4ee0942244 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -681,6 +681,21 @@ PFN_vkVoidFunction WINAPI wine_vkGetDeviceProcAddr(VkDevice device, const char * if (func) return func; + /* vkGetDeviceProcAddr was intended for loading device and subdevice functions. Doom and Wolfenstein + * however use it also for loading of instance functions. This is undefined behavior as the specification + * clearly disallows using any of the returned function pointers outside of device / subdevice objects. + * Khronos recognizes the issue and is addressing the spec. The mentioned games may get updated. If they + * do we could remove 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(pName); + if (func) + { + WARN("Application relies on undefined behavior by requesting instance function '%s'!\n", pName); + return func; + } + TRACE("Function %s not found\n", pName); return NULL; }