wineopenxr: Export __wineopenxr_get_extensions_internal() function.

CW-Bug-ID: #19504
This commit is contained in:
Paul Gofman 2021-10-05 19:36:07 +03:00 committed by Arkadiusz Hiler
parent 89f8134740
commit 034ff27cf3
2 changed files with 35 additions and 30 deletions

View file

@ -319,7 +319,8 @@ done:
return value == 1; return value == 1;
} }
XrResult load_host_openxr_loader(void) int WINAPI __wineopenxr_get_extensions_internal(char **ret_instance_extensions,
char **ret_device_extensions)
{ {
PFN_xrGetVulkanInstanceExtensionsKHR pxrGetVulkanInstanceExtensionsKHR; PFN_xrGetVulkanInstanceExtensionsKHR pxrGetVulkanInstanceExtensionsKHR;
PFN_xrGetSystem pxrGetSystem; PFN_xrGetSystem pxrGetSystem;
@ -328,6 +329,7 @@ XrResult load_host_openxr_loader(void)
PFN_xrGetVulkanGraphicsRequirementsKHR pxrGetVulkanGraphicsRequirementsKHR; PFN_xrGetVulkanGraphicsRequirementsKHR pxrGetVulkanGraphicsRequirementsKHR;
PFN_xrGetInstanceProperties pxrGetInstanceProperties; PFN_xrGetInstanceProperties pxrGetInstanceProperties;
PFN_xrEnumerateViewConfigurations pxrEnumerateViewConfigurations; PFN_xrEnumerateViewConfigurations pxrEnumerateViewConfigurations;
char *instance_extensions, *device_extensions;
uint32_t len, i; uint32_t len, i;
XrInstance instance; XrInstance instance;
XrSystemId system; XrSystemId system;
@ -341,16 +343,6 @@ XrResult load_host_openxr_loader(void)
"XR_KHR_vulkan_enable", "XR_KHR_vulkan_enable",
}; };
if(g_instance_extensions || g_device_extensions)
/* already done */
return XR_SUCCESS;
if(!HACK_does_openvr_work()){
return XR_ERROR_INITIALIZATION_FAILED;
}
load_vk_unwrappers();
XrInstanceCreateInfo xrCreateInfo = { XrInstanceCreateInfo xrCreateInfo = {
.type = XR_TYPE_INSTANCE_CREATE_INFO, .type = XR_TYPE_INSTANCE_CREATE_INFO,
.next = NULL, .next = NULL,
@ -423,13 +415,12 @@ XrResult load_host_openxr_loader(void)
xrDestroyInstance(instance); xrDestroyInstance(instance);
return res; return res;
} }
g_instance_extensions = heap_alloc(len); instance_extensions = heap_alloc(len);
res = pxrGetVulkanInstanceExtensionsKHR(instance, system, len, &len, g_instance_extensions); res = pxrGetVulkanInstanceExtensionsKHR(instance, system, len, &len, instance_extensions);
if(res != XR_SUCCESS){ if(res != XR_SUCCESS){
WINE_WARN("xrGetVulkanInstanceExtensionsKHR failed: %d\n", res); WINE_WARN("xrGetVulkanInstanceExtensionsKHR failed: %d\n", res);
xrDestroyInstance(instance); xrDestroyInstance(instance);
heap_free(g_instance_extensions); heap_free(instance_extensions);
g_instance_extensions = NULL;
return res; return res;
} }
@ -454,7 +445,7 @@ XrResult load_host_openxr_loader(void)
.ppEnabledExtensionNames = NULL, .ppEnabledExtensionNames = NULL,
}; };
parse_extensions(g_instance_extensions, parse_extensions(instance_extensions,
&vk_createinfo.enabledExtensionCount, &vk_createinfo.enabledExtensionCount,
(char ***)&vk_createinfo.ppEnabledExtensionNames); (char ***)&vk_createinfo.ppEnabledExtensionNames);
@ -465,8 +456,7 @@ XrResult load_host_openxr_loader(void)
heap_free((void*)vk_createinfo.ppEnabledExtensionNames[i]); heap_free((void*)vk_createinfo.ppEnabledExtensionNames[i]);
heap_free((void*)vk_createinfo.ppEnabledExtensionNames); heap_free((void*)vk_createinfo.ppEnabledExtensionNames);
xrDestroyInstance(instance); xrDestroyInstance(instance);
heap_free(g_instance_extensions); heap_free(instance_extensions);
g_instance_extensions = NULL;
return XR_ERROR_INITIALIZATION_FAILED; return XR_ERROR_INITIALIZATION_FAILED;
} }
@ -479,8 +469,7 @@ XrResult load_host_openxr_loader(void)
WINE_WARN("xrGetVulkanGraphicsDeviceKHR failed: %d\n", res); WINE_WARN("xrGetVulkanGraphicsDeviceKHR failed: %d\n", res);
vkDestroyInstance(vk_instance, NULL); vkDestroyInstance(vk_instance, NULL);
xrDestroyInstance(instance); xrDestroyInstance(instance);
heap_free(g_instance_extensions); heap_free(instance_extensions);
g_instance_extensions = NULL;
return res; return res;
} }
@ -493,32 +482,47 @@ XrResult load_host_openxr_loader(void)
WINE_WARN("pxrGetVulkanDeviceExtensionsKHR fail: %d\n", res); WINE_WARN("pxrGetVulkanDeviceExtensionsKHR fail: %d\n", res);
vkDestroyInstance(vk_instance, NULL); vkDestroyInstance(vk_instance, NULL);
xrDestroyInstance(instance); xrDestroyInstance(instance);
heap_free(g_instance_extensions); heap_free(instance_extensions);
g_instance_extensions = NULL;
return res; return res;
} }
g_device_extensions = heap_alloc(len); device_extensions = heap_alloc(len);
res = pxrGetVulkanDeviceExtensionsKHR(instance, system, len, &len, g_device_extensions); res = pxrGetVulkanDeviceExtensionsKHR(instance, system, len, &len, device_extensions);
if(res != XR_SUCCESS){ if(res != XR_SUCCESS){
WINE_WARN("pxrGetVulkanDeviceExtensionsKHR fail: %d\n", res); WINE_WARN("pxrGetVulkanDeviceExtensionsKHR fail: %d\n", res);
vkDestroyInstance(vk_instance, NULL); vkDestroyInstance(vk_instance, NULL);
xrDestroyInstance(instance); xrDestroyInstance(instance);
heap_free(g_instance_extensions); heap_free(instance_extensions);
g_instance_extensions = NULL; heap_free(device_extensions);
heap_free(g_device_extensions);
g_device_extensions = NULL;
return res; return res;
} }
vkDestroyInstance(vk_instance, NULL); vkDestroyInstance(vk_instance, NULL);
xrDestroyInstance(instance); xrDestroyInstance(instance);
WINE_TRACE("Got required instance extensions: %s\n", g_instance_extensions); WINE_TRACE("Got required instance extensions: %s\n", instance_extensions);
WINE_TRACE("Got required device extensions: %s\n", g_device_extensions); WINE_TRACE("Got required device extensions: %s\n", device_extensions);
*ret_instance_extensions = instance_extensions;
*ret_device_extensions = device_extensions;
return XR_SUCCESS; return XR_SUCCESS;
} }
XrResult load_host_openxr_loader(void)
{
if(g_instance_extensions || g_device_extensions)
/* already done */
return XR_SUCCESS;
if(!HACK_does_openvr_work()){
return XR_ERROR_INITIALIZATION_FAILED;
}
load_vk_unwrappers();
return __wineopenxr_get_extensions_internal(&g_instance_extensions, &g_device_extensions);
}
XrResult WINAPI wine_xrEnumerateInstanceExtensionProperties(const char *layerName, XrResult WINAPI wine_xrEnumerateInstanceExtensionProperties(const char *layerName,
uint32_t propertyCapacityInput, uint32_t *propertyCountOutput, XrExtensionProperties *properties) uint32_t propertyCapacityInput, uint32_t *propertyCountOutput, XrExtensionProperties *properties)
{ {

View file

@ -1,3 +1,4 @@
@ stdcall xrNegotiateLoaderRuntimeInterface(ptr ptr) wine_xrNegotiateLoaderRuntimeInterface @ stdcall xrNegotiateLoaderRuntimeInterface(ptr ptr) wine_xrNegotiateLoaderRuntimeInterface
@ stdcall __wineopenxr_GetVulkanInstanceExtensions(long ptr ptr) @ stdcall __wineopenxr_GetVulkanInstanceExtensions(long ptr ptr)
@ stdcall __wineopenxr_GetVulkanDeviceExtensions(long ptr ptr) @ stdcall __wineopenxr_GetVulkanDeviceExtensions(long ptr ptr)
@ stdcall __wineopenxr_get_extensions_internal(ptr ptr)