2020-06-01 20:32:43 +00:00
|
|
|
// Copyright 2018-2020, Collabora, Ltd.
|
2019-03-18 05:52:32 +00:00
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
/*!
|
|
|
|
* @file
|
|
|
|
* @brief Holds system related entrypoints.
|
|
|
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
|
|
|
* @ingroup oxr_api
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "xrt/xrt_compiler.h"
|
|
|
|
#include "xrt/xrt_gfx_gl.h"
|
2019-10-29 10:08:11 +00:00
|
|
|
#include "xrt/xrt_gfx_gles.h"
|
2021-02-22 20:35:16 +00:00
|
|
|
|
2019-03-18 05:52:32 +00:00
|
|
|
#include "util/u_debug.h"
|
2021-02-22 20:35:16 +00:00
|
|
|
#include "util/u_trace_marker.h"
|
2019-03-18 05:52:32 +00:00
|
|
|
|
|
|
|
#include "oxr_objects.h"
|
|
|
|
#include "oxr_logger.h"
|
|
|
|
#include "oxr_two_call.h"
|
|
|
|
|
|
|
|
#include "oxr_api_funcs.h"
|
|
|
|
#include "oxr_api_verify.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2019-06-05 19:21:25 +00:00
|
|
|
* A helper define that verifies the systemId.
|
2019-03-18 05:52:32 +00:00
|
|
|
*/
|
2021-01-14 14:13:48 +00:00
|
|
|
#define OXR_VERIFY_SYSTEM_AND_GET(log, inst, sysId, system) \
|
|
|
|
struct oxr_system *system = NULL; \
|
|
|
|
do { \
|
|
|
|
XrResult ret = oxr_system_get_by_id(log, inst, sysId, &system); \
|
|
|
|
if (ret != XR_SUCCESS) { \
|
|
|
|
return ret; \
|
|
|
|
} \
|
|
|
|
assert(system != NULL); \
|
2019-03-18 05:52:32 +00:00
|
|
|
} while (false)
|
|
|
|
|
|
|
|
XrResult
|
2021-01-14 14:13:48 +00:00
|
|
|
oxr_xrGetSystem(XrInstance instance, const XrSystemGetInfo *getInfo, XrSystemId *systemId)
|
2019-03-18 05:52:32 +00:00
|
|
|
{
|
2021-02-22 20:35:16 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2019-09-29 10:43:45 +00:00
|
|
|
struct oxr_instance *inst;
|
2019-03-18 05:52:32 +00:00
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrGetSystem");
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, getInfo, XR_TYPE_SYSTEM_GET_INFO);
|
2019-03-18 05:52:32 +00:00
|
|
|
OXR_VERIFY_ARG_NOT_NULL(&log, systemId);
|
|
|
|
|
2019-09-29 10:43:45 +00:00
|
|
|
struct oxr_system *selected = NULL;
|
|
|
|
struct oxr_system *systems[1] = {&inst->system};
|
2021-11-08 21:29:21 +00:00
|
|
|
uint32_t system_count = ARRAY_SIZE(systems);
|
2019-03-18 05:52:32 +00:00
|
|
|
|
2021-11-08 21:29:21 +00:00
|
|
|
XrResult ret = oxr_system_select(&log, systems, system_count, getInfo->formFactor, &selected);
|
2019-03-18 05:52:32 +00:00
|
|
|
if (ret != XR_SUCCESS) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
*systemId = selected->systemId;
|
|
|
|
|
|
|
|
return XR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
2021-01-14 14:13:48 +00:00
|
|
|
oxr_xrGetSystemProperties(XrInstance instance, XrSystemId systemId, XrSystemProperties *properties)
|
2019-03-18 05:52:32 +00:00
|
|
|
{
|
2021-02-22 20:35:16 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2019-09-29 10:43:45 +00:00
|
|
|
struct oxr_instance *inst;
|
2019-03-18 05:52:32 +00:00
|
|
|
struct oxr_logger log;
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrGetSystemProperties");
|
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, properties, XR_TYPE_SYSTEM_PROPERTIES);
|
2019-03-18 05:52:32 +00:00
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
|
|
|
|
|
|
|
return oxr_system_get_properties(&log, sys, properties);
|
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
2021-01-14 14:13:48 +00:00
|
|
|
oxr_xrEnumerateViewConfigurations(XrInstance instance,
|
|
|
|
XrSystemId systemId,
|
|
|
|
uint32_t viewConfigurationTypeCapacityInput,
|
|
|
|
uint32_t *viewConfigurationTypeCountOutput,
|
|
|
|
XrViewConfigurationType *viewConfigurationTypes)
|
2019-03-18 05:52:32 +00:00
|
|
|
{
|
2021-02-22 20:35:16 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2019-09-29 10:43:45 +00:00
|
|
|
struct oxr_instance *inst;
|
2019-03-18 05:52:32 +00:00
|
|
|
struct oxr_logger log;
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrEnumerateViewConfigurations");
|
2019-03-18 05:52:32 +00:00
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
|
|
|
|
2021-01-14 14:13:48 +00:00
|
|
|
return oxr_system_enumerate_view_confs(&log, sys, viewConfigurationTypeCapacityInput,
|
|
|
|
viewConfigurationTypeCountOutput, viewConfigurationTypes);
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
2021-01-14 14:13:48 +00:00
|
|
|
oxr_xrEnumerateEnvironmentBlendModes(XrInstance instance,
|
|
|
|
XrSystemId systemId,
|
|
|
|
XrViewConfigurationType viewConfigurationType,
|
|
|
|
uint32_t environmentBlendModeCapacityInput,
|
|
|
|
uint32_t *environmentBlendModeCountOutput,
|
|
|
|
XrEnvironmentBlendMode *environmentBlendModes)
|
2019-03-18 05:52:32 +00:00
|
|
|
{
|
2021-02-22 20:35:16 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2019-09-29 10:43:45 +00:00
|
|
|
struct oxr_instance *inst;
|
2019-03-18 05:52:32 +00:00
|
|
|
struct oxr_logger log;
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrEnumerateEnvironmentBlendModes");
|
2019-03-18 05:52:32 +00:00
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
2020-06-04 14:01:57 +00:00
|
|
|
OXR_VERIFY_VIEW_CONFIG_TYPE(&log, inst, viewConfigurationType);
|
2020-05-30 10:58:06 +00:00
|
|
|
|
|
|
|
if (viewConfigurationType != sys->view_config_type) {
|
2021-01-14 14:13:48 +00:00
|
|
|
return oxr_error(&log, XR_ERROR_VIEW_CONFIGURATION_TYPE_UNSUPPORTED,
|
2020-05-30 10:58:06 +00:00
|
|
|
"(viewConfigurationType == 0x%08x) "
|
|
|
|
"unsupported view configuration type",
|
|
|
|
viewConfigurationType);
|
|
|
|
}
|
|
|
|
|
2021-01-14 14:13:48 +00:00
|
|
|
return oxr_system_enumerate_blend_modes(&log, sys, viewConfigurationType, environmentBlendModeCapacityInput,
|
|
|
|
environmentBlendModeCountOutput, environmentBlendModes);
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
2021-01-14 14:13:48 +00:00
|
|
|
oxr_xrGetViewConfigurationProperties(XrInstance instance,
|
|
|
|
XrSystemId systemId,
|
|
|
|
XrViewConfigurationType viewConfigurationType,
|
|
|
|
XrViewConfigurationProperties *configurationProperties)
|
2019-03-18 05:52:32 +00:00
|
|
|
{
|
2021-02-22 20:35:16 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2019-09-29 10:43:45 +00:00
|
|
|
struct oxr_instance *inst;
|
2019-03-18 05:52:32 +00:00
|
|
|
struct oxr_logger log;
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrGetViewConfigurationProperties");
|
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, configurationProperties, XR_TYPE_VIEW_CONFIGURATION_PROPERTIES);
|
2019-03-18 05:52:32 +00:00
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
|
|
|
|
2021-01-14 14:13:48 +00:00
|
|
|
return oxr_system_get_view_conf_properties(&log, sys, viewConfigurationType, configurationProperties);
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
2021-01-14 14:13:48 +00:00
|
|
|
oxr_xrEnumerateViewConfigurationViews(XrInstance instance,
|
|
|
|
XrSystemId systemId,
|
|
|
|
XrViewConfigurationType viewConfigurationType,
|
|
|
|
uint32_t viewCapacityInput,
|
|
|
|
uint32_t *viewCountOutput,
|
|
|
|
XrViewConfigurationView *views)
|
2019-03-18 05:52:32 +00:00
|
|
|
{
|
2021-02-22 20:35:16 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2019-09-29 10:43:45 +00:00
|
|
|
struct oxr_instance *inst;
|
2019-03-18 05:52:32 +00:00
|
|
|
struct oxr_logger log;
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrEnumerateViewConfigurationViews");
|
2019-03-18 05:52:32 +00:00
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
|
|
|
|
2021-01-14 14:13:48 +00:00
|
|
|
return oxr_system_enumerate_view_conf_views(&log, sys, viewConfigurationType, viewCapacityInput,
|
|
|
|
viewCountOutput, views);
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-29 10:08:11 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* OpenGL ES
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
|
|
|
|
|
|
|
|
XrResult
|
2021-01-14 14:13:48 +00:00
|
|
|
oxr_xrGetOpenGLESGraphicsRequirementsKHR(XrInstance instance,
|
|
|
|
XrSystemId systemId,
|
|
|
|
XrGraphicsRequirementsOpenGLESKHR *graphicsRequirements)
|
2019-10-29 10:08:11 +00:00
|
|
|
{
|
2021-02-22 20:35:16 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2019-10-29 10:08:11 +00:00
|
|
|
struct oxr_instance *inst;
|
|
|
|
struct oxr_logger log;
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrGetOpenGLESGraphicsRequirementsKHR");
|
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, graphicsRequirements, XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_ES_KHR);
|
2019-10-29 10:08:11 +00:00
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
|
|
|
|
|
|
|
struct xrt_api_requirements ver;
|
|
|
|
|
|
|
|
xrt_gfx_gles_get_versions(&ver);
|
|
|
|
|
2021-01-14 14:13:48 +00:00
|
|
|
graphicsRequirements->minApiVersionSupported = XR_MAKE_VERSION(ver.min_major, ver.min_minor, ver.min_patch);
|
|
|
|
graphicsRequirements->maxApiVersionSupported = XR_MAKE_VERSION(ver.max_major, ver.max_minor, ver.max_patch);
|
2019-10-29 10:08:11 +00:00
|
|
|
|
2020-05-30 11:42:41 +00:00
|
|
|
sys->gotten_requirements = true;
|
|
|
|
|
2019-10-29 10:08:11 +00:00
|
|
|
return XR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2019-03-18 05:52:32 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* OpenGL
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef XR_USE_GRAPHICS_API_OPENGL
|
|
|
|
|
|
|
|
XrResult
|
2021-01-14 14:13:48 +00:00
|
|
|
oxr_xrGetOpenGLGraphicsRequirementsKHR(XrInstance instance,
|
|
|
|
XrSystemId systemId,
|
|
|
|
XrGraphicsRequirementsOpenGLKHR *graphicsRequirements)
|
2019-03-18 05:52:32 +00:00
|
|
|
{
|
2021-02-22 20:35:16 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2019-09-29 10:43:45 +00:00
|
|
|
struct oxr_instance *inst;
|
2019-03-18 05:52:32 +00:00
|
|
|
struct oxr_logger log;
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrGetOpenGLGraphicsRequirementsKHR");
|
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, graphicsRequirements, XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_KHR);
|
2019-03-18 05:52:32 +00:00
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
|
|
|
|
|
|
|
struct xrt_api_requirements ver;
|
|
|
|
|
|
|
|
xrt_gfx_gl_get_versions(&ver);
|
|
|
|
|
2021-01-14 14:13:48 +00:00
|
|
|
graphicsRequirements->minApiVersionSupported = XR_MAKE_VERSION(ver.min_major, ver.min_minor, ver.min_patch);
|
|
|
|
graphicsRequirements->maxApiVersionSupported = XR_MAKE_VERSION(ver.max_major, ver.max_minor, ver.max_patch);
|
2019-03-18 05:52:32 +00:00
|
|
|
|
2020-05-30 11:42:41 +00:00
|
|
|
sys->gotten_requirements = true;
|
|
|
|
|
2019-03-18 05:52:32 +00:00
|
|
|
return XR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Vulkan
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef XR_USE_GRAPHICS_API_VULKAN
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrGetVulkanInstanceExtensionsKHR(XrInstance instance,
|
|
|
|
XrSystemId systemId,
|
|
|
|
uint32_t namesCapacityInput,
|
2019-09-29 10:43:45 +00:00
|
|
|
uint32_t *namesCountOutput,
|
|
|
|
char *namesString)
|
2019-03-18 05:52:32 +00:00
|
|
|
{
|
2021-02-22 20:35:16 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2019-09-29 10:43:45 +00:00
|
|
|
struct oxr_instance *inst;
|
2019-03-18 05:52:32 +00:00
|
|
|
struct oxr_logger log;
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrGetVulkanInstanceExtensionsKHR");
|
2019-03-18 05:52:32 +00:00
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
|
|
|
|
2021-01-14 14:13:48 +00:00
|
|
|
return oxr_vk_get_instance_exts(&log, sys, namesCapacityInput, namesCountOutput, namesString);
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrGetVulkanDeviceExtensionsKHR(XrInstance instance,
|
|
|
|
XrSystemId systemId,
|
|
|
|
uint32_t namesCapacityInput,
|
2019-09-29 10:43:45 +00:00
|
|
|
uint32_t *namesCountOutput,
|
|
|
|
char *namesString)
|
2019-03-18 05:52:32 +00:00
|
|
|
{
|
2021-02-22 20:35:16 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2019-09-29 10:43:45 +00:00
|
|
|
struct oxr_instance *inst;
|
2019-03-18 05:52:32 +00:00
|
|
|
struct oxr_logger log;
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrGetVulkanDeviceExtensionsKHR");
|
2019-03-18 05:52:32 +00:00
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
|
|
|
|
2021-01-14 14:13:48 +00:00
|
|
|
return oxr_vk_get_device_exts(&log, sys, namesCapacityInput, namesCountOutput, namesString);
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
2020-08-06 14:29:37 +00:00
|
|
|
// NOLINTNEXTLINE // don't remove the forward decl.
|
2019-03-18 05:52:32 +00:00
|
|
|
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL
|
2019-09-29 10:43:45 +00:00
|
|
|
vkGetInstanceProcAddr(VkInstance instance, const char *pName);
|
2019-03-18 05:52:32 +00:00
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrGetVulkanGraphicsDeviceKHR(XrInstance instance,
|
|
|
|
XrSystemId systemId,
|
|
|
|
VkInstance vkInstance,
|
2019-09-29 10:43:45 +00:00
|
|
|
VkPhysicalDevice *vkPhysicalDevice)
|
2019-03-18 05:52:32 +00:00
|
|
|
{
|
2021-02-22 20:35:16 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2019-09-29 10:43:45 +00:00
|
|
|
struct oxr_instance *inst;
|
2019-03-18 05:52:32 +00:00
|
|
|
struct oxr_logger log;
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrGetVulkanGraphicsDeviceKHR");
|
2019-03-18 05:52:32 +00:00
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
|
|
|
OXR_VERIFY_ARG_NOT_NULL(&log, vkPhysicalDevice);
|
|
|
|
|
2021-01-14 14:13:48 +00:00
|
|
|
return oxr_vk_get_physical_device(&log, inst, sys, vkInstance, vkGetInstanceProcAddr, vkPhysicalDevice);
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
2021-01-04 15:44:50 +00:00
|
|
|
XrResult
|
2021-01-14 14:13:48 +00:00
|
|
|
oxr_xrGetVulkanGraphicsDevice2KHR(XrInstance instance,
|
|
|
|
const XrVulkanGraphicsDeviceGetInfoKHR *getInfo,
|
|
|
|
VkPhysicalDevice *vkPhysicalDevice)
|
2021-01-04 15:44:50 +00:00
|
|
|
{
|
2021-04-06 23:49:42 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2021-01-04 15:44:50 +00:00
|
|
|
struct oxr_instance *inst;
|
|
|
|
struct oxr_logger log;
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrGetVulkanGraphicsDeviceKHR");
|
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, getInfo, XR_TYPE_VULKAN_GRAPHICS_DEVICE_GET_INFO_KHR);
|
2021-01-04 15:44:50 +00:00
|
|
|
|
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, getInfo->systemId, sys);
|
|
|
|
OXR_VERIFY_ARG_NOT_NULL(&log, vkPhysicalDevice);
|
|
|
|
|
2021-01-14 14:13:48 +00:00
|
|
|
return oxr_vk_get_physical_device(&log, inst, sys, getInfo->vulkanInstance, vkGetInstanceProcAddr,
|
|
|
|
vkPhysicalDevice);
|
2021-01-04 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 05:52:32 +00:00
|
|
|
XrResult
|
2021-01-14 14:13:48 +00:00
|
|
|
oxr_xrGetVulkanGraphicsRequirementsKHR(XrInstance instance,
|
|
|
|
XrSystemId systemId,
|
|
|
|
XrGraphicsRequirementsVulkanKHR *graphicsRequirements)
|
2019-03-18 05:52:32 +00:00
|
|
|
{
|
2021-02-22 20:35:16 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2019-09-29 10:43:45 +00:00
|
|
|
struct oxr_instance *inst;
|
2019-03-18 05:52:32 +00:00
|
|
|
struct oxr_logger log;
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrGetVulkanGraphicsRequirementsKHR");
|
2019-03-18 05:52:32 +00:00
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, graphicsRequirements, XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN_KHR);
|
2019-03-18 05:52:32 +00:00
|
|
|
|
|
|
|
return oxr_vk_get_requirements(&log, sys, graphicsRequirements);
|
|
|
|
}
|
|
|
|
|
2021-01-04 15:44:50 +00:00
|
|
|
XrResult
|
2021-01-14 14:13:48 +00:00
|
|
|
oxr_xrGetVulkanGraphicsRequirements2KHR(XrInstance instance,
|
|
|
|
XrSystemId systemId,
|
|
|
|
XrGraphicsRequirementsVulkan2KHR *graphicsRequirements)
|
2021-01-04 15:44:50 +00:00
|
|
|
{
|
2021-04-06 23:49:42 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2021-01-04 15:44:50 +00:00
|
|
|
struct oxr_instance *inst;
|
|
|
|
struct oxr_logger log;
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrGetVulkanGraphicsRequirementsKHR");
|
2021-01-04 15:44:50 +00:00
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
|
|
|
/* XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN2_KHR aliased to
|
|
|
|
* XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN_KHR */
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, graphicsRequirements, XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN_KHR);
|
2021-01-04 15:44:50 +00:00
|
|
|
|
|
|
|
return oxr_vk_get_requirements(&log, sys, graphicsRequirements);
|
|
|
|
}
|
|
|
|
|
|
|
|
XRAPI_ATTR XrResult XRAPI_CALL
|
|
|
|
oxr_xrCreateVulkanInstanceKHR(XrInstance instance,
|
|
|
|
const XrVulkanInstanceCreateInfoKHR *createInfo,
|
|
|
|
VkInstance *vulkanInstance,
|
|
|
|
VkResult *vulkanResult)
|
|
|
|
{
|
2021-04-06 23:49:42 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2021-01-04 15:44:50 +00:00
|
|
|
struct oxr_instance *inst;
|
|
|
|
struct oxr_logger log;
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrCreateVulkanInstanceKHR");
|
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, createInfo, XR_TYPE_VULKAN_INSTANCE_CREATE_INFO_KHR);
|
2021-01-04 15:44:50 +00:00
|
|
|
|
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, createInfo->systemId, sys);
|
|
|
|
OXR_VERIFY_ARG_NOT_NULL(&log, createInfo->pfnGetInstanceProcAddr);
|
|
|
|
OXR_VERIFY_ARG_ZERO(&log, createInfo->createFlags);
|
|
|
|
|
|
|
|
OXR_VERIFY_ARG_NOT_NULL(&log, createInfo->pfnGetInstanceProcAddr);
|
|
|
|
OXR_VERIFY_ARG_NOT_NULL(&log, createInfo->vulkanCreateInfo);
|
|
|
|
|
|
|
|
// createInfo->vulkanAllocator can be NULL
|
|
|
|
|
2021-01-14 14:13:48 +00:00
|
|
|
if (createInfo->vulkanCreateInfo->sType != VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO) {
|
2021-01-04 15:44:50 +00:00
|
|
|
return oxr_error(&log, XR_ERROR_VALIDATION_FAILURE,
|
|
|
|
"createInfo->vulkanCreateInfo->sType must be "
|
|
|
|
"VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO");
|
|
|
|
}
|
|
|
|
|
2021-01-14 14:13:48 +00:00
|
|
|
return oxr_vk_create_vulkan_instance(&log, sys, createInfo, vulkanInstance, vulkanResult);
|
2021-01-04 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrCreateVulkanDeviceKHR(XrInstance instance,
|
|
|
|
const XrVulkanDeviceCreateInfoKHR *createInfo,
|
|
|
|
VkDevice *vulkanDevice,
|
|
|
|
VkResult *vulkanResult)
|
|
|
|
{
|
2021-04-06 23:49:42 +00:00
|
|
|
OXR_TRACE_MARKER();
|
|
|
|
|
2021-01-04 15:44:50 +00:00
|
|
|
struct oxr_instance *inst;
|
|
|
|
struct oxr_logger log;
|
|
|
|
|
2021-01-14 14:13:48 +00:00
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrGetVulkanGraphicsDeviceKHR");
|
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, createInfo, XR_TYPE_VULKAN_DEVICE_CREATE_INFO_KHR);
|
2021-01-04 15:44:50 +00:00
|
|
|
|
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, createInfo->systemId, sys);
|
|
|
|
OXR_VERIFY_ARG_ZERO(&log, createInfo->createFlags);
|
|
|
|
|
|
|
|
OXR_VERIFY_ARG_NOT_NULL(&log, createInfo->pfnGetInstanceProcAddr);
|
|
|
|
OXR_VERIFY_ARG_NOT_NULL(&log, createInfo->vulkanCreateInfo);
|
|
|
|
|
|
|
|
// VK_NULL_HANDLE is 0
|
|
|
|
OXR_VERIFY_ARG_NOT_NULL(&log, createInfo->vulkanPhysicalDevice);
|
|
|
|
|
2021-05-06 22:34:47 +00:00
|
|
|
OXR_VERIFY_ARG_NOT_NULL(&log, sys->suggested_vulkan_physical_device);
|
2021-01-04 15:44:50 +00:00
|
|
|
OXR_VERIFY_ARG_NOT_NULL(&log, sys->vulkan_enable2_instance);
|
|
|
|
|
2021-05-06 22:34:47 +00:00
|
|
|
if (sys->suggested_vulkan_physical_device != createInfo->vulkanPhysicalDevice) {
|
2021-01-14 14:13:48 +00:00
|
|
|
return oxr_error(&log, XR_ERROR_HANDLE_INVALID,
|
|
|
|
"createInfo->vulkanPhysicalDevice must be the device "
|
|
|
|
"returned by xrGetVulkanGraphicsDeviceKHR");
|
2021-01-04 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// createInfo->vulkanAllocator can be NULL
|
|
|
|
|
2021-01-14 14:13:48 +00:00
|
|
|
return oxr_vk_create_vulkan_device(&log, sys, createInfo, vulkanDevice, vulkanResult);
|
2021-01-04 15:44:50 +00:00
|
|
|
}
|
2019-03-18 05:52:32 +00:00
|
|
|
#endif
|
2022-05-16 15:44:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* D3D11
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef XR_USE_GRAPHICS_API_D3D11
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrGetD3D11GraphicsRequirementsKHR(XrInstance instance,
|
|
|
|
XrSystemId systemId,
|
|
|
|
XrGraphicsRequirementsD3D11KHR *graphicsRequirements)
|
|
|
|
{
|
|
|
|
|
|
|
|
struct oxr_instance *inst;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrGetD3D11GraphicsRequirementsKHR");
|
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, graphicsRequirements, XR_TYPE_GRAPHICS_REQUIREMENTS_D3D11_KHR);
|
|
|
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
|
|
|
|
|
|
|
sys->gotten_requirements = true;
|
|
|
|
|
|
|
|
return oxr_d3d11_get_requirements(&log, sys, graphicsRequirements);
|
|
|
|
}
|
|
|
|
#endif
|