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

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

Issue 1331843005: Implemented new fence syncs which replaces the old sync points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Forgot to remove cmd buffer helper functios and replace with gpu control ones Created 5 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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/sequence_checker.h" 18 #include "base/sequence_checker.h"
19 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
20 #include "base/thread_task_runner_handle.h" 20 #include "base/thread_task_runner_handle.h"
21 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" 21 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
22 #include "gpu/command_buffer/common/gles2_cmd_format.h"
22 #include "gpu/command_buffer/common/value_state.h" 23 #include "gpu/command_buffer/common/value_state.h"
23 #include "gpu/command_buffer/service/command_buffer_service.h" 24 #include "gpu/command_buffer/service/command_buffer_service.h"
24 #include "gpu/command_buffer/service/context_group.h" 25 #include "gpu/command_buffer/service/context_group.h"
25 #include "gpu/command_buffer/service/gl_context_virtual.h" 26 #include "gpu/command_buffer/service/gl_context_virtual.h"
26 #include "gpu/command_buffer/service/gpu_scheduler.h" 27 #include "gpu/command_buffer/service/gpu_scheduler.h"
27 #include "gpu/command_buffer/service/gpu_switches.h" 28 #include "gpu/command_buffer/service/gpu_switches.h"
28 #include "gpu/command_buffer/service/image_factory.h" 29 #include "gpu/command_buffer/service/image_factory.h"
29 #include "gpu/command_buffer/service/image_manager.h" 30 #include "gpu/command_buffer/service/image_manager.h"
30 #include "gpu/command_buffer/service/mailbox_manager.h" 31 #include "gpu/command_buffer/service/mailbox_manager.h"
31 #include "gpu/command_buffer/service/memory_program_cache.h" 32 #include "gpu/command_buffer/service/memory_program_cache.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 176 }
176 177
177 InProcessCommandBuffer::InProcessCommandBuffer( 178 InProcessCommandBuffer::InProcessCommandBuffer(
178 const scoped_refptr<Service>& service) 179 const scoped_refptr<Service>& service)
179 : command_buffer_id_(g_next_command_buffer_id.GetNext()), 180 : command_buffer_id_(g_next_command_buffer_id.GetNext()),
180 context_lost_(false), 181 context_lost_(false),
181 delayed_work_pending_(false), 182 delayed_work_pending_(false),
182 image_factory_(nullptr), 183 image_factory_(nullptr),
183 last_put_offset_(-1), 184 last_put_offset_(-1),
184 gpu_memory_buffer_manager_(nullptr), 185 gpu_memory_buffer_manager_(nullptr),
186 next_fence_sync_release_(1),
187 flushed_fence_sync_release_(0),
185 flush_event_(false, false), 188 flush_event_(false, false),
186 service_(GetInitialService(service)), 189 service_(GetInitialService(service)),
187 gpu_thread_weak_ptr_factory_(this) { 190 gpu_thread_weak_ptr_factory_(this) {
188 DCHECK(service_.get()); 191 DCHECK(service_.get());
189 next_image_id_.GetNext(); 192 next_image_id_.GetNext();
190 } 193 }
191 194
192 InProcessCommandBuffer::~InProcessCommandBuffer() { 195 InProcessCommandBuffer::~InProcessCommandBuffer() {
193 Destroy(); 196 Destroy();
194 } 197 }
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 555
553 SyncPointManager* sync_manager = service_->sync_point_manager(); 556 SyncPointManager* sync_manager = service_->sync_point_manager();
554 const uint32_t order_num = 557 const uint32_t order_num =
555 sync_point_client_state_->GenerateUnprocessedOrderNumber(sync_manager); 558 sync_point_client_state_->GenerateUnprocessedOrderNumber(sync_manager);
556 last_put_offset_ = put_offset; 559 last_put_offset_ = put_offset;
557 base::Closure task = base::Bind(&InProcessCommandBuffer::FlushOnGpuThread, 560 base::Closure task = base::Bind(&InProcessCommandBuffer::FlushOnGpuThread,
558 gpu_thread_weak_ptr_, 561 gpu_thread_weak_ptr_,
559 put_offset, 562 put_offset,
560 order_num); 563 order_num);
561 QueueTask(task); 564 QueueTask(task);
565
566 flushed_fence_sync_release_ = next_fence_sync_release_ - 1;
562 } 567 }
563 568
564 void InProcessCommandBuffer::OrderingBarrier(int32 put_offset) { 569 void InProcessCommandBuffer::OrderingBarrier(int32 put_offset) {
565 Flush(put_offset); 570 Flush(put_offset);
566 } 571 }
567 572
568 void InProcessCommandBuffer::WaitForTokenInRange(int32 start, int32 end) { 573 void InProcessCommandBuffer::WaitForTokenInRange(int32 start, int32 end) {
569 CheckSequencedThread(); 574 CheckSequencedThread();
570 while (!InRange(start, end, GetLastToken()) && 575 while (!InRange(start, end, GetLastToken()) &&
571 last_state_.error == gpu::error::kNoError) 576 last_state_.error == gpu::error::kNoError)
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 795
791 void InProcessCommandBuffer::RetireSyncPointOnGpuThread(uint32 sync_point) { 796 void InProcessCommandBuffer::RetireSyncPointOnGpuThread(uint32 sync_point) {
792 gles2::MailboxManager* mailbox_manager = 797 gles2::MailboxManager* mailbox_manager =
793 decoder_->GetContextGroup()->mailbox_manager(); 798 decoder_->GetContextGroup()->mailbox_manager();
794 if (mailbox_manager->UsesSync()) { 799 if (mailbox_manager->UsesSync()) {
795 bool make_current_success = false; 800 bool make_current_success = false;
796 { 801 {
797 base::AutoLock lock(command_buffer_lock_); 802 base::AutoLock lock(command_buffer_lock_);
798 make_current_success = MakeCurrent(); 803 make_current_success = MakeCurrent();
799 } 804 }
800 if (make_current_success) 805 if (make_current_success) {
801 mailbox_manager->PushTextureUpdates(sync_point); 806 gles2::SyncToken sync_token = {
807 GetNamespaceID(),
808 GetCommandBufferID(),
809 sync_point
810 };
811 mailbox_manager->PushTextureUpdates(sync_token);
812 }
802 } 813 }
803 service_->sync_point_manager()->RetireSyncPoint(sync_point); 814 service_->sync_point_manager()->RetireSyncPoint(sync_point);
804 } 815 }
805 816
806 void InProcessCommandBuffer::SignalSyncPoint(unsigned sync_point, 817 void InProcessCommandBuffer::SignalSyncPoint(unsigned sync_point,
807 const base::Closure& callback) { 818 const base::Closure& callback) {
808 CheckSequencedThread(); 819 CheckSequencedThread();
809 QueueTask(base::Bind(&InProcessCommandBuffer::SignalSyncPointOnGpuThread, 820 QueueTask(base::Bind(&InProcessCommandBuffer::SignalSyncPointOnGpuThread,
810 base::Unretained(this), 821 base::Unretained(this),
811 sync_point, 822 sync_point,
812 WrapCallback(callback))); 823 WrapCallback(callback)));
813 } 824 }
814 825
815 bool InProcessCommandBuffer::WaitSyncPointOnGpuThread(unsigned sync_point) { 826 bool InProcessCommandBuffer::WaitSyncPointOnGpuThread(unsigned sync_point) {
816 service_->sync_point_manager()->WaitSyncPoint(sync_point); 827 service_->sync_point_manager()->WaitSyncPoint(sync_point);
817 gles2::MailboxManager* mailbox_manager = 828 gles2::MailboxManager* mailbox_manager =
818 decoder_->GetContextGroup()->mailbox_manager(); 829 decoder_->GetContextGroup()->mailbox_manager();
819 mailbox_manager->PullTextureUpdates(sync_point); 830 gles2::SyncToken sync_token = {
831 GetNamespaceID(),
832 GetCommandBufferID(),
833 sync_point
834 };
835 mailbox_manager->PullTextureUpdates(sync_token);
820 return true; 836 return true;
821 } 837 }
822 838
823 void InProcessCommandBuffer::SignalSyncPointOnGpuThread( 839 void InProcessCommandBuffer::SignalSyncPointOnGpuThread(
824 unsigned sync_point, 840 unsigned sync_point,
825 const base::Closure& callback) { 841 const base::Closure& callback) {
826 service_->sync_point_manager()->AddSyncPointCallback(sync_point, callback); 842 service_->sync_point_manager()->AddSyncPointCallback(sync_point, callback);
827 } 843 }
828 844
829 void InProcessCommandBuffer::SignalQuery(unsigned query_id, 845 void InProcessCommandBuffer::SignalQuery(unsigned query_id,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 } 889 }
874 890
875 CommandBufferNamespace InProcessCommandBuffer::GetNamespaceID() const { 891 CommandBufferNamespace InProcessCommandBuffer::GetNamespaceID() const {
876 return CommandBufferNamespace::IN_PROCESS; 892 return CommandBufferNamespace::IN_PROCESS;
877 } 893 }
878 894
879 uint64_t InProcessCommandBuffer::GetCommandBufferID() const { 895 uint64_t InProcessCommandBuffer::GetCommandBufferID() const {
880 return command_buffer_id_; 896 return command_buffer_id_;
881 } 897 }
882 898
899 uint32_t InProcessCommandBuffer::GenerateFenceSyncRelease() {
900 return next_fence_sync_release_++;
901 }
902
903 bool InProcessCommandBuffer::IsFenceSyncRelease(uint32_t release) {
904 return release != 0 && release < next_fence_sync_release_;
905 }
906
907 bool InProcessCommandBuffer::IsFenceSyncFlushed(uint32_t release) {
908 return release <= flushed_fence_sync_release_;
909 }
910
883 uint32 InProcessCommandBuffer::CreateStreamTextureOnGpuThread( 911 uint32 InProcessCommandBuffer::CreateStreamTextureOnGpuThread(
884 uint32 client_texture_id) { 912 uint32 client_texture_id) {
885 #if defined(OS_ANDROID) 913 #if defined(OS_ANDROID)
886 return stream_texture_manager_->CreateStreamTexture( 914 return stream_texture_manager_->CreateStreamTexture(
887 client_texture_id, decoder_->GetContextGroup()->texture_manager()); 915 client_texture_id, decoder_->GetContextGroup()->texture_manager());
888 #else 916 #else
889 return 0; 917 return 0;
890 #endif 918 #endif
891 } 919 }
892 920
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 framebuffer_completeness_cache_ = 1015 framebuffer_completeness_cache_ =
988 new gpu::gles2::FramebufferCompletenessCache; 1016 new gpu::gles2::FramebufferCompletenessCache;
989 return framebuffer_completeness_cache_; 1017 return framebuffer_completeness_cache_;
990 } 1018 }
991 1019
992 SyncPointManager* GpuInProcessThread::sync_point_manager() { 1020 SyncPointManager* GpuInProcessThread::sync_point_manager() {
993 return sync_point_manager_; 1021 return sync_point_manager_;
994 } 1022 }
995 1023
996 } // namespace gpu 1024 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698