Commit f8413731 authored by Klaus Weidner's avatar Klaus Weidner Committed by Commit Bot

Fix DCHECK for VR Browsing's gpu trace fence

This fence is used to measure render time in VR Browsing mode. Replacing the
gpu_fence_ member after GVR Submit has a race condition - GVR internally
creates a fence when submitting and blocks the next Submit until the previous
submitted frame's fence is complete, but the separate render time fence was
created after submitting, so we may end up with a situation where this second
fence hasn't registered as complete yet.

Update the order to create the new fence first in a locally scoped variable
before GVR submit, then overwrite the previous fence only after GVR submit
completes.

BUG=854347

Change-Id: I8359f67859016039b2ddf5d54d5f391c5e212918
Reviewed-on: https://chromium-review.googlesource.com/1107013Reviewed-by: default avatarBill Orr <billorr@chromium.org>
Commit-Queue: Klaus Weidner <klausw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568694}
parent b9e188de
...@@ -1877,6 +1877,18 @@ void VrShellGl::DrawFrameSubmitNow(int16_t frame_index, ...@@ -1877,6 +1877,18 @@ void VrShellGl::DrawFrameSubmitNow(int16_t frame_index,
TransformToGvrMat(head_pose, &mat); TransformToGvrMat(head_pose, &mat);
bool is_webvr_frame = frame_index >= 0; bool is_webvr_frame = frame_index >= 0;
{ {
std::unique_ptr<ScopedGpuTrace> browser_gpu_trace;
if (gl::GLFence::IsGpuFenceSupported() && !is_webvr_frame) {
// This fence instance is created for the tracing side effect. Insert it
// before GVR submit. Then replace the previous instance below after GVR
// submit completes, at which point the previous fence (if any) should be
// complete. Doing this in two steps avoids a race condition - a fence
// that was inserted after Submit may not be complete yet when the next
// Submit finishes.
browser_gpu_trace = std::make_unique<ScopedGpuTrace>(
"gpu", "VrShellGl::PostSubmitDrawOnGpu");
}
TRACE_EVENT0("gpu", "VrShellGl::SubmitToGvr"); TRACE_EVENT0("gpu", "VrShellGl::SubmitToGvr");
base::TimeTicks submit_start = base::TimeTicks::Now(); base::TimeTicks submit_start = base::TimeTicks::Now();
acquired_frame_.Submit(viewport_list_, mat); acquired_frame_.Submit(viewport_list_, mat);
...@@ -1884,13 +1896,11 @@ void VrShellGl::DrawFrameSubmitNow(int16_t frame_index, ...@@ -1884,13 +1896,11 @@ void VrShellGl::DrawFrameSubmitNow(int16_t frame_index,
webvr_submit_time_.AddSample(submit_done - submit_start); webvr_submit_time_.AddSample(submit_done - submit_start);
CHECK(!acquired_frame_); CHECK(!acquired_frame_);
if (gl::GLFence::IsGpuFenceSupported() && !is_webvr_frame) { if (browser_gpu_trace) {
// This instance is created for the tracing side effect. Create a new // Replacing the previous instance will record the trace result for
// instance here to replace previous instace will record trace for // the previous instance.
// previous instance and start a new trace for the new instance.
DCHECK(!gpu_trace_ || gpu_trace_->fence()->HasCompleted()); DCHECK(!gpu_trace_ || gpu_trace_->fence()->HasCompleted());
gpu_trace_ = std::make_unique<ScopedGpuTrace>( gpu_trace_ = std::move(browser_gpu_trace);
"gpu", "VrShellGl::PostSubmitDrawOnGpu");
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment