winevulkan: Move fill_luid_property and its callers to loader.c.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1cc6b4921a
commit
2d3309d854
|
@ -23,6 +23,9 @@
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
#include "winreg.h"
|
#include "winreg.h"
|
||||||
#include "winuser.h"
|
#include "winuser.h"
|
||||||
|
#include "initguid.h"
|
||||||
|
#include "devguid.h"
|
||||||
|
#include "setupapi.h"
|
||||||
|
|
||||||
#include "vulkan_private.h"
|
#include "vulkan_private.h"
|
||||||
|
|
||||||
|
@ -33,10 +36,27 @@ WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
|
||||||
*/
|
*/
|
||||||
#define WINE_VULKAN_ICD_VERSION 4
|
#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 HINSTANCE hinstance;
|
||||||
|
|
||||||
static void *wine_vk_get_global_proc_addr(const char *name);
|
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)
|
VkResult WINAPI wine_vkEnumerateInstanceLayerProperties(uint32_t *count, VkLayerProperties *properties)
|
||||||
{
|
{
|
||||||
TRACE("%p, %p\n", count, properties);
|
TRACE("%p, %p\n", count, properties);
|
||||||
|
@ -186,6 +206,95 @@ VkResult WINAPI wine_vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *supporte
|
||||||
return VK_SUCCESS;
|
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)
|
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, void *reserved)
|
||||||
{
|
{
|
||||||
TRACE("%p, %u, %p\n", hinst, reason, reserved);
|
TRACE("%p, %u, %p\n", hinst, reason, reserved);
|
||||||
|
|
|
@ -26,17 +26,11 @@
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
#include "winreg.h"
|
#include "winreg.h"
|
||||||
#include "winuser.h"
|
#include "winuser.h"
|
||||||
#include "initguid.h"
|
|
||||||
#include "devguid.h"
|
|
||||||
#include "setupapi.h"
|
|
||||||
|
|
||||||
#include "vulkan_private.h"
|
#include "vulkan_private.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
|
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)
|
#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)
|
static void *wine_vk_find_struct_(void *s, VkStructureType t)
|
||||||
{
|
{
|
||||||
|
@ -1525,95 +1519,6 @@ VkResult WINAPI wine_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(VkPhysicalDe
|
||||||
return res;
|
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,
|
void WINAPI wine_vkGetPhysicalDeviceExternalSemaphoreProperties(VkPhysicalDevice phys_dev,
|
||||||
const VkPhysicalDeviceExternalSemaphoreInfo *semaphore_info, VkExternalSemaphoreProperties *properties)
|
const VkPhysicalDeviceExternalSemaphoreInfo *semaphore_info, VkExternalSemaphoreProperties *properties)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue