Skip to content

Commit

Permalink
Merge pull request #12 from ChristophHaag/openxr_fixes
Browse files Browse the repository at this point in the history
Openxr fixes
  • Loading branch information
BastiaanOlij authored Jan 28, 2022
2 parents 23be0da + 5560652 commit 72fc90a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
29 changes: 18 additions & 11 deletions drivers/openxr/openxr_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,11 @@ bool OpenXRDevice::load_supported_view_configuration_views(XrViewConfigurationTy
view_configuration_views = (XrViewConfigurationView *)memalloc(sizeof(XrViewConfigurationView) * view_count);
ERR_FAIL_NULL_V(view_configuration_views, false);

for (uint32_t i = 0; i < view_count; i++) {
view_configuration_views[i].type = XR_TYPE_VIEW_CONFIGURATION_VIEW;
view_configuration_views[i].next = NULL;
}

result = xrEnumerateViewConfigurationViews(instance, system_id, p_configuration_type, view_count, &view_count, view_configuration_views);
ERR_FAIL_COND_V_MSG(XR_FAILED(result), false, "OpenXR: Failed to enumerate view configurations");

Expand Down Expand Up @@ -1655,17 +1660,19 @@ void OpenXRDevice::pre_render() {
#endif
}

if (frame_state.shouldRender) {
// let's start our frame..
XrFrameBeginInfo frame_begin_info = {
XR_TYPE_FRAME_BEGIN_INFO, // type
nullptr // next
};
result = xrBeginFrame(session, &frame_begin_info);
if (XR_FAILED(result)) {
print_line("OpenXR: failed to being frame [", get_error_string(result), "]");
return;
}
if (!frame_state.shouldRender) {
// TODO: Tell godot not do render VR to save resources.
}

// let's start our frame..
XrFrameBeginInfo frame_begin_info = {
XR_TYPE_FRAME_BEGIN_INFO, // type
nullptr // next
};
result = xrBeginFrame(session, &frame_begin_info);
if (XR_FAILED(result)) {
print_line("OpenXR: failed to being frame [", get_error_string(result), "]");
return;
}
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/openxr/openxr_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class OpenXRDevice {
XrSession session = XR_NULL_HANDLE;
XrSessionState session_state = XR_SESSION_STATE_UNKNOWN;
bool running = false;
XrFrameState frame_state = {};
XrFrameState frame_state = { XR_TYPE_FRAME_STATE, NULL, 0, 0, false };

OpenXRGraphicsExtensionWrapper *graphics_extension = nullptr;
XrSystemGraphicsProperties graphics_properties;
Expand Down

0 comments on commit 72fc90a

Please sign in to comment.