Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3882)

Unified Diff: chrome/browser/android/vr_shell/vr_shell_gl.cc

Issue 2941913002: WebVR: Fix missing sample collection for prediction timing (Closed)
Patch Set: Rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_gl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/vr_shell_gl.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell_gl.cc b/chrome/browser/android/vr_shell/vr_shell_gl.cc
index 5af608969e685903c419e404b6bcbdedb822b0c6..459b623d8e11d2ed55ada17cd767fbedfaa1fa40 100644
--- a/chrome/browser/android/vr_shell/vr_shell_gl.cc
+++ b/chrome/browser/android/vr_shell/vr_shell_gl.cc
@@ -380,6 +380,9 @@ void VrShellGl::SubmitWebVRFrame(int16_t frame_index,
DCHECK(submit_client_.get());
TRACE_EVENT0("gpu", "VrShellGl::SubmitWebVRFrame");
+ webvr_time_js_submit_[frame_index % kPoseRingBufferSize] =
+ base::TimeTicks::Now();
+
// Swapping twice on a Surface without calling updateTexImage in
// between can lose frames, so don't draw+swap if we already have
// a pending frame we haven't consumed yet.
@@ -450,6 +453,8 @@ void VrShellGl::InitializeRenderer() {
vr::Mat4f head_pose;
device::GvrDelegate::GetGvrPoseWithNeckModel(gvr_api_.get(), &head_pose);
webvr_head_pose_.assign(kPoseRingBufferSize, head_pose);
+ webvr_time_pose_.assign(kPoseRingBufferSize, base::TimeTicks());
+ webvr_time_js_submit_.assign(kPoseRingBufferSize, base::TimeTicks());
std::vector<gvr::BufferSpec> specs;
// For kFramePrimaryBuffer (primary VrShell and WebVR content)
@@ -1105,6 +1110,20 @@ void VrShellGl::DrawFrameSubmitWhenReady(int16_t frame_index,
submit_client_->OnSubmitFrameRendered();
}
+ if (ShouldDrawWebVr()) {
+ base::TimeTicks now = base::TimeTicks::Now();
+ base::TimeTicks pose_time =
+ webvr_time_pose_[frame_index % kPoseRingBufferSize];
+ base::TimeTicks js_submit_time =
+ webvr_time_js_submit_[frame_index % kPoseRingBufferSize];
+ int64_t pose_to_js_submit_us =
+ (js_submit_time - pose_time).InMicroseconds();
+ webvr_js_time_->AddSample(pose_to_js_submit_us);
+ int64_t js_submit_to_gvr_submit_us =
+ (now - js_submit_time).InMicroseconds();
+ webvr_render_time_->AddSample(js_submit_to_gvr_submit_us);
+ }
+
// After saving the timestamp, fps will be available via GetFPS().
// TODO(vollick): enable rendering of this framerate in a HUD.
fps_meter_->AddFrame(base::TimeTicks::Now());
@@ -1585,6 +1604,7 @@ void VrShellGl::SendVSync(base::TimeDelta time, GetVSyncCallback callback) {
prediction_nanos);
webvr_head_pose_[frame_index % kPoseRingBufferSize] = head_mat;
+ webvr_time_pose_[frame_index % kPoseRingBufferSize] = base::TimeTicks::Now();
std::move(callback).Run(std::move(pose), time, frame_index,
device::mojom::VRVSyncProvider::Status::SUCCESS);
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_gl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698