Jacek Caban : winevulkan: Move fill_luid_property and its callers to loader.c.
Alexandre Julliard
julliard at winehq.org
Wed Apr 14 16:01:20 CDT 2021
Module: wine
Branch: master
Commit: 2d3309d85491d14d6632cc5818e8a7270d75be9e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=2d3309d85491d14d6632cc5818e8a7270d75be9e
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Apr 14 17:58:34 2021 +0200
winevulkan: Move fill_luid_property and its callers to loader.c.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winevulkan/loader.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++
dlls/winevulkan/vulkan.c | 95 -----------------------------------------
2 files changed, 109 insertions(+), 95 deletions(-)
diff --git a/dlls/winevulkan/loader.c b/dlls/winevulkan/loader.c
index 199349b98c2..0966e2d9468 100644
--- a/dlls/winevulkan/loader.c
+++ b/dlls/winevulkan/loader.c
@@ -23,6 +23,9 @@
#include "winbase.h"
#include "winreg.h"
#include "winuser.h"
+#include "initguid.h"
+#include "devguid.h"
+#include "setupapi.h"
#include "vulkan_private.h"
@@ -33,10 +36,27 @@ WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
*/
#define WINE_VULKAN_ICD_VERSION 4
+DEFINE_DEVPROPKEY(DEVPROPKEY_GPU_LUID, 0x60b193cb, 0x5276, 0x4d0f, 0x96, 0xfc, 0xf1, 0x73, 0xab, 0xad, 0x3e, 0xc6, 2);
+DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_GPU_VULKAN_UUID, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5c, 2);
+
static HINSTANCE hinstance;
static void *wine_vk_get_global_proc_addr(const char *name);
+#define wine_vk_find_struct(s, t) wine_vk_find_struct_((void *)s, VK_STRUCTURE_TYPE_##t)
+static void *wine_vk_find_struct_(void *s, VkStructureType t)
+{
+ VkBaseOutStructure *header;
+
+ for (header = s; header; header = header->pNext)
+ {
+ if (header->sType == t)
+ return header;
+ }
+
+ return NULL;
+}
+
VkResult WINAPI wine_vkEnumerateInstanceLayerProperties(uint32_t *count, VkLayerProperties *properties)
{
TRACE("%p, %p\n", count, properties);
@@ -186,6 +206,95 @@ VkResult WINAPI wine_vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *supporte
return VK_SUCCESS;
}
+static HANDLE get_display_device_init_mutex(void)
+{
+ static const WCHAR init_mutexW[] = {'d','i','s','p','l','a','y','_','d','e','v','i','c','e','_','i','n','i','t',0};
+ HANDLE mutex = CreateMutexW(NULL, FALSE, init_mutexW);
+
+ WaitForSingleObject(mutex, INFINITE);
+ return mutex;
+}
+
+static void release_display_device_init_mutex(HANDLE mutex)
+{
+ ReleaseMutex(mutex);
+ CloseHandle(mutex);
+}
+
+/* Wait until graphics driver is loaded by explorer */
+static void wait_graphics_driver_ready(void)
+{
+ static BOOL ready = FALSE;
+
+ if (!ready)
+ {
+ SendMessageW(GetDesktopWindow(), WM_NULL, 0, 0);
+ ready = TRUE;
+ }
+}
+
+static void fill_luid_property(VkPhysicalDeviceProperties2 *properties2)
+{
+ static const WCHAR pci[] = {'P','C','I',0};
+ VkPhysicalDeviceIDProperties *id;
+ SP_DEVINFO_DATA device_data;
+ DWORD type, device_idx = 0;
+ HDEVINFO devinfo;
+ HANDLE mutex;
+ GUID uuid;
+ LUID luid;
+
+ if (!(id = wine_vk_find_struct(properties2, PHYSICAL_DEVICE_ID_PROPERTIES)))
+ return;
+
+ wait_graphics_driver_ready();
+ mutex = get_display_device_init_mutex();
+ devinfo = SetupDiGetClassDevsW(&GUID_DEVCLASS_DISPLAY, pci, NULL, 0);
+ device_data.cbSize = sizeof(device_data);
+ while (SetupDiEnumDeviceInfo(devinfo, device_idx++, &device_data))
+ {
+ if (!SetupDiGetDevicePropertyW(devinfo, &device_data, &WINE_DEVPROPKEY_GPU_VULKAN_UUID,
+ &type, (BYTE *)&uuid, sizeof(uuid), NULL, 0))
+ continue;
+
+ if (!IsEqualGUID(&uuid, id->deviceUUID))
+ continue;
+
+ if (SetupDiGetDevicePropertyW(devinfo, &device_data, &DEVPROPKEY_GPU_LUID, &type,
+ (BYTE *)&luid, sizeof(luid), NULL, 0))
+ {
+ memcpy(&id->deviceLUID, &luid, sizeof(id->deviceLUID));
+ id->deviceLUIDValid = VK_TRUE;
+ id->deviceNodeMask = 1;
+ break;
+ }
+ }
+ SetupDiDestroyDeviceInfoList(devinfo);
+ release_display_device_init_mutex(mutex);
+
+ TRACE("deviceName:%s deviceLUIDValid:%d LUID:%08x:%08x deviceNodeMask:%#x.\n",
+ properties2->properties.deviceName, id->deviceLUIDValid, luid.HighPart, luid.LowPart,
+ id->deviceNodeMask);
+}
+
+void WINAPI wine_vkGetPhysicalDeviceProperties2(VkPhysicalDevice phys_dev,
+ VkPhysicalDeviceProperties2 *properties2)
+{
+ TRACE("%p, %p\n", phys_dev, properties2);
+
+ thunk_vkGetPhysicalDeviceProperties2(phys_dev, properties2);
+ fill_luid_property(properties2);
+}
+
+void WINAPI wine_vkGetPhysicalDeviceProperties2KHR(VkPhysicalDevice phys_dev,
+ VkPhysicalDeviceProperties2 *properties2)
+{
+ TRACE("%p, %p\n", phys_dev, properties2);
+
+ thunk_vkGetPhysicalDeviceProperties2KHR(phys_dev, properties2);
+ fill_luid_property(properties2);
+}
+
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, void *reserved)
{
TRACE("%p, %u, %p\n", hinst, reason, reserved);
diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c
index 8f65da35f52..fbcbe4721a3 100644
--- a/dlls/winevulkan/vulkan.c
+++ b/dlls/winevulkan/vulkan.c
@@ -26,17 +26,11 @@
#include "winbase.h"
#include "winreg.h"
#include "winuser.h"
-#include "initguid.h"
-#include "devguid.h"
-#include "setupapi.h"
#include "vulkan_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
-DEFINE_DEVPROPKEY(DEVPROPKEY_GPU_LUID, 0x60b193cb, 0x5276, 0x4d0f, 0x96, 0xfc, 0xf1, 0x73, 0xab, 0xad, 0x3e, 0xc6, 2);
-DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_GPU_VULKAN_UUID, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5c, 2);
-
#define wine_vk_find_struct(s, t) wine_vk_find_struct_((void *)s, VK_STRUCTURE_TYPE_##t)
static void *wine_vk_find_struct_(void *s, VkStructureType t)
{
@@ -1525,95 +1519,6 @@ VkResult WINAPI wine_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(VkPhysicalDe
return res;
}
-static HANDLE get_display_device_init_mutex(void)
-{
- static const WCHAR init_mutexW[] = {'d','i','s','p','l','a','y','_','d','e','v','i','c','e','_','i','n','i','t',0};
- HANDLE mutex = CreateMutexW(NULL, FALSE, init_mutexW);
-
- WaitForSingleObject(mutex, INFINITE);
- return mutex;
-}
-
-static void release_display_device_init_mutex(HANDLE mutex)
-{
- ReleaseMutex(mutex);
- CloseHandle(mutex);
-}
-
-/* Wait until graphics driver is loaded by explorer */
-static void wait_graphics_driver_ready(void)
-{
- static BOOL ready = FALSE;
-
- if (!ready)
- {
- SendMessageW(GetDesktopWindow(), WM_NULL, 0, 0);
- ready = TRUE;
- }
-}
-
-static void fill_luid_property(VkPhysicalDeviceProperties2 *properties2)
-{
- static const WCHAR pci[] = {'P','C','I',0};
- VkPhysicalDeviceIDProperties *id;
- SP_DEVINFO_DATA device_data;
- DWORD type, device_idx = 0;
- HDEVINFO devinfo;
- HANDLE mutex;
- GUID uuid;
- LUID luid;
-
- if (!(id = wine_vk_find_struct(properties2, PHYSICAL_DEVICE_ID_PROPERTIES)))
- return;
-
- wait_graphics_driver_ready();
- mutex = get_display_device_init_mutex();
- devinfo = SetupDiGetClassDevsW(&GUID_DEVCLASS_DISPLAY, pci, NULL, 0);
- device_data.cbSize = sizeof(device_data);
- while (SetupDiEnumDeviceInfo(devinfo, device_idx++, &device_data))
- {
- if (!SetupDiGetDevicePropertyW(devinfo, &device_data, &WINE_DEVPROPKEY_GPU_VULKAN_UUID,
- &type, (BYTE *)&uuid, sizeof(uuid), NULL, 0))
- continue;
-
- if (!IsEqualGUID(&uuid, id->deviceUUID))
- continue;
-
- if (SetupDiGetDevicePropertyW(devinfo, &device_data, &DEVPROPKEY_GPU_LUID, &type,
- (BYTE *)&luid, sizeof(luid), NULL, 0))
- {
- memcpy(&id->deviceLUID, &luid, sizeof(id->deviceLUID));
- id->deviceLUIDValid = VK_TRUE;
- id->deviceNodeMask = 1;
- break;
- }
- }
- SetupDiDestroyDeviceInfoList(devinfo);
- release_display_device_init_mutex(mutex);
-
- TRACE("deviceName:%s deviceLUIDValid:%d LUID:%08x:%08x deviceNodeMask:%#x.\n",
- properties2->properties.deviceName, id->deviceLUIDValid, luid.HighPart, luid.LowPart,
- id->deviceNodeMask);
-}
-
-void WINAPI wine_vkGetPhysicalDeviceProperties2(VkPhysicalDevice phys_dev,
- VkPhysicalDeviceProperties2 *properties2)
-{
- TRACE("%p, %p\n", phys_dev, properties2);
-
- thunk_vkGetPhysicalDeviceProperties2(phys_dev, properties2);
- fill_luid_property(properties2);
-}
-
-void WINAPI wine_vkGetPhysicalDeviceProperties2KHR(VkPhysicalDevice phys_dev,
- VkPhysicalDeviceProperties2 *properties2)
-{
- TRACE("%p, %p\n", phys_dev, properties2);
-
- thunk_vkGetPhysicalDeviceProperties2KHR(phys_dev, properties2);
- fill_luid_property(properties2);
-}
-
void WINAPI wine_vkGetPhysicalDeviceExternalSemaphoreProperties(VkPhysicalDevice phys_dev,
const VkPhysicalDeviceExternalSemaphoreInfo *semaphore_info, VkExternalSemaphoreProperties *properties)
{
More information about the wine-cvs
mailing list