2019-03-18 05:52:32 +00:00
|
|
|
// Copyright 2019, Collabora, Ltd.
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
/*!
|
|
|
|
* @file
|
|
|
|
* @brief Session entrypoints for the OpenXR state tracker.
|
|
|
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
|
|
|
* @ingroup oxr_api
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "xrt/xrt_compiler.h"
|
|
|
|
|
|
|
|
#include "util/u_debug.h"
|
|
|
|
|
|
|
|
#include "oxr_objects.h"
|
|
|
|
#include "oxr_logger.h"
|
|
|
|
#include "oxr_two_call.h"
|
|
|
|
|
|
|
|
#include "oxr_api_funcs.h"
|
|
|
|
#include "oxr_api_verify.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrCreateSession(XrInstance instance,
|
|
|
|
const XrSessionCreateInfo* createInfo,
|
|
|
|
XrSession* out_session)
|
|
|
|
{
|
|
|
|
XrResult ret;
|
|
|
|
struct oxr_instance* inst;
|
|
|
|
struct oxr_session* sess;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst,
|
|
|
|
"xrCreateSession");
|
|
|
|
|
2019-03-23 01:11:14 +00:00
|
|
|
ret = oxr_verify_XrSessionCreateInfo(&log, inst, createInfo);
|
2019-03-18 05:52:32 +00:00
|
|
|
if (ret != XR_SUCCESS) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-06-03 19:17:45 +00:00
|
|
|
ret = oxr_session_create(&log, &inst->system, createInfo, &sess);
|
2019-03-18 05:52:32 +00:00
|
|
|
if (ret != XR_SUCCESS) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
*out_session = oxr_session_to_openxr(sess);
|
|
|
|
|
|
|
|
return XR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrDestroySession(XrSession session)
|
|
|
|
{
|
|
|
|
struct oxr_session* sess;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
|
|
|
|
"xrDestroySession");
|
|
|
|
|
2019-04-05 19:18:03 +00:00
|
|
|
return oxr_handle_destroy(&log, &sess->handle);
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrBeginSession(XrSession session, const XrSessionBeginInfo* beginInfo)
|
|
|
|
{
|
|
|
|
struct oxr_session* sess;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, "xrBeginSession");
|
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NULL(&log, beginInfo,
|
|
|
|
XR_TYPE_SESSION_BEGIN_INFO);
|
|
|
|
|
|
|
|
return oxr_session_begin(&log, sess, beginInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrEndSession(XrSession session)
|
|
|
|
{
|
|
|
|
struct oxr_session* sess;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, "xrEndSession");
|
|
|
|
|
|
|
|
return oxr_session_end(&log, sess);
|
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrWaitFrame(XrSession session,
|
|
|
|
const XrFrameWaitInfo* frameWaitInfo,
|
|
|
|
XrFrameState* frameState)
|
|
|
|
{
|
|
|
|
struct oxr_session* sess;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, "xrWaitFrame");
|
2019-03-23 01:11:14 +00:00
|
|
|
if (sess->compositor == NULL) {
|
2019-04-04 23:19:15 +00:00
|
|
|
return oxr_error(&log, XR_ERROR_GRAPHICS_DEVICE_INVALID,
|
|
|
|
"xrWaitFrame is illegal in headless sessions");
|
2019-03-23 01:11:14 +00:00
|
|
|
}
|
2019-03-18 05:52:32 +00:00
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NULL(&log, frameState, XR_TYPE_FRAME_STATE);
|
|
|
|
OXR_VERIFY_ARG_NOT_NULL(&log, frameState);
|
|
|
|
|
|
|
|
return oxr_session_frame_wait(&log, sess, frameState);
|
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrBeginFrame(XrSession session, const XrFrameBeginInfo* frameBeginInfo)
|
|
|
|
{
|
|
|
|
struct oxr_session* sess;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, "xrBeginFrame");
|
2019-04-04 23:19:15 +00:00
|
|
|
// NULL explicitly allowed here because it's a basically empty struct.
|
|
|
|
if (frameBeginInfo != NULL) {
|
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NULL(&log, frameBeginInfo,
|
|
|
|
XR_TYPE_FRAME_BEGIN_INFO);
|
|
|
|
}
|
2019-03-18 05:52:32 +00:00
|
|
|
|
|
|
|
return oxr_session_frame_begin(&log, sess);
|
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrEndFrame(XrSession session, const XrFrameEndInfo* frameEndInfo)
|
|
|
|
{
|
|
|
|
struct oxr_session* sess;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, "xrEndFrame");
|
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NULL(&log, frameEndInfo,
|
|
|
|
XR_TYPE_FRAME_END_INFO);
|
|
|
|
|
|
|
|
return oxr_session_frame_end(&log, sess, frameEndInfo);
|
|
|
|
}
|
|
|
|
|
2019-07-13 16:17:57 +00:00
|
|
|
XrResult
|
|
|
|
oxr_xrRequestExitSession(XrSession session)
|
|
|
|
{
|
|
|
|
struct oxr_session* sess;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
|
|
|
|
"xrRequestExitSession");
|
|
|
|
|
|
|
|
return oxr_error(&log, XR_ERROR_HANDLE_INVALID, " not implemented");
|
|
|
|
}
|
|
|
|
|
2019-03-18 05:52:32 +00:00
|
|
|
XrResult
|
|
|
|
oxr_xrLocateViews(XrSession session,
|
|
|
|
const XrViewLocateInfo* viewLocateInfo,
|
|
|
|
XrViewState* viewState,
|
|
|
|
uint32_t viewCapacityInput,
|
|
|
|
uint32_t* viewCountOutput,
|
|
|
|
XrView* views)
|
|
|
|
{
|
|
|
|
struct oxr_session* sess;
|
|
|
|
struct oxr_space* spc;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, "xrLocateViews");
|
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NULL(&log, viewLocateInfo,
|
|
|
|
XR_TYPE_VIEW_LOCATE_INFO);
|
|
|
|
OXR_VERIFY_SPACE_NOT_NULL(&log, viewLocateInfo->space, spc);
|
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NULL(&log, viewState, XR_TYPE_VIEW_STATE);
|
|
|
|
|
|
|
|
if (viewCapacityInput == 0) {
|
|
|
|
OXR_VERIFY_ARG_NOT_NULL(&log, viewCountOutput);
|
|
|
|
} else {
|
|
|
|
OXR_VERIFY_ARG_NOT_NULL(&log, views);
|
|
|
|
}
|
|
|
|
|
|
|
|
return oxr_session_views(&log, sess, viewLocateInfo, viewState,
|
|
|
|
viewCapacityInput, viewCountOutput, views);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* XR_KHR_visibility_mask
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef XR_KHR_visibility_mask
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrGetVisibilityMaskKHR(XrSession session,
|
|
|
|
XrViewConfigurationType viewConfigurationType,
|
|
|
|
uint32_t viewIndex,
|
|
|
|
XrVisibilityMaskTypeKHR visibilityMaskType,
|
|
|
|
XrVisibilityMaskKHR* visibilityMask)
|
|
|
|
{
|
|
|
|
struct oxr_session* sess;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
|
|
|
|
"xrGetVisibilityMaskKHR");
|
|
|
|
|
|
|
|
return oxr_error(&log, XR_ERROR_HANDLE_INVALID, " not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* XR_EXT_performance_settings
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef XR_EXT_performance_settings
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrPerfSettingsSetPerformanceLevelEXT(XrSession session,
|
|
|
|
XrPerfSettingsDomainEXT domain,
|
|
|
|
XrPerfSettingsLevelEXT level)
|
|
|
|
{
|
|
|
|
struct oxr_session* sess;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
|
|
|
|
"xrPerfSettingsSetPerformanceLevelEXT");
|
|
|
|
|
|
|
|
return oxr_error(&log, XR_ERROR_HANDLE_INVALID, " not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* XR_EXT_thermal_query
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef XR_EXT_thermal_query
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrThermalGetTemperatureTrendEXT(
|
|
|
|
XrSession session,
|
|
|
|
XrPerfSettingsDomainEXT domain,
|
|
|
|
XrPerfSettingsNotificationLevelEXT* notificationLevel,
|
|
|
|
float* tempHeadroom,
|
|
|
|
float* tempSlope)
|
|
|
|
{
|
|
|
|
struct oxr_session* sess;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
|
|
|
|
"xrThermalGetTemperatureTrendEXT");
|
|
|
|
|
|
|
|
return oxr_error(&log, XR_ERROR_HANDLE_INVALID, " not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|