[RFC PATCH 9/9] winex11.drv: Thunk vkGetPhysicalDeviceProperties2 to report LUID.

Zhiyi Zhang zzhang at codeweavers.com
Tue Dec 18 10:22:40 CST 2018


Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
 dlls/vulkan-1/tests/vulkan.c |  4 +-
 dlls/winevulkan/make_vulkan  |  6 ++-
 dlls/winex11.drv/vulkan.c    | 81 ++++++++++++++++++++++++++++++++++++
 include/wine/vulkan_driver.h |  8 +++-
 4 files changed, 95 insertions(+), 4 deletions(-)

diff --git a/dlls/vulkan-1/tests/vulkan.c b/dlls/vulkan-1/tests/vulkan.c
index cb4d2e9e53..da3af11d4d 100644
--- a/dlls/vulkan-1/tests/vulkan.c
+++ b/dlls/vulkan-1/tests/vulkan.c
@@ -212,8 +212,8 @@ static void test_enumerate_physical_device2(void)
             trace("Device '%s', device UUID:%s, driver UUID:%s, device LUID:%08x:%08x\n",
                   properties2.properties.deviceName, wine_dbgstr_guid((const GUID *)id.deviceUUID),
                   wine_dbgstr_guid((const GUID *)id.driverUUID), luid->HighPart, luid->LowPart);
-            todo_wine ok(id.deviceLUIDValid == VK_TRUE, "Expect valid device LUID \n");
-            todo_wine ok(id.deviceNodeMask == 1, "Expect device node mask %08x, got %08x\n", 1, id.deviceNodeMask);
+            ok(id.deviceLUIDValid == VK_TRUE, "Expect valid device LUID \n");
+            ok(id.deviceNodeMask == 1, "Expect device node mask %08x, got %08x\n", 1, id.deviceNodeMask);
         }
     }
 
diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan
index 960417d428..99c44d420e 100755
--- a/dlls/winevulkan/make_vulkan
+++ b/dlls/winevulkan/make_vulkan
@@ -133,7 +133,7 @@ CORE_EXTENSIONS = [
 # Functions part of our winevulkan graphics driver interface.
 # DRIVER_VERSION should be bumped on any change to driver interface
 # in FUNCTION_OVERRIDES
-DRIVER_VERSION = 7
+DRIVER_VERSION = 8
 
 # Table of functions for which we have a special implementation.
 # These are regular device / instance functions for which we need
@@ -167,8 +167,12 @@ FUNCTION_OVERRIDES = {
     "vkGetDeviceProcAddr" : {"dispatch" : False, "driver" : True, "thunk" : False},
     "vkGetDeviceQueue" : {"dispatch": True, "driver" : False, "thunk" : False},
     "vkGetDeviceQueue2" : {"dispatch": True, "driver" : False, "thunk" : False},
+    "vkGetPhysicalDeviceProperties2": {"dispatch" : True, "driver" : True, "thunk" : True},
     "vkQueueSubmit" : {"dispatch": True, "driver" : False, "thunk" : False},
 
+    # VK_KHR_get_physical_device_properties2
+    "vkGetPhysicalDeviceProperties2KHR": {"dispatch" : True, "driver" : True, "thunk" : True},
+
     # VK_KHR_surface
     "vkDestroySurfaceKHR" : {"dispatch" : True, "driver" : True, "thunk" : True},
     "vkGetPhysicalDeviceSurfaceSupportKHR" : {"dispatch" : True, "driver" : True, "thunk" : True},
diff --git a/dlls/winex11.drv/vulkan.c b/dlls/winex11.drv/vulkan.c
index 28ae1a9e0e..c99a89e388 100644
--- a/dlls/winex11.drv/vulkan.c
+++ b/dlls/winex11.drv/vulkan.c
@@ -28,6 +28,10 @@
 
 #include "windef.h"
 #include "winbase.h"
+#include "winuser.h"
+#include "winreg.h"
+#include "devguid.h"
+#include "setupapi.h"
 
 #include "wine/debug.h"
 #include "wine/heap.h"
@@ -56,6 +60,9 @@ static CRITICAL_SECTION context_section = { &critsect_debug, -1, 0, 0, 0, 0 };
 
 static XContext vulkan_hwnd_context;
 
+extern const DEVPROPKEY DEVPROPKEY_DISPLAY_ADAPTER_LUID;
+extern const DEVPROPKEY DEVPROPKEY_DISPLAY_ADAPTER_UUID;
+
 #define VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR 1000004000
 
 struct wine_vk_surface
@@ -65,6 +72,13 @@ struct wine_vk_surface
     VkSurfaceKHR surface; /* native surface */
 };
 
+/* All Vulkan structures use this structure for the first elements. */
+struct wine_vk_structure_header
+{
+    VkStructureType sType;
+    void *pNext;
+};
+
 typedef struct VkXlibSurfaceCreateInfoKHR
 {
     VkStructureType sType;
@@ -85,6 +99,7 @@ static VkResult (*pvkGetDeviceGroupSurfacePresentModesKHR)(VkDevice, VkSurfaceKH
 static void * (*pvkGetDeviceProcAddr)(VkDevice, const char *);
 static void * (*pvkGetInstanceProcAddr)(VkInstance, const char *);
 static VkResult (*pvkGetPhysicalDevicePresentRectanglesKHR)(VkPhysicalDevice, VkSurfaceKHR, uint32_t *, VkRect2D *);
+static void (*pvkGetPhysicalDeviceProperties2)(VkPhysicalDevice, VkPhysicalDeviceProperties2 *);
 static VkResult (*pvkGetPhysicalDeviceSurfaceCapabilitiesKHR)(VkPhysicalDevice, VkSurfaceKHR, VkSurfaceCapabilitiesKHR *);
 static VkResult (*pvkGetPhysicalDeviceSurfaceFormatsKHR)(VkPhysicalDevice, VkSurfaceKHR, uint32_t *, VkSurfaceFormatKHR *);
 static VkResult (*pvkGetPhysicalDeviceSurfacePresentModesKHR)(VkPhysicalDevice, VkSurfaceKHR, uint32_t *, VkPresentModeKHR *);
@@ -131,6 +146,7 @@ static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context)
     LOAD_FUNCPTR(vkQueuePresentKHR)
     LOAD_OPTIONAL_FUNCPTR(vkGetDeviceGroupSurfacePresentModesKHR)
     LOAD_OPTIONAL_FUNCPTR(vkGetPhysicalDevicePresentRectanglesKHR)
+    LOAD_OPTIONAL_FUNCPTR(vkGetPhysicalDeviceProperties2)
 #undef LOAD_FUNCPTR
 #undef LOAD_OPTIONAL_FUNCPTR
 
@@ -544,6 +560,69 @@ static VkResult X11DRV_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *
     return res;
 }
 
+static BOOL wine_get_adapter_luid(const GUID *uuid, LUID *luid)
+{
+    HDEVINFO devinfo;
+    SP_DEVINFO_DATA devinfo_data = {sizeof(SP_DEVINFO_DATA)};
+    DEVPROPTYPE property_type;
+    GUID result;
+    UINT i;
+
+    devinfo = SetupDiGetClassDevsW(&GUID_DEVCLASS_DISPLAY, NULL, NULL, DIGCF_PRESENT);
+    if (devinfo == INVALID_HANDLE_VALUE)
+        return FALSE;
+
+    for (i = 0; SetupDiEnumDeviceInfo(devinfo, i, &devinfo_data); ++i)
+    {
+        property_type = DEVPROP_TYPE_UINT64;
+        if (!SetupDiGetDevicePropertyW(devinfo, &devinfo_data, &DEVPROPKEY_DISPLAY_ADAPTER_UUID, &property_type,
+                                       (BYTE *)&result, sizeof(result), NULL, 0))
+            continue;
+
+        if (IsEqualGUID(&result, uuid))
+        {
+            if (SetupDiGetDevicePropertyW(devinfo, &devinfo_data, &DEVPROPKEY_DISPLAY_ADAPTER_LUID, &property_type,
+                                          (BYTE *)luid, sizeof(*luid), NULL, 0))
+                return TRUE;
+        }
+    }
+
+    return FALSE;
+}
+
+static void wine_fill_physical_device_id_luid(VkPhysicalDeviceProperties2 *properties)
+{
+    VkPhysicalDeviceIDProperties *id;
+    struct wine_vk_structure_header *header;
+    
+    if (!properties->pNext)
+        return;
+    
+    for (header = properties->pNext; header; header = header->pNext)
+    {
+        if (header->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES)
+        {
+            id = (VkPhysicalDeviceIDProperties *)header;
+            if (wine_get_adapter_luid((const GUID *)id->deviceUUID, (LUID *)id->deviceLUID))
+            {
+                id->deviceNodeMask = 1;
+                id->deviceLUIDValid = VK_TRUE;
+            }
+        }
+    }
+}
+
+static void X11DRV_vkGetPhysicalDeviceProperties2(VkPhysicalDevice phys_dev, VkPhysicalDeviceProperties2 *properties)
+{
+    pvkGetPhysicalDeviceProperties2(phys_dev, properties);
+    wine_fill_physical_device_id_luid(properties);
+}
+
+static void X11DRV_vkGetPhysicalDeviceProperties2KHR(VkPhysicalDevice phys_dev, VkPhysicalDeviceProperties2 *properties)
+{
+    X11DRV_vkGetPhysicalDeviceProperties2(phys_dev, properties);
+}
+
 static const struct vulkan_funcs vulkan_funcs =
 {
     X11DRV_vkCreateInstance,
@@ -557,6 +636,8 @@ static const struct vulkan_funcs vulkan_funcs =
     X11DRV_vkGetDeviceProcAddr,
     X11DRV_vkGetInstanceProcAddr,
     X11DRV_vkGetPhysicalDevicePresentRectanglesKHR,
+    X11DRV_vkGetPhysicalDeviceProperties2,
+    X11DRV_vkGetPhysicalDeviceProperties2KHR,
     X11DRV_vkGetPhysicalDeviceSurfaceCapabilitiesKHR,
     X11DRV_vkGetPhysicalDeviceSurfaceFormatsKHR,
     X11DRV_vkGetPhysicalDeviceSurfacePresentModesKHR,
diff --git a/include/wine/vulkan_driver.h b/include/wine/vulkan_driver.h
index a5bc50325c..87ebd3d5a9 100644
--- a/include/wine/vulkan_driver.h
+++ b/include/wine/vulkan_driver.h
@@ -39,7 +39,7 @@
 #define __WINE_VULKAN_DRIVER_H
 
 /* Wine internal vulkan driver version, needs to be bumped upon vulkan_funcs changes. */
-#define WINE_VULKAN_DRIVER_VERSION 7
+#define WINE_VULKAN_DRIVER_VERSION 8
 
 struct vulkan_funcs
 {
@@ -58,6 +58,8 @@ struct vulkan_funcs
     void * (*p_vkGetDeviceProcAddr)(VkDevice, const char *);
     void * (*p_vkGetInstanceProcAddr)(VkInstance, const char *);
     VkResult (*p_vkGetPhysicalDevicePresentRectanglesKHR)(VkPhysicalDevice, VkSurfaceKHR, uint32_t *, VkRect2D *);
+    void (*p_vkGetPhysicalDeviceProperties2)(VkPhysicalDevice, VkPhysicalDeviceProperties2 *);
+    void (*p_vkGetPhysicalDeviceProperties2KHR)(VkPhysicalDevice, VkPhysicalDeviceProperties2 *);
     VkResult (*p_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)(VkPhysicalDevice, VkSurfaceKHR, VkSurfaceCapabilitiesKHR *);
     VkResult (*p_vkGetPhysicalDeviceSurfaceFormatsKHR)(VkPhysicalDevice, VkSurfaceKHR, uint32_t *, VkSurfaceFormatKHR *);
     VkResult (*p_vkGetPhysicalDeviceSurfacePresentModesKHR)(VkPhysicalDevice, VkSurfaceKHR, uint32_t *, VkPresentModeKHR *);
@@ -116,6 +118,10 @@ static inline void *get_vulkan_driver_instance_proc_addr(
         return vulkan_funcs->p_vkGetInstanceProcAddr;
     if (!strcmp(name, "GetPhysicalDevicePresentRectanglesKHR"))
         return vulkan_funcs->p_vkGetPhysicalDevicePresentRectanglesKHR;
+    if (!strcmp(name, "GetPhysicalDeviceProperties2"))
+        return vulkan_funcs->p_vkGetPhysicalDeviceProperties2;
+    if (!strcmp(name, "GetPhysicalDeviceProperties2KHR"))
+        return vulkan_funcs->p_vkGetPhysicalDeviceProperties2KHR;
     if (!strcmp(name, "GetPhysicalDeviceSurfaceCapabilitiesKHR"))
         return vulkan_funcs->p_vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
     if (!strcmp(name, "GetPhysicalDeviceSurfaceFormatsKHR"))
-- 
2.19.2




More information about the wine-devel mailing list