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

Unified Diff: third_party/WebKit/Source/modules/vr/VRDisplay.cpp

Issue 2891033002: WebVR: flush before requesting sync token for mailbox (Closed)
Patch Set: Rebase Created 3 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/vr/VRDisplay.cpp
diff --git a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
index 5122c99d42d313daa98f7a7ad95c259908966e61..3201ab4b09aef52ea62219a363d4ac17c5b6a456 100644
--- a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
+++ b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
@@ -523,7 +523,9 @@ void VRDisplay::submitFrame() {
return;
}
+ TRACE_EVENT_BEGIN0("gpu", "VRDisplay::Flush_1");
context_gl_->Flush();
+ TRACE_EVENT_END0("gpu", "VRDisplay::Flush_1");
// Check if the canvas got resized, if yes send a bounds update.
int current_width = rendering_context_->drawingBufferWidth();
@@ -560,8 +562,10 @@ void VRDisplay::submitFrame() {
}
}
+ TRACE_EVENT_BEGIN0("gpu", "VRDisplay::GetImage");
RefPtr<Image> image_ref = rendering_context_->GetImage(
kPreferAcceleration, kSnapshotReasonCreateImageBitmap);
+ TRACE_EVENT_END0("gpu", "VRDisplay::GetImage");
// Hardware-accelerated rendering should always be texture backed,
// as implemented by AcceleratedStaticBitmapImage. Ensure this is
@@ -578,7 +582,9 @@ void VRDisplay::submitFrame() {
// image until the mailbox was consumed.
StaticBitmapImage* static_image =
static_cast<StaticBitmapImage*>(image_ref.Get());
+ TRACE_EVENT_BEGIN0("gpu", "VRDisplay::EnsureMailbox");
static_image->EnsureMailbox();
+ TRACE_EVENT_END0("gpu", "VRDisplay::EnsureMailbox");
if (wait_for_previous_transfer_to_finish) {
// Save a reference to the image to keep it alive until next frame,
@@ -587,9 +593,22 @@ void VRDisplay::submitFrame() {
previous_image_ = std::move(image_ref);
}
+ // Create mailbox and sync token for transfer.
+ TRACE_EVENT_BEGIN0("gpu", "VRDisplay::GetMailbox");
+ auto mailbox = static_image->GetMailbox();
+ TRACE_EVENT_END0("gpu", "VRDisplay::GetMailbox");
+ // Flush to avoid black screen flashes which appear to be related to
+ // "fence sync must be flushed before generating sync token" GL errors.
+ TRACE_EVENT_BEGIN0("gpu", "VRDisplay::Flush_2");
+ context_gl_->Flush();
+ TRACE_EVENT_END0("gpu", "VRDisplay::Flush_2");
+ auto sync_token = static_image->GetSyncToken();
+
// Wait for the previous render to finish, to avoid losing frames in the
// Android Surface / GLConsumer pair. TODO(klausw): make this tunable?
- // Other devices may have different preferences.
+ // Other devices may have different preferences. Do this step as late
+ // as possible before SubmitFrame to ensure we can do as much work as
+ // possible in parallel with the previous frame's rendering.
{
TRACE_EVENT0("gpu", "waitForPreviousRenderToFinish");
while (pending_previous_frame_render_) {
@@ -602,10 +621,11 @@ void VRDisplay::submitFrame() {
pending_previous_frame_render_ = true;
pending_submit_frame_ = true;
- display_->SubmitFrame(
- vr_frame_id_,
- gpu::MailboxHolder(static_image->GetMailbox(),
- static_image->GetSyncToken(), GL_TEXTURE_2D));
+
+ TRACE_EVENT_BEGIN0("gpu", "VRDisplay::SubmitFrame");
+ display_->SubmitFrame(vr_frame_id_,
+ gpu::MailboxHolder(mailbox, sync_token, GL_TEXTURE_2D));
+ TRACE_EVENT_END0("gpu", "VRDisplay::SubmitFrame");
// If preserveDrawingBuffer is false, must clear now. Normally this
// happens as part of compositing, but that's not active while
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698