Georg Lehmann : winevulkan: Unwrap VkSurfaceKHR if required.

Alexandre Julliard julliard at winehq.org
Fri Jan 22 15:59:16 CST 2021


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

Author: Georg Lehmann <dadschoorse at gmail.com>
Date:   Fri Jan 22 18:31:57 2021 +0100

winevulkan: Unwrap VkSurfaceKHR if required.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50422
Signed-off-by: Georg Lehmann <dadschoorse at gmail.com>
Signed-off-by: Liam Middlebrook <lmiddlebrook at nvidia.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winevulkan/make_vulkan     | 12 ++++++++++--
 dlls/winevulkan/vulkan_thunks.c |  5 ++++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan
index 6242ddcce0b..40978a8fc7a 100755
--- a/dlls/winevulkan/make_vulkan
+++ b/dlls/winevulkan/make_vulkan
@@ -955,6 +955,8 @@ class VkHandle(object):
             return "wine_debug_utils_messenger_from_handle({0})->debug_messenger".format(name)
         if self.name == "VkDebugReportCallbackEXT":
             return "wine_debug_report_callback_from_handle({0})->debug_callback".format(name)
+        if self.name == "VkSurfaceKHR":
+            return "wine_surface_from_handle({0})->base.surface".format(name)
 
         native_handle_name = None
 
@@ -979,6 +981,8 @@ class VkHandle(object):
     def is_wrapped(self):
         return self.native_handle("test") is not None
 
+    def is_unwrapped_by_driver(self):
+        return self.name == "VkSurfaceKHR"
 
 class VkMember(object):
     def __init__(self, const=False, struct_fwd_decl=False,_type=None, pointer=None, name=None, array_len=None,
@@ -1601,8 +1605,12 @@ class VkParam(object):
             else:
                 return "&{0}_host".format(self.name)
         else:
-            # We need to pass the native handle to the native Vulkan calls.
-            native_handle = self.handle.native_handle(self.name) if self.is_handle() else None
+            # We need to pass the native handle to the native Vulkan calls unless
+            # the wine driver unwraps the handle for us.
+            if self.is_handle() and not self.handle.is_unwrapped_by_driver():
+                native_handle = self.handle.native_handle(self.name)
+            else:
+                native_handle = None
             return native_handle if native_handle else self.name
 
 
diff --git a/dlls/winevulkan/vulkan_thunks.c b/dlls/winevulkan/vulkan_thunks.c
index a0ddace9866..0ea713be6cf 100644
--- a/dlls/winevulkan/vulkan_thunks.c
+++ b/dlls/winevulkan/vulkan_thunks.c
@@ -7262,7 +7262,8 @@ BOOL wine_vk_is_type_wrapped(VkObjectType type)
         type == VK_OBJECT_TYPE_DEVICE ||
         type == VK_OBJECT_TYPE_INSTANCE ||
         type == VK_OBJECT_TYPE_PHYSICAL_DEVICE ||
-        type == VK_OBJECT_TYPE_QUEUE;
+        type == VK_OBJECT_TYPE_QUEUE ||
+        type == VK_OBJECT_TYPE_SURFACE_KHR;
 }
 
 uint64_t wine_vk_unwrap_handle(VkObjectType type, uint64_t handle)
@@ -7285,6 +7286,8 @@ uint64_t wine_vk_unwrap_handle(VkObjectType type, uint64_t handle)
         return (uint64_t) (uintptr_t) ((VkPhysicalDevice) (uintptr_t) handle)->phys_dev;
     case VK_OBJECT_TYPE_QUEUE:
         return (uint64_t) (uintptr_t) ((VkQueue) (uintptr_t) handle)->queue;
+    case VK_OBJECT_TYPE_SURFACE_KHR:
+        return (uint64_t) wine_surface_from_handle(handle)->base.surface;
     default:
        return handle;
     }




More information about the wine-cvs mailing list