Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of time #230

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
cd webxr
cargo build --features=glwindow,headless
cargo build --features=ipc,glwindow,headless
cargo build --features=glwindow,headless,profile
cargo build --features=glwindow,headless
mac:
runs-on: macos-latest
steps:
Expand All @@ -39,7 +39,7 @@ jobs:
cd webxr
cargo build --features=glwindow,headless
cargo build --features=ipc,glwindow,headless
cargo build --features=glwindow,headless,profile
cargo build --features=glwindow,headless
win:
runs-on: windows-latest
steps:
Expand All @@ -50,7 +50,7 @@ jobs:
cd webxr
cargo build --features=glwindow,headless
cargo build --features=ipc,glwindow,headless
cargo build --features=glwindow,headless,profile
cargo build --features=glwindow,headless
rustup target add aarch64-pc-windows-msvc
cargo build --target=aarch64-pc-windows-msvc --features ipc,openxr-api
build_result:
Expand Down
1 change: 0 additions & 1 deletion webxr-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ path = "lib.rs"

[features]
ipc = ["serde", "ipc-channel", "euclid/serde"]
profile = ["time"]

[dependencies]
euclid = "0.22"
Expand Down
6 changes: 0 additions & 6 deletions webxr-api/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ pub struct Frame {
/// The subimages to render to
pub sub_images: Vec<SubImages>,

/// Value of time::precise_time_ns() when frame was obtained
pub time_ns: u64,

/// The time the frame was sent (only set with the profile feature)
pub sent_time: u64,

/// The hit test results for this frame, if any
pub hit_test_results: Vec<HitTestResult>,
}
Expand Down
58 changes: 4 additions & 54 deletions webxr-api/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ impl SessionInit {
}
}

#[cfg(feature = "profile")]
fn to_ms(ns: u64) -> f64 {
ns as f64 / 1_000_000.
}

/// https://immersive-web.github.io/webxr-ar-module/#xrenvironmentblendmode-enum
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "ipc", derive(Serialize, Deserialize))]
Expand All @@ -119,7 +114,7 @@ enum SessionMsg {
SetEventDest(Sender<Event>),
UpdateClipPlanes(/* near */ f32, /* far */ f32),
StartRenderLoop,
RenderAnimationFrame(/* request time */ u64),
RenderAnimationFrame,
RequestHitTest(HitTestSource),
CancelHitTest(HitTestId),
Quit,
Expand Down Expand Up @@ -221,13 +216,7 @@ impl Session {
}

pub fn render_animation_frame(&mut self) {
#[allow(unused)]
let mut time = 0;
#[cfg(feature = "profile")]
{
time = time::precise_time_ns();
}
let _ = self.sender.send(SessionMsg::RenderAnimationFrame(time));
let _ = self.sender.send(SessionMsg::RenderAnimationFrame);
}

pub fn end_session(&mut self) {
Expand Down Expand Up @@ -376,35 +365,16 @@ where
let _ = self.frame_sender.send(frame);
}
SessionMsg::UpdateClipPlanes(near, far) => self.device.update_clip_planes(near, far),
SessionMsg::RenderAnimationFrame(_sent_time) => {
SessionMsg::RenderAnimationFrame => {
self.frame_count += 1;
#[cfg(feature = "profile")]
let render_start = time::precise_time_ns();
#[cfg(feature = "profile")]
println!(
"WEBXR PROFILING [raf transmitted]:\t{}ms",
to_ms(render_start - _sent_time)
);

#[cfg(feature = "profile")]
let end_frame = time::precise_time_ns();

self.device.end_animation_frame(&self.layers[..]);

if self.render_state == RenderState::PendingQuit {
self.quit();
return false;
}

#[cfg(feature = "profile")]
let ended_frame = time::precise_time_ns();
#[cfg(feature = "profile")]
println!(
"WEBXR PROFILING [raf end frame]:\t{}ms",
to_ms(ended_frame - end_frame)
);

#[cfg(feature = "profile")]
let begin_frame = time::precise_time_ns();
if let Some(layers) = self.pending_layers.take() {
self.layers = layers;
}
Expand All @@ -416,16 +386,6 @@ where
return false;
}
};
#[cfg(feature = "profile")]
let begun_frame = time::precise_time_ns();
#[cfg(feature = "profile")]
{
println!(
"WEBXR PROFILING [raf begin frame]:\t{}ms",
to_ms(begun_frame - begin_frame)
);
frame.sent_time = begun_frame;
}

let _ = self.frame_sender.send(frame);
}
Expand Down Expand Up @@ -459,23 +419,13 @@ where
{
fn run_one_frame(&mut self) {
let frame_count = self.frame_count;
#[cfg(feature = "profile")]
let start_run = time::precise_time_ns();
while frame_count == self.frame_count && self.running {
if let Ok(msg) = crate::recv_timeout(&self.receiver, TIMEOUT) {
self.running = self.handle_msg(msg);
} else {
break;
}
}
#[cfg(feature = "profile")]
{
let end_run = time::precise_time_ns();
println!(
"WEBXR PROFILING [run_one_frame]:\t{}ms",
to_ms(end_run - start_run)
);
}
}

fn running(&self) -> bool {
Expand Down
2 changes: 0 additions & 2 deletions webxr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ glwindow = []
headless = []
ipc = ["webxr-api/ipc", "serde"]
openxr-api = ["angle", "openxr", "winapi", "wio", "surfman/sm-angle-default"]
profile = ["webxr-api/profile"]

[dependencies]
webxr-api = { path = "../webxr-api" }
Expand All @@ -36,7 +35,6 @@ openxr = { version = "0.18", optional = true }
serde = { version = "1.0", optional = true }
sparkle = "0.1"
surfman = { version = "0.9", features = ["chains"] }
time = "0.1.42"

[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3", features = ["dxgi", "d3d11", "winerror"], optional = true }
Expand Down
3 changes: 0 additions & 3 deletions webxr/glwindow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ impl DeviceAPI for GlWindowDevice {

fn begin_animation_frame(&mut self, layers: &[(ContextId, LayerId)]) -> Option<Frame> {
log::debug!("Begin animation frame for layers {:?}", layers);
let time_ns = time::precise_time_ns();
let translation = Vector3D::from_untyped(self.window.get_translation());
let translation: RigidTransform3D<_, _, Native> =
RigidTransform3D::from_translation(translation);
Expand All @@ -191,9 +190,7 @@ impl DeviceAPI for GlWindowDevice {
}),
inputs: vec![],
events: vec![],
time_ns,
sub_images,
sent_time: 0,
hit_test_results: vec![],
})
}
Expand Down
3 changes: 0 additions & 3 deletions webxr/headless/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ macro_rules! with_all_sessions {

impl HeadlessDeviceData {
fn get_frame(&self, s: &PerSessionData, sub_images: Vec<SubImages>) -> Frame {
let time_ns = time::precise_time_ns();
let views = self.views.clone();

let pose = self.viewer_origin.map(|transform| {
Expand Down Expand Up @@ -358,9 +357,7 @@ impl HeadlessDeviceData {
pose,
inputs,
events: vec![],
time_ns,
sub_images,
sent_time: 0,
hit_test_results: vec![],
}
}
Expand Down
3 changes: 0 additions & 3 deletions webxr/openxr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,6 @@ impl DeviceAPI for OpenXrDevice {

let mut guard = self.shared_data.lock().unwrap();
let data = guard.as_mut().unwrap();
let time_ns = time::precise_time_ns();

// XXXManishearth should we check frame_state.should_render?
let (_view_flags, mut views) = match self.session.locate_views(
Expand Down Expand Up @@ -1327,9 +1326,7 @@ impl DeviceAPI for OpenXrDevice {
pose: Some(ViewerPose { transform, views }),
inputs: vec![right.frame, left.frame],
events: vec![],
time_ns,
sub_images,
sent_time: 0,
hit_test_results: vec![],
};

Expand Down
Loading