st/oxr: Make all oxr_error calls uniform and improve output

This commit is contained in:
Jakob Bornecrantz 2020-05-31 16:49:25 +01:00
parent f4fadc6f55
commit a36753443a
19 changed files with 148 additions and 95 deletions

View file

@ -0,0 +1,2 @@
OpenXR: Rework the logging formatting of error messages, this makes it easier to
read for the application developer.

View file

@ -366,7 +366,7 @@ oxr_xrGetActionStateBoolean(XrSession session,
if (act->action_type != XR_ACTION_TYPE_BOOLEAN_INPUT) { if (act->action_type != XR_ACTION_TYPE_BOOLEAN_INPUT) {
return oxr_error(&log, XR_ERROR_ACTION_TYPE_MISMATCH, return oxr_error(&log, XR_ERROR_ACTION_TYPE_MISMATCH,
" not created with boolean type"); "Not created with boolean type");
} }
ret = oxr_verify_subaction_path_get( ret = oxr_verify_subaction_path_get(
@ -399,7 +399,7 @@ oxr_xrGetActionStateFloat(XrSession session,
if (act->action_type != XR_ACTION_TYPE_FLOAT_INPUT) { if (act->action_type != XR_ACTION_TYPE_FLOAT_INPUT) {
return oxr_error(&log, XR_ERROR_ACTION_TYPE_MISMATCH, return oxr_error(&log, XR_ERROR_ACTION_TYPE_MISMATCH,
" not created with float type"); "Not created with float type");
} }
ret = oxr_verify_subaction_path_get( ret = oxr_verify_subaction_path_get(
@ -432,7 +432,7 @@ oxr_xrGetActionStateVector2f(XrSession session,
if (act->action_type != XR_ACTION_TYPE_VECTOR2F_INPUT) { if (act->action_type != XR_ACTION_TYPE_VECTOR2F_INPUT) {
return oxr_error(&log, XR_ERROR_ACTION_TYPE_MISMATCH, return oxr_error(&log, XR_ERROR_ACTION_TYPE_MISMATCH,
" not created with float[2] type"); "Not created with float[2] type");
} }
ret = oxr_verify_subaction_path_get( ret = oxr_verify_subaction_path_get(
@ -464,7 +464,7 @@ oxr_xrGetActionStatePose(XrSession session,
if (act->action_type != XR_ACTION_TYPE_POSE_INPUT) { if (act->action_type != XR_ACTION_TYPE_POSE_INPUT) {
return oxr_error(&log, XR_ERROR_ACTION_TYPE_MISMATCH, return oxr_error(&log, XR_ERROR_ACTION_TYPE_MISMATCH,
" not created with pose type"); "Not created with pose type");
} }
ret = oxr_verify_subaction_path_get( ret = oxr_verify_subaction_path_get(
@ -540,7 +540,7 @@ oxr_xrApplyHapticFeedback(XrSession session,
if (act->action_type != XR_ACTION_TYPE_VIBRATION_OUTPUT) { if (act->action_type != XR_ACTION_TYPE_VIBRATION_OUTPUT) {
return oxr_error(&log, XR_ERROR_ACTION_TYPE_MISMATCH, return oxr_error(&log, XR_ERROR_ACTION_TYPE_MISMATCH,
" not created with output vibration type"); "Not created with output vibration type");
} }
return oxr_action_apply_haptic_feedback(&log, sess, act->key, sub_paths, return oxr_action_apply_haptic_feedback(&log, sess, act->key, sub_paths,
@ -571,7 +571,7 @@ oxr_xrStopHapticFeedback(XrSession session,
if (act->action_type != XR_ACTION_TYPE_VIBRATION_OUTPUT) { if (act->action_type != XR_ACTION_TYPE_VIBRATION_OUTPUT) {
return oxr_error(&log, XR_ERROR_ACTION_TYPE_MISMATCH, return oxr_error(&log, XR_ERROR_ACTION_TYPE_MISMATCH,
" not created with output vibration type"); "Not created with output vibration type");
} }
return oxr_action_stop_haptic_feedback(&log, sess, act->key, sub_paths); return oxr_action_stop_haptic_feedback(&log, sess, act->key, sub_paths);

View file

@ -200,7 +200,7 @@ oxr_xrGetVisibilityMaskKHR(XrSession session,
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
"xrGetVisibilityMaskKHR"); "xrGetVisibilityMaskKHR");
return oxr_error(&log, XR_ERROR_HANDLE_INVALID, " not implemented"); return oxr_error(&log, XR_ERROR_HANDLE_INVALID, "Not implemented");
} }
#endif #endif
@ -224,7 +224,7 @@ oxr_xrPerfSettingsSetPerformanceLevelEXT(XrSession session,
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
"xrPerfSettingsSetPerformanceLevelEXT"); "xrPerfSettingsSetPerformanceLevelEXT");
return oxr_error(&log, XR_ERROR_HANDLE_INVALID, " not implemented"); return oxr_error(&log, XR_ERROR_HANDLE_INVALID, "Not implemented");
} }
#endif #endif
@ -251,7 +251,7 @@ oxr_xrThermalGetTemperatureTrendEXT(
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
"xrThermalGetTemperatureTrendEXT"); "xrThermalGetTemperatureTrendEXT");
return oxr_error(&log, XR_ERROR_HANDLE_INVALID, " not implemented"); return oxr_error(&log, XR_ERROR_HANDLE_INVALID, "Not implemented");
} }
#endif #endif

View file

@ -50,9 +50,8 @@ oxr_xrCreateSwapchain(XrSession session,
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
"xrCreateSwapchain"); "xrCreateSwapchain");
if (sess->compositor == NULL) { if (sess->compositor == NULL) {
return oxr_error( return oxr_error(&log, XR_ERROR_VALIDATION_FAILURE,
&log, XR_ERROR_VALIDATION_FAILURE, "Is illegal in headless sessions");
"xrCreateSwapchain is illegal in headless sessions");
} }
OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, createInfo, OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, createInfo,
XR_TYPE_SWAPCHAIN_CREATE_INFO); XR_TYPE_SWAPCHAIN_CREATE_INFO);
@ -104,7 +103,7 @@ oxr_xrEnumerateSwapchainImages(XrSwapchain swapchain,
} }
if (imageCapacityInput < xsc->num_images) { if (imageCapacityInput < xsc->num_images) {
return oxr_error(&log, XR_ERROR_SIZE_INSUFFICIENT, return oxr_error(&log, XR_ERROR_SIZE_INSUFFICIENT,
"(imageCapacityInput = %u)", "(imageCapacityInput == %u)",
imageCapacityInput); imageCapacityInput);
} }

View file

@ -30,10 +30,10 @@ extern "C" {
} \ } \
if (new_thing->handle.state != OXR_HANDLE_STATE_LIVE) { \ if (new_thing->handle.state != OXR_HANDLE_STATE_LIVE) { \
return oxr_error(log, XR_ERROR_HANDLE_INVALID, \ return oxr_error(log, XR_ERROR_HANDLE_INVALID, \
" state == %s (" #thing " == %p)", \ "(" #thing " == %p) state == %s", \
(void *)new_thing, \
oxr_handle_state_to_string( \ oxr_handle_state_to_string( \
new_thing->handle.state), \ new_thing->handle.state)); \
(void *)new_thing); \
} \ } \
oxr_log_set_instance(log, lookup); \ oxr_log_set_instance(log, lookup); \
} while (0) } while (0)
@ -91,7 +91,7 @@ extern "C" {
do { \ do { \
if (!(inst)->extensions.mixed_case_name) { \ if (!(inst)->extensions.mixed_case_name) { \
return oxr_error((log), XR_ERROR_FUNCTION_UNSUPPORTED, \ return oxr_error((log), XR_ERROR_FUNCTION_UNSUPPORTED, \
" Requires XR_" #mixed_case_name \ "Requires XR_" #mixed_case_name \
" extension enabled"); \ " extension enabled"); \
} \ } \
} while (false) } while (false)
@ -133,7 +133,8 @@ extern "C" {
do { \ do { \
if (count > 0 && paths == NULL) { \ if (count > 0 && paths == NULL) { \
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \ return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
" " #count " is not zero but " #paths \ "(" #count \
") is not zero but " #paths \
" is NULL"); \ " is NULL"); \
} \ } \
} while (false) } while (false)

View file

@ -417,7 +417,7 @@ oxr_action_get_current_interaction_profile(
if (!sess->actionsAttached) { if (!sess->actionsAttached) {
return oxr_error(log, XR_ERROR_ACTIONSET_NOT_ATTACHED, return oxr_error(log, XR_ERROR_ACTIONSET_NOT_ATTACHED,
" xrAttachSessionActionSets has not been " "xrAttachSessionActionSets has not been "
"called on this session."); "called on this session.");
} }
@ -431,7 +431,7 @@ oxr_action_get_current_interaction_profile(
interactionProfile->interactionProfile = sess->gamepad; interactionProfile->interactionProfile = sess->gamepad;
} else { } else {
return oxr_error(log, XR_ERROR_HANDLE_INVALID, return oxr_error(log, XR_ERROR_HANDLE_INVALID,
" not implemented"); "Not implemented");
} }
return XR_SUCCESS; return XR_SUCCESS;
} }
@ -446,7 +446,7 @@ oxr_action_get_input_source_localized_name(
char *buffer) char *buffer)
{ {
//! @todo Implement //! @todo Implement
return oxr_error(log, XR_ERROR_HANDLE_INVALID, " not implemented"); return oxr_error(log, XR_ERROR_HANDLE_INVALID, "Not implemented");
} }
XrResult XrResult
@ -458,5 +458,5 @@ oxr_action_enumerate_bound_sources(struct oxr_logger *log,
XrPath *sources) XrPath *sources)
{ {
//! @todo Implement //! @todo Implement
return oxr_error(log, XR_ERROR_HANDLE_INVALID, " not implemented"); return oxr_error(log, XR_ERROR_HANDLE_INVALID, "Not implemented");
} }

View file

@ -110,7 +110,7 @@ oxr_event_alloc(struct oxr_logger *log,
if (event == NULL) { if (event == NULL) {
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, return oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
" out of memory"); "Out of memory");
} }
event->next = NULL; event->next = NULL;

View file

@ -74,7 +74,7 @@ oxr_handle_init(struct oxr_logger *log,
if (parent->state != OXR_HANDLE_STATE_LIVE) { if (parent->state != OXR_HANDLE_STATE_LIVE) {
return oxr_error( return oxr_error(
log, XR_ERROR_RUNTIME_FAILURE, log, XR_ERROR_RUNTIME_FAILURE,
" Handle %p given parent %p in invalid state: %s", "Handle %p given parent %p in invalid state: %s",
(void *)parent, (void *)hb, (void *)parent, (void *)hb,
oxr_handle_state_to_string(parent->state)); oxr_handle_state_to_string(parent->state));
} }
@ -93,7 +93,7 @@ oxr_handle_init(struct oxr_logger *log,
} }
if (!placed) { if (!placed) {
return oxr_error(log, XR_ERROR_LIMIT_REACHED, return oxr_error(log, XR_ERROR_LIMIT_REACHED,
" parent handle has no more room for " "Parent handle has no more room for "
"child handles"); "child handles");
} }
} }
@ -167,7 +167,7 @@ oxr_handle_do_destroy(struct oxr_logger *log,
if (!found) { if (!found) {
return oxr_error( return oxr_error(
log, XR_ERROR_RUNTIME_FAILURE, log, XR_ERROR_RUNTIME_FAILURE,
" parent handle does not refer to this handle"); "Parent handle does not refer to this handle");
} }
/* clear parent pointer */ /* clear parent pointer */

View file

@ -23,9 +23,65 @@
DEBUG_GET_ONCE_BOOL_OPTION(entrypoints, "OXR_DEBUG_ENTRYPOINTS", false) DEBUG_GET_ONCE_BOOL_OPTION(entrypoints, "OXR_DEBUG_ENTRYPOINTS", false)
DEBUG_GET_ONCE_BOOL_OPTION(break_on_error, "OXR_BREAK_ON_ERROR", false) DEBUG_GET_ONCE_BOOL_OPTION(break_on_error, "OXR_BREAK_ON_ERROR", false)
/*
*
* Helpers
*
*/
static const char * static const char *
oxr_result_to_string(XrResult result); oxr_result_to_string(XrResult result);
static bool
is_fmt_func_arg_start(const char *fmt)
{
if (fmt == NULL) {
return false;
}
if (fmt[0] == '(') {
return true;
}
return false;
}
/*!
* Prints the first part of a logging message, has three forms.
*
* ```c++
* print_prefix(l, "(myInfo->foo) is bad", "XR_ERROR_VALIDATION_FAILURE");
* // XR_ERROR_VALIDATION_FAILURE: xrMyFunc(myInfo->foo) is bad
*
* print_prefix(l, "This is bad", "XR_ERROR_VALIDATION_FAILURE");
* // XR_ERROR_VALIDATION_FAILURE in xrMyFunc: This is bad
*
* print_prefix(l, "No functions set now", "LOG");
* // LOG: No function set now
* ```
*/
static void
print_prefix(struct oxr_logger *logger, const char *fmt, const char *prefix)
{
if (logger->api_func_name != NULL) {
if (is_fmt_func_arg_start(fmt)) {
fprintf(stderr, "%s: %s", prefix,
logger->api_func_name);
} else {
fprintf(stderr, "%s in %s: ", prefix,
logger->api_func_name);
}
} else {
fprintf(stderr, "%s: ", prefix);
}
}
/*
*
* 'Exported' functions.
*
*/
void void
oxr_log_init(struct oxr_logger *logger, const char *api_func_name) oxr_log_init(struct oxr_logger *logger, const char *api_func_name)
{ {
@ -46,9 +102,7 @@ oxr_log_set_instance(struct oxr_logger *logger, struct oxr_instance *inst)
void void
oxr_log(struct oxr_logger *logger, const char *fmt, ...) oxr_log(struct oxr_logger *logger, const char *fmt, ...)
{ {
if (logger->api_func_name != NULL) { print_prefix(logger, fmt, "LOG");
fprintf(stderr, " in %s", logger->api_func_name);
}
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
@ -61,11 +115,7 @@ oxr_log(struct oxr_logger *logger, const char *fmt, ...)
void void
oxr_warn(struct oxr_logger *logger, const char *fmt, ...) oxr_warn(struct oxr_logger *logger, const char *fmt, ...)
{ {
if (logger->api_func_name != NULL) { print_prefix(logger, fmt, "WARNING");
fprintf(stderr, "%s WARNING: ", logger->api_func_name);
} else {
fprintf(stderr, "WARNING: ");
}
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
@ -82,13 +132,8 @@ oxr_error(struct oxr_logger *logger, XrResult result, const char *fmt, ...)
fprintf(stderr, "\t"); fprintf(stderr, "\t");
} }
fprintf(stderr, "%s", oxr_result_to_string(result)); print_prefix(logger, fmt, oxr_result_to_string(result));
if (logger->api_func_name != NULL) {
fprintf(stderr, " in %s", logger->api_func_name);
}
fprintf(stderr, ": ");
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
vfprintf(stderr, fmt, args); vfprintf(stderr, fmt, args);

View file

@ -91,7 +91,7 @@ oxr_session_enumerate_formats(struct oxr_logger *log,
struct xrt_compositor *xc = sess->compositor; struct xrt_compositor *xc = sess->compositor;
if (formatCountOutput == NULL) { if (formatCountOutput == NULL) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"(formatCountOutput)"); "(formatCountOutput == NULL) can not be null");
} }
if (xc == NULL) { if (xc == NULL) {
if (formatCountOutput != NULL) { if (formatCountOutput != NULL) {
@ -112,7 +112,7 @@ oxr_session_begin(struct oxr_logger *log,
{ {
if (is_running(sess)) { if (is_running(sess)) {
return oxr_error(log, XR_ERROR_SESSION_RUNNING, return oxr_error(log, XR_ERROR_SESSION_RUNNING,
" session is already running"); "Session is already running");
} }
struct xrt_compositor *xc = sess->compositor; struct xrt_compositor *xc = sess->compositor;
@ -125,7 +125,9 @@ oxr_session_begin(struct oxr_logger *log,
* system right now */ * system right now */
return oxr_error( return oxr_error(
log, XR_ERROR_VIEW_CONFIGURATION_TYPE_UNSUPPORTED, log, XR_ERROR_VIEW_CONFIGURATION_TYPE_UNSUPPORTED,
" view configuration type not supported"); "(beginInfo->primaryViewConfigurationType == "
"0x%08x) view configuration type not supported",
view_type);
} }
xrt_comp_begin_session(xc, (enum xrt_view_type)beginInfo xrt_comp_begin_session(xc, (enum xrt_view_type)beginInfo
@ -144,11 +146,11 @@ oxr_session_end(struct oxr_logger *log, struct oxr_session *sess)
if (!is_running(sess)) { if (!is_running(sess)) {
return oxr_error(log, XR_ERROR_SESSION_NOT_RUNNING, return oxr_error(log, XR_ERROR_SESSION_NOT_RUNNING,
" session is not running"); "Session is not running");
} }
if (sess->state != XR_SESSION_STATE_STOPPING) { if (sess->state != XR_SESSION_STATE_STOPPING) {
return oxr_error(log, XR_ERROR_SESSION_NOT_STOPPING, return oxr_error(log, XR_ERROR_SESSION_NOT_STOPPING,
" session is not stopping"); "Session is not stopping");
} }
if (xc != NULL) { if (xc != NULL) {
@ -177,7 +179,7 @@ oxr_session_request_exit(struct oxr_logger *log, struct oxr_session *sess)
{ {
if (!is_running(sess)) { if (!is_running(sess)) {
return oxr_error(log, XR_ERROR_SESSION_NOT_RUNNING, return oxr_error(log, XR_ERROR_SESSION_NOT_RUNNING,
" session is not running"); "Session is not running");
} }
if (sess->state == XR_SESSION_STATE_FOCUSED) { if (sess->state == XR_SESSION_STATE_FOCUSED) {
@ -399,7 +401,7 @@ oxr_session_frame_wait(struct oxr_logger *log,
{ {
if (!is_running(sess)) { if (!is_running(sess)) {
return oxr_error(log, XR_ERROR_SESSION_NOT_RUNNING, return oxr_error(log, XR_ERROR_SESSION_NOT_RUNNING,
" session is not running"); "Session is not running");
} }
//! @todo this should be carefully synchronized, because there may be //! @todo this should be carefully synchronized, because there may be
@ -420,7 +422,7 @@ oxr_session_frame_wait(struct oxr_logger *log,
if ((int64_t)predicted_display_time <= 0) { if ((int64_t)predicted_display_time <= 0) {
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, return oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
" got a negative display time '%" PRIi64 "'", "Got a negative display time '%" PRIi64 "'",
(int64_t)predicted_display_time); (int64_t)predicted_display_time);
} }
@ -432,7 +434,7 @@ oxr_session_frame_wait(struct oxr_logger *log,
if (frameState->predictedDisplayTime <= 0) { if (frameState->predictedDisplayTime <= 0) {
return oxr_error( return oxr_error(
log, XR_ERROR_RUNTIME_FAILURE, log, XR_ERROR_RUNTIME_FAILURE,
" time_state_monotonic_to_ts_ns returned '%" PRIi64 "'", "Time_state_monotonic_to_ts_ns returned '%" PRIi64 "'",
frameState->predictedDisplayTime); frameState->predictedDisplayTime);
} }
@ -452,7 +454,7 @@ oxr_session_frame_begin(struct oxr_logger *log, struct oxr_session *sess)
{ {
if (!is_running(sess)) { if (!is_running(sess)) {
return oxr_error(log, XR_ERROR_SESSION_NOT_RUNNING, return oxr_error(log, XR_ERROR_SESSION_NOT_RUNNING,
" session is not running"); "Session is not running");
} }
struct xrt_compositor *xc = sess->compositor; struct xrt_compositor *xc = sess->compositor;
@ -786,11 +788,11 @@ oxr_session_frame_end(struct oxr_logger *log,
if (!is_running(sess)) { if (!is_running(sess)) {
return oxr_error(log, XR_ERROR_SESSION_NOT_RUNNING, return oxr_error(log, XR_ERROR_SESSION_NOT_RUNNING,
" session is not running"); "Session is not running");
} }
if (!sess->frame_started) { if (!sess->frame_started) {
return oxr_error(log, XR_ERROR_CALL_ORDER_INVALID, return oxr_error(log, XR_ERROR_CALL_ORDER_INVALID,
" frame not begun with xrBeginFrame"); "Frame not begun with xrBeginFrame");
} }
if (frameEndInfo->displayTime <= 0) { if (frameEndInfo->displayTime <= 0) {
@ -1034,7 +1036,8 @@ oxr_session_create_impl(struct oxr_logger *log,
return XR_SUCCESS; return XR_SUCCESS;
} }
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"(createInfo->next->type)"); "(createInfo->next->type) doesn't contain a valid "
"graphics binding structs");
} }
XrResult XrResult

View file

@ -47,21 +47,22 @@ oxr_session_populate_egl(struct oxr_logger *log,
PFNEGLQUERYCONTEXTPROC eglQueryContext = PFNEGLQUERYCONTEXTPROC eglQueryContext =
(PFNEGLQUERYCONTEXTPROC)next->getProcAddress("eglQueryContext"); (PFNEGLQUERYCONTEXTPROC)next->getProcAddress("eglQueryContext");
if (!eglQueryContext) { if (!eglQueryContext) {
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, return oxr_error(
"getProcAddress(eglQueryContext) failed"); log, XR_ERROR_INITIALIZATION_FAILED,
"Call to getProcAddress(eglQueryContext) failed");
} }
if (!eglQueryContext(next->display, next->context, if (!eglQueryContext(next->display, next->context,
EGL_CONTEXT_CLIENT_TYPE, &egl_client_type)) { EGL_CONTEXT_CLIENT_TYPE, &egl_client_type)) {
return oxr_error( return oxr_error(
log, XR_ERROR_INITIALIZATION_FAILED, log, XR_ERROR_INITIALIZATION_FAILED,
"eglQueryContext(EGL_CONTEXT_CLIENT_TYPE) failed"); "Call to eglQueryContext(EGL_CONTEXT_CLIENT_TYPE) failed");
} }
if (egl_client_type != EGL_OPENGL_API && if (egl_client_type != EGL_OPENGL_API &&
egl_client_type != EGL_OPENGL_ES_API) { egl_client_type != EGL_OPENGL_ES_API) {
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
"unsupported EGL client type"); "Unsupported EGL client type");
} }
struct xrt_compositor_fd *xcfd = NULL; struct xrt_compositor_fd *xcfd = NULL;
@ -69,7 +70,7 @@ oxr_session_populate_egl(struct oxr_logger *log,
true, &xcfd); true, &xcfd);
if (ret < 0 || xcfd == NULL) { if (ret < 0 || xcfd == NULL) {
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
" failed create a fd compositor '%i'", ret); "Failed create a fd compositor '%i'", ret);
} }
struct xrt_compositor_gl *xcgl = struct xrt_compositor_gl *xcgl =
@ -79,7 +80,7 @@ oxr_session_populate_egl(struct oxr_logger *log,
if (xcgl == NULL) { if (xcgl == NULL) {
xcfd->base.destroy(&xcfd->base); xcfd->base.destroy(&xcfd->base);
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
" failed create a egl client compositor"); "Failed create a egl client compositor");
} }
sess->compositor = &xcgl->base; sess->compositor = &xcgl->base;

View file

@ -38,7 +38,7 @@ oxr_session_populate_gl_xlib(struct oxr_logger *log,
true, &xcfd); true, &xcfd);
if (ret < 0 || xcfd == NULL) { if (ret < 0 || xcfd == NULL) {
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
" failed create a fd compositor '%i'", ret); "Failed create a fd compositor '%i'", ret);
} }
@ -49,7 +49,7 @@ oxr_session_populate_gl_xlib(struct oxr_logger *log,
if (xcgl == NULL) { if (xcgl == NULL) {
xcfd->base.destroy(&xcfd->base); xcfd->base.destroy(&xcfd->base);
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
" failed create a xlib client compositor"); "Failed create a xlib client compositor");
} }
sess->compositor = &xcgl->base; sess->compositor = &xcgl->base;

View file

@ -32,7 +32,7 @@ oxr_session_populate_vk(struct oxr_logger *log,
false, &xcfd); false, &xcfd);
if (ret < 0 || xcfd == NULL) { if (ret < 0 || xcfd == NULL) {
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
" failed create a fd compositor '%i'", ret); "Failed create a fd compositor '%i'", ret);
} }
struct xrt_compositor_vk *xcvk = xrt_gfx_vk_provider_create( struct xrt_compositor_vk *xcvk = xrt_gfx_vk_provider_create(
@ -42,7 +42,7 @@ oxr_session_populate_vk(struct oxr_logger *log,
if (xcvk == NULL) { if (xcvk == NULL) {
xcfd->base.destroy(&xcfd->base); xcfd->base.destroy(&xcfd->base);
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
" failed create a vk client compositor"); "Failed create a vk client compositor");
} }
sess->compositor = &xcvk->base; sess->compositor = &xcvk->base;

View file

@ -37,8 +37,8 @@ check_reference_space_type(struct oxr_logger *log, XrReferenceSpaceType type)
#endif #endif
default: default:
return oxr_error(log, XR_ERROR_REFERENCE_SPACE_UNSUPPORTED, return oxr_error(log, XR_ERROR_REFERENCE_SPACE_UNSUPPORTED,
"(createInfo->referenceSpaceType = " "(createInfo->referenceSpaceType == 0x%08x)",
"<UNKNOWN>)"); type);
} }
} }
@ -222,7 +222,7 @@ oxr_space_action_relation(struct oxr_logger *log,
// Internal error check. // Internal error check.
if (act_spc == NULL || act_spc->is_reference || ref_spc == NULL || if (act_spc == NULL || act_spc->is_reference || ref_spc == NULL ||
!ref_spc->is_reference) { !ref_spc->is_reference) {
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, "this is bad!"); return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, "This is bad!");
} }
// Reset so no relation is returned. // Reset so no relation is returned.

View file

@ -28,7 +28,7 @@ oxr_swapchain_acquire_image(struct oxr_logger *log,
uint32_t index; uint32_t index;
if (sc->acquired.num >= sc->swapchain->num_images) { if (sc->acquired.num >= sc->swapchain->num_images) {
return oxr_error(log, XR_ERROR_CALL_ORDER_INVALID, return oxr_error(log, XR_ERROR_CALL_ORDER_INVALID,
" all images have been acquired"); "All images have been acquired");
} }
if (sc->is_static && (sc->released.yes || sc->waited.yes)) { if (sc->is_static && (sc->released.yes || sc->waited.yes)) {
@ -39,7 +39,7 @@ oxr_swapchain_acquire_image(struct oxr_logger *log,
struct xrt_swapchain *xsc = (struct xrt_swapchain *)sc->swapchain; struct xrt_swapchain *xsc = (struct xrt_swapchain *)sc->swapchain;
if (!xsc->acquire_image(xsc, &index)) { if (!xsc->acquire_image(xsc, &index)) {
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, return oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
" call to xsc->acquire_image failed"); "Call to xsc->acquire_image failed");
} }
if (sc->images[index].state != OXR_IMAGE_STATE_READY) { if (sc->images[index].state != OXR_IMAGE_STATE_READY) {
@ -72,12 +72,12 @@ oxr_swapchain_wait_image(struct oxr_logger *log,
if (sc->waited.yes) { if (sc->waited.yes) {
return oxr_error( return oxr_error(
log, XR_ERROR_CALL_ORDER_INVALID, log, XR_ERROR_CALL_ORDER_INVALID,
" swapchain has already been waited, call release"); "Swapchain has already been waited, call release");
} }
if (u_index_fifo_is_empty(&sc->acquired.fifo)) { if (u_index_fifo_is_empty(&sc->acquired.fifo)) {
return oxr_error(log, XR_ERROR_CALL_ORDER_INVALID, return oxr_error(log, XR_ERROR_CALL_ORDER_INVALID,
" no image acquired"); "No image acquired");
} }
uint32_t index; uint32_t index;
@ -86,7 +86,7 @@ oxr_swapchain_wait_image(struct oxr_logger *log,
struct xrt_swapchain *xsc = (struct xrt_swapchain *)sc->swapchain; struct xrt_swapchain *xsc = (struct xrt_swapchain *)sc->swapchain;
if (!xsc->wait_image(xsc, waitInfo->timeout, index)) { if (!xsc->wait_image(xsc, waitInfo->timeout, index)) {
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, return oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
" call to xsc->wait_image failed"); "Call to xsc->wait_image failed");
} }
// The app can only wait on one image. // The app can only wait on one image.
@ -104,7 +104,7 @@ oxr_swapchain_release_image(struct oxr_logger *log,
{ {
if (!sc->waited.yes) { if (!sc->waited.yes) {
return oxr_error(log, XR_ERROR_CALL_ORDER_INVALID, return oxr_error(log, XR_ERROR_CALL_ORDER_INVALID,
" no swapchain images waited on"); "No swapchain images waited on");
} }
sc->waited.yes = false; sc->waited.yes = false;
@ -113,7 +113,7 @@ oxr_swapchain_release_image(struct oxr_logger *log,
struct xrt_swapchain *xsc = (struct xrt_swapchain *)sc->swapchain; struct xrt_swapchain *xsc = (struct xrt_swapchain *)sc->swapchain;
if (!xsc->release_image(xsc, index)) { if (!xsc->release_image(xsc, index)) {
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, return oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
" call to xsc->release_image failed"); "Call to xsc->release_image failed");
} }
// Only decerement here. // Only decerement here.
@ -192,7 +192,7 @@ oxr_create_swapchain(struct oxr_logger *log,
if (xsc == NULL) { if (xsc == NULL) {
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, return oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
" failed to create swapchain"); "Failed to create swapchain");
} }
struct oxr_swapchain *sc = NULL; struct oxr_swapchain *sc = NULL;

View file

@ -63,7 +63,7 @@ oxr_swapchain_gl_enumerate_images(struct oxr_logger *log,
break; break;
default: default:
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"unsupported XrSwapchainImageBaseHeader type"); "Unsupported XrSwapchainImageBaseHeader type");
} }
for (uint32_t i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
@ -71,7 +71,7 @@ oxr_swapchain_gl_enumerate_images(struct oxr_logger *log,
(gles_imgs != NULL && (gles_imgs != NULL &&
gles_imgs[i].type != images[0].type)) { gles_imgs[i].type != images[0].type)) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"images array contains mixed types"); "Images array contains mixed types");
} }
if (gl_imgs != NULL) { if (gl_imgs != NULL) {
gl_imgs[i].image = xsc->images[i]; gl_imgs[i].image = xsc->images[i];

View file

@ -79,7 +79,7 @@ oxr_system_verify_id(struct oxr_logger *log,
{ {
if (systemId != 1) { if (systemId != 1) {
return oxr_error(log, XR_ERROR_SYSTEM_INVALID, return oxr_error(log, XR_ERROR_SYSTEM_INVALID,
"invalid system %" PRIu64, systemId); "Invalid system %" PRIu64, systemId);
} }
return XR_SUCCESS; return XR_SUCCESS;
} }
@ -124,7 +124,7 @@ oxr_system_fill_in(struct oxr_logger *log,
if (head == NULL) { if (head == NULL) {
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
" failed to probe device"); "Failed to probe device");
} }
if (head->tracking_origin->type == XRT_TRACKING_TYPE_NONE) { if (head->tracking_origin->type == XRT_TRACKING_TYPE_NONE) {
@ -266,7 +266,7 @@ oxr_system_get_view_conf_properties(
if (viewConfigurationType != sys->view_config_type) { if (viewConfigurationType != sys->view_config_type) {
return oxr_error(log, return oxr_error(log,
XR_ERROR_VIEW_CONFIGURATION_TYPE_UNSUPPORTED, XR_ERROR_VIEW_CONFIGURATION_TYPE_UNSUPPORTED,
"invalid view configuration type"); "Invalid view configuration type");
} }
// clang-format off // clang-format off
@ -303,7 +303,7 @@ oxr_system_enumerate_view_conf_views(
if (viewConfigurationType != sys->view_config_type) { if (viewConfigurationType != sys->view_config_type) {
return oxr_error(log, return oxr_error(log,
XR_ERROR_VIEW_CONFIGURATION_TYPE_UNSUPPORTED, XR_ERROR_VIEW_CONFIGURATION_TYPE_UNSUPPORTED,
"invalid view configuration type"); "Invalid view configuration type");
} }
OXR_TWO_CALL_FILL_IN_HELPER(log, viewCapacityInput, viewCountOutput, OXR_TWO_CALL_FILL_IN_HELPER(log, viewCapacityInput, viewCountOutput,

View file

@ -466,7 +466,7 @@ oxr_verify_XrSessionCreateInfo(struct oxr_logger *log,
if (createInfo->createFlags != 0) { if (createInfo->createFlags != 0) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
" Non-zero session create flags"); "Non-zero session create flags");
} }
XrResult result = oxr_system_verify_id(log, inst, createInfo->systemId); XrResult result = oxr_system_verify_id(log, inst, createInfo->systemId);
@ -568,7 +568,7 @@ oxr_verify_XrGraphicsBindingVulkanKHR(struct oxr_logger *log,
{ {
if (next->type != XR_TYPE_GRAPHICS_BINDING_VULKAN_KHR) { if (next->type != XR_TYPE_GRAPHICS_BINDING_VULKAN_KHR) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
" Graphics binding has invalid type"); "Graphics binding has invalid type");
} }
return XR_SUCCESS; return XR_SUCCESS;
@ -585,7 +585,7 @@ oxr_verify_XrGraphicsBindingEGLMNDX(struct oxr_logger *log,
{ {
if (next->type != XR_TYPE_GRAPHICS_BINDING_EGL_MNDX) { if (next->type != XR_TYPE_GRAPHICS_BINDING_EGL_MNDX) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
" Graphics binding has invalid type"); "Graphics binding has invalid type");
} }
return XR_SUCCESS; return XR_SUCCESS;

View file

@ -83,29 +83,31 @@ oxr_vk_get_physical_device(struct oxr_logger *log,
vk_ret = vkEnumeratePhysicalDevices(vkInstance, &count, NULL); vk_ret = vkEnumeratePhysicalDevices(vkInstance, &count, NULL);
if (vk_ret != VK_SUCCESS) { if (vk_ret != VK_SUCCESS) {
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, return oxr_error(
" vkEnumeratePhysicalDevices returned %u", log, XR_ERROR_RUNTIME_FAILURE,
vk_ret); "Call to vkEnumeratePhysicalDevices returned %u", vk_ret);
} }
if (count == 0) { if (count == 0) {
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, return oxr_error(
" vkEnumeratePhysicalDevices returned zero " log, XR_ERROR_RUNTIME_FAILURE,
"VkPhysicalDevices"); "Call to vkEnumeratePhysicalDevices returned zero "
"VkPhysicalDevices");
} }
VkPhysicalDevice *phys = U_TYPED_ARRAY_CALLOC(VkPhysicalDevice, count); VkPhysicalDevice *phys = U_TYPED_ARRAY_CALLOC(VkPhysicalDevice, count);
vk_ret = vkEnumeratePhysicalDevices(vkInstance, &count, phys); vk_ret = vkEnumeratePhysicalDevices(vkInstance, &count, phys);
if (vk_ret != VK_SUCCESS) { if (vk_ret != VK_SUCCESS) {
free(phys); free(phys);
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, return oxr_error(
" vkEnumeratePhysicalDevices returned %u", log, XR_ERROR_RUNTIME_FAILURE,
vk_ret); "Call to vkEnumeratePhysicalDevices returned %u", vk_ret);
} }
if (count == 0) { if (count == 0) {
free(phys); free(phys);
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, return oxr_error(
" vkEnumeratePhysicalDevices returned zero " log, XR_ERROR_RUNTIME_FAILURE,
"VkPhysicalDevices"); "Call to vkEnumeratePhysicalDevices returned zero "
"VkPhysicalDevices");
} }
if (count > 1) { if (count > 1) {