aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2020-02-19 17:23:39 -0800
committerManish Goregaokar <manishsmail@gmail.com>2020-02-22 22:00:05 -0800
commitf3e1aba4e3bc1f715cebdca3d00734ab29b63d9b (patch)
tree5727da14674281210bb57e3263df815d45daccad /components/script/dom
parent52c9cce4c4adae7f90369903c37552fbe09d2657 (diff)
downloadservo-f3e1aba4e3bc1f715cebdca3d00734ab29b63d9b.tar.gz
servo-f3e1aba4e3bc1f715cebdca3d00734ab29b63d9b.zip
Add profiling for WebXR
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/document.rs8
-rw-r--r--components/script/dom/xrsession.rs26
2 files changed, 32 insertions, 2 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 3049d4f0bd6..6ee46bea95b 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -2530,11 +2530,17 @@ impl Document {
return;
}
+ #[allow(unused)]
+ let mut time = 0;
+ #[cfg(feature = "xr-profile")]
+ {
+ time = time::precise_time_ns();
+ }
let (sender, receiver) = webgl::webgl_channel().unwrap();
self.window
.webgl_chan()
.expect("Where's the WebGL channel?")
- .send(WebGLMsg::SwapBuffers(dirty_context_ids, sender))
+ .send(WebGLMsg::SwapBuffers(dirty_context_ids, sender, time))
.unwrap();
receiver.recv().unwrap();
}
diff --git a/components/script/dom/xrsession.rs b/components/script/dom/xrsession.rs
index 09aa2c7c854..62d9c15f3d6 100644
--- a/components/script/dom/xrsession.rs
+++ b/components/script/dom/xrsession.rs
@@ -164,10 +164,21 @@ impl XRSession {
ROUTER.add_route(
frame_receiver.to_opaque(),
Box::new(move |message| {
+ #[allow(unused)]
+ let mut frame: Frame = message.to().unwrap();
+ #[cfg(feature = "xr-profile")]
+ {
+ let received = time::precise_time_ns();
+ println!(
+ "WEBXR PROFILING [raf receive]:\t{}ms",
+ (received - frame.sent_time) as f64 / 1_000_000.
+ );
+ frame.sent_time = received;
+ }
let this = this.clone();
let _ = task_source.queue_with_canceller(
task!(xr_raf_callback: move || {
- this.root().raf_callback(message.to().unwrap());
+ this.root().raf_callback(frame);
}),
&canceller,
);
@@ -333,6 +344,13 @@ impl XRSession {
/// https://immersive-web.github.io/webxr/#xr-animation-frame
fn raf_callback(&self, mut frame: Frame) {
debug!("WebXR RAF callback");
+ #[cfg(feature = "xr-profile")]
+ let raf_start = time::precise_time_ns();
+ #[cfg(feature = "xr-profile")]
+ println!(
+ "WEBXR PROFILING [raf queued]:\t{}ms",
+ (raf_start - frame.sent_time) as f64 / 1_000_000.
+ );
// Step 1
if let Some(pending) = self.pending_render_state.take() {
@@ -389,6 +407,12 @@ impl XRSession {
self.session.borrow_mut().start_render_loop();
}
+ #[cfg(feature = "xr-profile")]
+ println!(
+ "WEBXR PROFILING [raf execute]:\t{}ms",
+ (time::precise_time_ns() - raf_start) as f64 / 1_000_000.
+ );
+
// If the canvas element is attached to the DOM, it is now dirty,
// and we need to trigger a reflow.
base_layer