wineopenxr: Propagate vulkan device IDs from steam.exe to the application.

This commit is contained in:
Yuxuan Shui 2024-05-01 14:47:57 +01:00 committed by Arkadiusz Hiler
parent c35598bb21
commit 22fa6c7346
2 changed files with 35 additions and 9 deletions

View file

@ -682,7 +682,7 @@ static void *get_winevulkan_unix_lib_handle(HMODULE hvulkan)
static DWORD WINAPI initialize_vr_data(void *arg) static DWORD WINAPI initialize_vr_data(void *arg)
{ {
int (WINAPI *p__wineopenxr_get_extensions_internal)(char **instance_extensions, char **device_extensions); int (WINAPI *p__wineopenxr_get_extensions_internal)(char **instance_extensions, char **device_extensions, uint32_t *physdev_vid, uint32_t *physdev_pid);
vr::IVRClientCore* (*vrclient_VRClientCoreFactory)(const char *name, int *return_code); vr::IVRClientCore* (*vrclient_VRClientCoreFactory)(const char *name, int *return_code);
uint32_t instance_extensions_count, device_count; uint32_t instance_extensions_count, device_count;
VkPhysicalDevice *phys_devices = NULL; VkPhysicalDevice *phys_devices = NULL;
@ -880,7 +880,8 @@ static DWORD WINAPI initialize_vr_data(void *arg)
(GetProcAddress(hwineopenxr, "__wineopenxr_get_extensions_internal")); (GetProcAddress(hwineopenxr, "__wineopenxr_get_extensions_internal"));
if (p__wineopenxr_get_extensions_internal) if (p__wineopenxr_get_extensions_internal)
{ {
if (!p__wineopenxr_get_extensions_internal(&xr_inst_ext, &xr_dev_ext)) uint32_t vid, pid;
if (!p__wineopenxr_get_extensions_internal(&xr_inst_ext, &xr_dev_ext, &vid, &pid))
{ {
WINE_TRACE("Got XR extensions.\n"); WINE_TRACE("Got XR extensions.\n");
if ((status = RegSetValueExA(vr_key, "openxr_vulkan_instance_extensions", 0, REG_SZ, if ((status = RegSetValueExA(vr_key, "openxr_vulkan_instance_extensions", 0, REG_SZ,
@ -895,6 +896,18 @@ static DWORD WINAPI initialize_vr_data(void *arg)
WINE_ERR("Could not set openxr_vulkan_device_extensions value, status %#x.\n", status); WINE_ERR("Could not set openxr_vulkan_device_extensions value, status %#x.\n", status);
goto done; goto done;
} }
if ((status = RegSetValueExA(vr_key, "openxr_vulkan_device_vid", 0, REG_DWORD,
(BYTE *)&vid, sizeof(vid))))
{
WINE_ERR("Could not set openxr_vulkan_device_vid value, status %#x.\n", status);
goto done;
}
if ((status = RegSetValueExA(vr_key, "openxr_vulkan_device_pid", 0, REG_DWORD,
(BYTE *)&pid, sizeof(pid))))
{
WINE_ERR("Could not set openxr_vulkan_device_pid value, status %#x.\n", status);
goto done;
}
} }
} }
else else

View file

@ -385,27 +385,39 @@ done:
{ {
if ((status = RegQueryValueExA(vr_key, "openxr_vulkan_instance_extensions", NULL, &type, NULL, &size))) if ((status = RegQueryValueExA(vr_key, "openxr_vulkan_instance_extensions", NULL, &type, NULL, &size)))
{ {
WINE_ERR("Error getting openxr_vulkan_instance_extensions, status %#x.\n", wait_status); WINE_ERR("Error getting openxr_vulkan_instance_extensions, status %#x.\n", status);
RegCloseKey(vr_key); RegCloseKey(vr_key);
return FALSE; return FALSE;
} }
g_instance_extensions = heap_alloc(size); g_instance_extensions = heap_alloc(size);
if ((status = RegQueryValueExA(vr_key, "openxr_vulkan_instance_extensions", NULL, &type, (BYTE *)g_instance_extensions, &size))) if ((status = RegQueryValueExA(vr_key, "openxr_vulkan_instance_extensions", NULL, &type, (BYTE *)g_instance_extensions, &size)))
{ {
WINE_ERR("Error getting openxr_vulkan_instance_extensions, status %#x.\n", wait_status); WINE_ERR("Error getting openxr_vulkan_instance_extensions, status %#x.\n", status);
RegCloseKey(vr_key); RegCloseKey(vr_key);
return FALSE; return FALSE;
} }
if ((status = RegQueryValueExA(vr_key, "openxr_vulkan_device_extensions", NULL, &type, NULL, &size))) if ((status = RegQueryValueExA(vr_key, "openxr_vulkan_device_extensions", NULL, &type, NULL, &size)))
{ {
WINE_ERR("Error getting openxr_vulkan_device_extensions, status %#x.\n", wait_status); WINE_ERR("Error getting openxr_vulkan_device_extensions, status %#x.\n", status);
RegCloseKey(vr_key); RegCloseKey(vr_key);
return FALSE; return FALSE;
} }
g_device_extensions = heap_alloc(size); g_device_extensions = heap_alloc(size);
if ((status = RegQueryValueExA(vr_key, "openxr_vulkan_device_extensions", NULL, &type, (BYTE *)g_device_extensions, &size))) if ((status = RegQueryValueExA(vr_key, "openxr_vulkan_device_extensions", NULL, &type, (BYTE *)g_device_extensions, &size)))
{ {
WINE_ERR("Error getting openxr_vulkan_device_extensions, status %#x.\n", wait_status); WINE_ERR("Error getting openxr_vulkan_device_extensions, status %#x.\n", status);
RegCloseKey(vr_key);
return FALSE;
}
if ((status = RegQueryValueExA(vr_key, "openxr_vulkan_device_vid", NULL, &type, (BYTE *)&g_physdev_vid, &size)))
{
WINE_ERR("Error getting openxr_vulkan_device_vid, status: %#x.\n", status);
RegCloseKey(vr_key);
return FALSE;
}
if ((status = RegQueryValueExA(vr_key, "openxr_vulkan_device_pid", NULL, &type, (BYTE *)&g_physdev_pid, &size)))
{
WINE_ERR("Error getting openxr_vulkan_device_pid, status: %#x.\n", status);
RegCloseKey(vr_key); RegCloseKey(vr_key);
return FALSE; return FALSE;
} }
@ -416,7 +428,7 @@ done:
} }
int WINAPI __wineopenxr_get_extensions_internal(char **ret_instance_extensions, int WINAPI __wineopenxr_get_extensions_internal(char **ret_instance_extensions,
char **ret_device_extensions) char **ret_device_extensions, uint32_t *ret_physdev_vid, uint32_t *ret_physdev_pid)
{ {
PFN_xrGetVulkanInstanceExtensionsKHR pxrGetVulkanInstanceExtensionsKHR; PFN_xrGetVulkanInstanceExtensionsKHR pxrGetVulkanInstanceExtensionsKHR;
PFN_xrGetSystem pxrGetSystem; PFN_xrGetSystem pxrGetSystem;
@ -576,8 +588,8 @@ int WINAPI __wineopenxr_get_extensions_internal(char **ret_instance_extensions,
} }
vkGetPhysicalDeviceProperties(vk_physdev, &vk_dev_props); vkGetPhysicalDeviceProperties(vk_physdev, &vk_dev_props);
g_physdev_vid = vk_dev_props.vendorID; *ret_physdev_vid = vk_dev_props.vendorID;
g_physdev_pid = vk_dev_props.deviceID; *ret_physdev_pid = vk_dev_props.deviceID;
res = pxrGetVulkanDeviceExtensionsKHR(instance, system, 0, &len, NULL); res = pxrGetVulkanDeviceExtensionsKHR(instance, system, 0, &len, NULL);
if(res != XR_SUCCESS){ if(res != XR_SUCCESS){
@ -737,6 +749,7 @@ XrResult WINAPI wine_xrGetD3D11GraphicsRequirementsKHR(XrInstance instance,
/* FIXME: what if we have two of the same adapters? */ /* FIXME: what if we have two of the same adapters? */
if(adapter_desc.VendorId == g_physdev_vid && if(adapter_desc.VendorId == g_physdev_vid &&
adapter_desc.DeviceId == g_physdev_pid){ adapter_desc.DeviceId == g_physdev_pid){
WINE_TRACE("Found DXGI adapter for %#04x:%#04x\n", g_physdev_vid, g_physdev_pid);
break; break;
} }
} }