mirror of
https://github.com/servo/servo.git
synced 2025-07-31 19:20:22 +01:00
Auto merge of #25810 - Manishearth:xr-profile, r=jdm
Add profiling to WebXR Fixes https://github.com/servo/webxr/issues/128 Depends on https://github.com/servo/webxr/pull/131 r? @jdm
This commit is contained in:
commit
6bc4a7df24
12 changed files with 95 additions and 11 deletions
|
@ -22,6 +22,7 @@ js_backtrace = ["backtrace"]
|
|||
refcell_backtrace = ["accountable-refcell"]
|
||||
uwp = ["js/uwp"]
|
||||
vslatestinstalled = ["js/vslatestinstalled"]
|
||||
xr-profile = ["webxr-api/profile"]
|
||||
|
||||
[build-dependencies]
|
||||
phf_codegen = "0.8"
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue