feat: impl Pipelined Rendering

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2025-10-21 00:09:17 +02:00
parent 08cec3c700
commit 05d4670609
8 changed files with 50 additions and 27 deletions

View File

@@ -3,7 +3,7 @@ use std::sync::Arc;
use bevy::prelude::*;
use bevy_mod_openxr::{
helper_traits::{ToQuat as _, ToVec3 as _},
resources::OxrFrameState,
resources::{OxrFrameState, Pipelined},
session::OxrSession,
};
use bevy_mod_xr::{
@@ -12,7 +12,7 @@ use bevy_mod_xr::{
};
use openxr::SpaceLocationFlags;
use crate::{DbusConnection, PreFrameWait, nodes::spatial::Spatial};
use crate::{DbusConnection, PreFrameWait, get_time, nodes::spatial::Spatial};
use super::{ObjectHandle, SpatialRef, input::mouse_pointer::FlatscreenCam};
@@ -68,6 +68,7 @@ fn update_xr(
ref_space: Option<Res<XrPrimaryReferenceSpace>>,
hmd: Res<Hmd>,
state: Option<Res<OxrFrameState>>,
pipelined: Option<Res<Pipelined>>,
) {
let (Some(session), Some(view), Some(ref_space), Some(state)) =
(session, hmd.space, ref_space, state)
@@ -80,9 +81,9 @@ fn update_xr(
// });
return;
};
// this won't be correct with pipelined rendering
let time = get_time(pipelined.is_some(), &state);
let location = session
.locate_space(&view, &ref_space, state.predicted_display_time)
.locate_space(&view, &ref_space, time)
.inspect_err(|err| error!("Error while Locating OpenXR Stage Space {err}"));
if let Ok(location) = location {
let is_tracked = location

View File

@@ -2,6 +2,7 @@ use super::{CaptureManager, get_sorted_handlers};
use crate::{
DbusConnection, PreFrameWait,
core::client::INTERNAL_CLIENT,
get_time,
nodes::{
Node, OwnedNode,
drawable::{
@@ -19,7 +20,7 @@ use bevy::{math::Affine3, prelude::*};
use bevy_mod_openxr::{
action_binding::{OxrSendActionBindings, OxrSuggestActionBinding},
helper_traits::{ToIsometry3d, ToVec2},
resources::{OxrFrameState, OxrInstance},
resources::{OxrFrameState, OxrInstance, Pipelined},
session::OxrSession,
};
use bevy_mod_xr::{
@@ -147,6 +148,7 @@ fn update(
session: Option<Res<OxrSession>>,
ref_space: Option<Res<XrPrimaryReferenceSpace>>,
state: Option<Res<OxrFrameState>>,
pipelined: Option<Res<Pipelined>>,
) {
let (Some(session), Some(state), Some(ref_space)) = (session, state, ref_space) else {
controllers.left.set_enabled(false);
@@ -158,8 +160,7 @@ fn update(
.sync_actions(&[ActiveActionSet::new(&actions.set)])
.unwrap();
});
let time = state.predicted_display_time;
// stupid bevy gltf loading issue (rotated 180 degrees on the y axis)
let time = get_time(pipelined.is_some(), &state);
controllers
.left
.update(&session, &actions, time, ref_space.0);

View File

@@ -8,11 +8,11 @@ use crate::nodes::{
spatial::Spatial,
};
use crate::objects::{AsyncTracked, ObjectHandle, SpatialRef, Tracked};
use crate::{BevyMaterial, DbusConnection, ObjectRegistryRes, PreFrameWait};
use crate::{BevyMaterial, DbusConnection, ObjectRegistryRes, PreFrameWait, get_time};
use bevy::prelude::Transform as BevyTransform;
use bevy::prelude::*;
use bevy_mod_openxr::helper_traits::{ToQuat, ToVec3};
use bevy_mod_openxr::resources::OxrFrameState;
use bevy_mod_openxr::resources::{OxrFrameState, Pipelined};
use bevy_mod_openxr::session::OxrSession;
use bevy_mod_xr::hands::{HandBone, HandSide, XrHandBoneEntities, XrHandBoneRadius};
use bevy_mod_xr::session::{XrPreDestroySession, XrSessionCreated};
@@ -50,6 +50,7 @@ fn update_hands(
&mut XrHandBoneRadius,
)>,
joints_query: Query<&XrHandBoneEntities>,
pipelined: Option<Res<Pipelined>>,
) {
let (Some(session), Some(state), Some(ref_space)) = (session, state, ref_space) else {
hands.left.tracked.set_tracked(false);
@@ -62,9 +63,9 @@ fn update_hands(
hand.tracked.set_tracked(false);
return None;
};
// this won't be correct with pipelined rendering
let time = get_time(pipelined.is_some(), &state);
session
.locate_hand_joints(tracker, &ref_space, state.predicted_display_time)
.locate_hand_joints(tracker, &ref_space, time)
.inspect_err(|err| error!("Error while locating hand joints"))
.ok()
.flatten()

View File

@@ -3,7 +3,7 @@ use std::sync::Arc;
use bevy::prelude::*;
use bevy_mod_openxr::{
helper_traits::{ToQuat, ToVec3},
resources::OxrFrameState,
resources::{OxrFrameState, Pipelined},
session::OxrSession,
};
use bevy_mod_xr::{
@@ -14,7 +14,7 @@ use openxr::SpaceLocationFlags;
use parking_lot::RwLock;
use zbus::{Connection, ObjectServer, interface};
use crate::{DbusConnection, PreFrameWait, nodes::spatial::Spatial};
use crate::{DbusConnection, PreFrameWait, get_time, nodes::spatial::Spatial};
use super::{AsyncTracked, ObjectHandle, SpatialRef, Tracked};
@@ -75,6 +75,7 @@ fn update(
ref_space: Option<Res<XrPrimaryReferenceSpace>>,
play_space: Res<PlaySpace>,
state: Option<Res<OxrFrameState>>,
pipelined: Option<Res<Pipelined>>,
) {
let (Some(session), Some(stage), Some(ref_space), Some(state)) =
(session, stage, ref_space, state)
@@ -87,9 +88,9 @@ fn update(
.set_local_transform(Mat4::from_translation(vec3(0.0, -1.65, 0.0)));
return;
};
// this won't be correct with pipelined rendering
let time = get_time(pipelined.is_some(), &state);
let location = session
.locate_space(&stage.0, &ref_space, state.predicted_display_time)
.locate_space(&stage.0, &ref_space, time)
.inspect_err(|err| error!("Error while Locating OpenXR Stage Space {err}"));
if let Ok(location) = location {
let is_tracked = location.location_flags.contains(