aboutsummaryrefslogtreecommitdiffstats
path: root/components/canvas_traits/webgl.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2020-02-23 08:55:33 -0500
committerGitHub <noreply@github.com>2020-02-23 08:55:33 -0500
commit6bc4a7df24df6c7ed41f2ee4c2d38a282760c2b6 (patch)
treefcbe9ebb7584055afbae43b26f65365bb93f30bf /components/canvas_traits/webgl.rs
parent504eeb803d67864efbaa370a2f4f0db5afe71275 (diff)
parentf3e1aba4e3bc1f715cebdca3d00734ab29b63d9b (diff)
downloadservo-6bc4a7df24df6c7ed41f2ee4c2d38a282760c2b6.tar.gz
servo-6bc4a7df24df6c7ed41f2ee4c2d38a282760c2b6.zip
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
Diffstat (limited to 'components/canvas_traits/webgl.rs')
-rw-r--r--components/canvas_traits/webgl.rs24
1 files changed, 21 insertions, 3 deletions
diff --git a/components/canvas_traits/webgl.rs b/components/canvas_traits/webgl.rs
index 6d3bd9bdc09..6709137b34e 100644
--- a/components/canvas_traits/webgl.rs
+++ b/components/canvas_traits/webgl.rs
@@ -82,7 +82,11 @@ pub enum WebGLMsg {
WebGLSender<Option<WebXRSwapChainId>>,
),
/// Performs a buffer swap.
- SwapBuffers(Vec<SwapChainId>, WebGLSender<()>),
+ ///
+ /// The third field contains the time (in ns) when the request
+ /// was initiated. The u64 in the second field will be the time the
+ /// request is fulfilled
+ SwapBuffers(Vec<SwapChainId>, WebGLSender<u64>, u64),
/// Frees all resources and closes the thread.
Exit,
}
@@ -195,9 +199,23 @@ impl WebGLMsgSender {
.map(|id| SwapChainId::Framebuffer(self.ctx_id, id))
.unwrap_or_else(|| SwapChainId::Context(self.ctx_id));
let (sender, receiver) = webgl_channel()?;
+ #[allow(unused)]
+ let mut time = 0;
+ #[cfg(feature = "xr-profile")]
+ {
+ time = time::precise_time_ns();
+ }
+
self.sender
- .send(WebGLMsg::SwapBuffers(vec![swap_id], sender))?;
- receiver.recv()?;
+ .send(WebGLMsg::SwapBuffers(vec![swap_id], sender, time))?;
+
+ #[allow(unused)]
+ let sent_time = receiver.recv()?;
+ #[cfg(feature = "xr-profile")]
+ println!(
+ "WEBXR PROFILING [swap complete]:\t{}ms",
+ (time::precise_time_ns() - sent_time) as f64 / 1_000_000.
+ );
Ok(())
}