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

Side by Side Diff: gpu/command_buffer/service/in_process_command_buffer.cc

Issue 661973003: MailboxSync: Imply fence with sync point (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mac Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/in_process_command_buffer.h" 5 #include "gpu/command_buffer/service/in_process_command_buffer.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 void SyncPointManager::WaitSyncPoint(uint32 sync_point) { 170 void SyncPointManager::WaitSyncPoint(uint32 sync_point) {
171 base::AutoLock lock(lock_); 171 base::AutoLock lock(lock_);
172 while (pending_sync_points_.count(sync_point)) { 172 while (pending_sync_points_.count(sync_point)) {
173 cond_var_.Wait(); 173 cond_var_.Wait();
174 } 174 }
175 } 175 }
176 176
177 base::LazyInstance<SyncPointManager> g_sync_point_manager = 177 base::LazyInstance<SyncPointManager> g_sync_point_manager =
178 LAZY_INSTANCE_INITIALIZER; 178 LAZY_INSTANCE_INITIALIZER;
179 179
180 bool WaitSyncPoint(uint32 sync_point) {
181 g_sync_point_manager.Get().WaitSyncPoint(sync_point);
182 return true;
183 }
184
185 } // anonyous namespace 180 } // anonyous namespace
186 181
187 InProcessCommandBuffer::Service::Service() {} 182 InProcessCommandBuffer::Service::Service() {}
188 183
189 InProcessCommandBuffer::Service::~Service() {} 184 InProcessCommandBuffer::Service::~Service() {}
190 185
191 scoped_refptr<gles2::MailboxManager> 186 scoped_refptr<gles2::MailboxManager>
192 InProcessCommandBuffer::Service::mailbox_manager() { 187 InProcessCommandBuffer::Service::mailbox_manager() {
193 if (!mailbox_manager_.get()) 188 if (!mailbox_manager_.get())
194 mailbox_manager_ = new gles2::MailboxManager(); 189 mailbox_manager_ = new gles2::MailboxManager();
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 LOG(ERROR) << "Could not initialize decoder."; 410 LOG(ERROR) << "Could not initialize decoder.";
416 DestroyOnGpuThread(); 411 DestroyOnGpuThread();
417 return false; 412 return false;
418 } 413 }
419 *params.capabilities = decoder_->GetCapabilities(); 414 *params.capabilities = decoder_->GetCapabilities();
420 415
421 if (!params.is_offscreen) { 416 if (!params.is_offscreen) {
422 decoder_->SetResizeCallback(base::Bind( 417 decoder_->SetResizeCallback(base::Bind(
423 &InProcessCommandBuffer::OnResizeView, gpu_thread_weak_ptr_)); 418 &InProcessCommandBuffer::OnResizeView, gpu_thread_weak_ptr_));
424 } 419 }
425 decoder_->SetWaitSyncPointCallback(base::Bind(&WaitSyncPoint)); 420 decoder_->SetWaitSyncPointCallback(
421 base::Bind(&InProcessCommandBuffer::WaitSyncPointOnGpuThread,
422 base::Unretained(this)));
426 423
427 return true; 424 return true;
428 } 425 }
429 426
430 void InProcessCommandBuffer::Destroy() { 427 void InProcessCommandBuffer::Destroy() {
431 CheckSequencedThread(); 428 CheckSequencedThread();
432 429
433 base::WaitableEvent completion(true, false); 430 base::WaitableEvent completion(true, false);
434 bool result = false; 431 bool result = false;
435 base::Callback<bool(void)> destroy_task = base::Bind( 432 base::Callback<bool(void)> destroy_task = base::Bind(
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 void InProcessCommandBuffer::RetireSyncPointOnGpuThread(uint32 sync_point) { 648 void InProcessCommandBuffer::RetireSyncPointOnGpuThread(uint32 sync_point) {
652 gles2::MailboxManager* mailbox_manager = 649 gles2::MailboxManager* mailbox_manager =
653 decoder_->GetContextGroup()->mailbox_manager(); 650 decoder_->GetContextGroup()->mailbox_manager();
654 if (mailbox_manager->UsesSync()) { 651 if (mailbox_manager->UsesSync()) {
655 bool make_current_success = false; 652 bool make_current_success = false;
656 { 653 {
657 base::AutoLock lock(command_buffer_lock_); 654 base::AutoLock lock(command_buffer_lock_);
658 make_current_success = MakeCurrent(); 655 make_current_success = MakeCurrent();
659 } 656 }
660 if (make_current_success) 657 if (make_current_success)
661 mailbox_manager->PushTextureUpdates(); 658 mailbox_manager->PushTextureUpdates(sync_point);
662 } 659 }
663 g_sync_point_manager.Get().RetireSyncPoint(sync_point); 660 g_sync_point_manager.Get().RetireSyncPoint(sync_point);
664 } 661 }
665 662
666 void InProcessCommandBuffer::SignalSyncPoint(unsigned sync_point, 663 void InProcessCommandBuffer::SignalSyncPoint(unsigned sync_point,
667 const base::Closure& callback) { 664 const base::Closure& callback) {
668 CheckSequencedThread(); 665 CheckSequencedThread();
669 QueueTask(base::Bind(&InProcessCommandBuffer::SignalSyncPointOnGpuThread, 666 QueueTask(base::Bind(&InProcessCommandBuffer::SignalSyncPointOnGpuThread,
670 base::Unretained(this), 667 base::Unretained(this),
671 sync_point, 668 sync_point,
672 WrapCallback(callback))); 669 WrapCallback(callback)));
673 } 670 }
674 671
672 bool InProcessCommandBuffer::WaitSyncPointOnGpuThread(unsigned sync_point) {
673 g_sync_point_manager.Get().WaitSyncPoint(sync_point);
674 gles2::MailboxManager* mailbox_manager =
675 decoder_->GetContextGroup()->mailbox_manager();
676 mailbox_manager->PullTextureUpdates(sync_point);
677 return true;
678 }
679
675 void InProcessCommandBuffer::SignalSyncPointOnGpuThread( 680 void InProcessCommandBuffer::SignalSyncPointOnGpuThread(
676 unsigned sync_point, 681 unsigned sync_point,
677 const base::Closure& callback) { 682 const base::Closure& callback) {
678 if (g_sync_point_manager.Get().IsSyncPointPassed(sync_point)) { 683 if (g_sync_point_manager.Get().IsSyncPointPassed(sync_point)) {
679 callback.Run(); 684 callback.Run();
680 } else { 685 } else {
681 service_->ScheduleIdleWork( 686 service_->ScheduleIdleWork(
682 base::Bind(&InProcessCommandBuffer::SignalSyncPointOnGpuThread, 687 base::Bind(&InProcessCommandBuffer::SignalSyncPointOnGpuThread,
683 gpu_thread_weak_ptr_, 688 gpu_thread_weak_ptr_,
684 sync_point, 689 sync_point,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 783
779 #if defined(OS_ANDROID) 784 #if defined(OS_ANDROID)
780 scoped_refptr<gfx::SurfaceTexture> 785 scoped_refptr<gfx::SurfaceTexture>
781 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { 786 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) {
782 DCHECK(stream_texture_manager_); 787 DCHECK(stream_texture_manager_);
783 return stream_texture_manager_->GetSurfaceTexture(stream_id); 788 return stream_texture_manager_->GetSurfaceTexture(stream_id);
784 } 789 }
785 #endif 790 #endif
786 791
787 } // namespace gpu 792 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/in_process_command_buffer.h ('k') | gpu/command_buffer/service/mailbox_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698