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

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.cc

Issue 1348363003: content/gpu: Simplify stub scheduling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gpu_channel_stream
Patch Set: address comments Created 5 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/hash.h" 8 #include "base/hash.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 requested_attribs_(attribs), 191 requested_attribs_(attribs),
192 gpu_preference_(gpu_preference), 192 gpu_preference_(gpu_preference),
193 use_virtualized_gl_context_(use_virtualized_gl_context), 193 use_virtualized_gl_context_(use_virtualized_gl_context),
194 stream_id_(stream_id), 194 stream_id_(stream_id),
195 route_id_(route_id), 195 route_id_(route_id),
196 surface_id_(surface_id), 196 surface_id_(surface_id),
197 software_(software), 197 software_(software),
198 last_flush_count_(0), 198 last_flush_count_(0),
199 last_memory_allocation_valid_(false), 199 last_memory_allocation_valid_(false),
200 watchdog_(watchdog), 200 watchdog_(watchdog),
201 sync_point_wait_count_(0), 201 waiting_for_sync_point_(false),
202 delayed_work_scheduled_(false), 202 delayed_work_scheduled_(false),
203 previous_processed_num_(0), 203 previous_processed_num_(0),
204 active_url_(active_url), 204 active_url_(active_url),
205 total_gpu_memory_(0) { 205 total_gpu_memory_(0) {
206 active_url_hash_ = base::Hash(active_url.possibly_invalid_spec()); 206 active_url_hash_ = base::Hash(active_url.possibly_invalid_spec());
207 FastSetActiveURL(active_url_, active_url_hash_); 207 FastSetActiveURL(active_url_, active_url_hash_);
208 208
209 gpu::gles2::ContextCreationAttribHelper attrib_parser; 209 gpu::gles2::ContextCreationAttribHelper attrib_parser;
210 attrib_parser.Parse(requested_attribs_); 210 attrib_parser.Parse(requested_attribs_);
211 211
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 base::Bind(&GpuCommandBufferStub::OnWaitSyncPoint, 613 base::Bind(&GpuCommandBufferStub::OnWaitSyncPoint,
614 base::Unretained(this))); 614 base::Unretained(this)));
615 615
616 command_buffer_->SetPutOffsetChangeCallback( 616 command_buffer_->SetPutOffsetChangeCallback(
617 base::Bind(&GpuCommandBufferStub::PutChanged, base::Unretained(this))); 617 base::Bind(&GpuCommandBufferStub::PutChanged, base::Unretained(this)));
618 command_buffer_->SetGetBufferChangeCallback( 618 command_buffer_->SetGetBufferChangeCallback(
619 base::Bind(&gpu::GpuScheduler::SetGetBuffer, 619 base::Bind(&gpu::GpuScheduler::SetGetBuffer,
620 base::Unretained(scheduler_.get()))); 620 base::Unretained(scheduler_.get())));
621 command_buffer_->SetParseErrorCallback( 621 command_buffer_->SetParseErrorCallback(
622 base::Bind(&GpuCommandBufferStub::OnParseError, base::Unretained(this))); 622 base::Bind(&GpuCommandBufferStub::OnParseError, base::Unretained(this)));
623 scheduler_->SetSchedulingChangedCallback( 623 scheduler_->SetSchedulingChangedCallback(base::Bind(
624 base::Bind(&GpuChannel::StubSchedulingChanged, 624 &GpuCommandBufferStub::OnSchedulingChanged, base::Unretained(this)));
625 base::Unretained(channel_)));
626 625
627 if (watchdog_) { 626 if (watchdog_) {
628 scheduler_->SetCommandProcessedCallback( 627 scheduler_->SetCommandProcessedCallback(
629 base::Bind(&GpuCommandBufferStub::OnCommandProcessed, 628 base::Bind(&GpuCommandBufferStub::OnCommandProcessed,
630 base::Unretained(this))); 629 base::Unretained(this)));
631 } 630 }
632 631
633 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); 632 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState);
634 if (!shared_state_shm->Map(kSharedStateSize)) { 633 if (!shared_state_shm->Map(kSharedStateSize)) {
635 DLOG(ERROR) << "Failed to map shared state buffer."; 634 DLOG(ERROR) << "Failed to map shared state buffer.";
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 // Tell the browser about this context loss as well, so it can 710 // Tell the browser about this context loss as well, so it can
712 // determine whether client APIs like WebGL need to be immediately 711 // determine whether client APIs like WebGL need to be immediately
713 // blocked from automatically running. 712 // blocked from automatically running.
714 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); 713 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
715 gpu_channel_manager->Send(new GpuHostMsg_DidLoseContext( 714 gpu_channel_manager->Send(new GpuHostMsg_DidLoseContext(
716 handle_.is_null(), state.context_lost_reason, active_url_)); 715 handle_.is_null(), state.context_lost_reason, active_url_));
717 716
718 CheckContextLost(); 717 CheckContextLost();
719 } 718 }
720 719
720 void GpuCommandBufferStub::OnSchedulingChanged(bool scheduled) {
721 TRACE_EVENT1("gpu", "GpuCommandBufferStub::OnSchedulingChanged", "scheduled",
722 scheduled);
723 channel_->OnStubSchedulingChanged(this, scheduled);
724 }
725
721 void GpuCommandBufferStub::OnWaitForTokenInRange(int32 start, 726 void GpuCommandBufferStub::OnWaitForTokenInRange(int32 start,
722 int32 end, 727 int32 end,
723 IPC::Message* reply_message) { 728 IPC::Message* reply_message) {
724 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnWaitForTokenInRange"); 729 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnWaitForTokenInRange");
725 DCHECK(command_buffer_.get()); 730 DCHECK(command_buffer_.get());
726 CheckContextLost(); 731 CheckContextLost();
727 if (wait_for_token_) 732 if (wait_for_token_)
728 LOG(ERROR) << "Got WaitForToken command while currently waiting for token."; 733 LOG(ERROR) << "Got WaitForToken command while currently waiting for token.";
729 wait_for_token_ = 734 wait_for_token_ =
730 make_scoped_ptr(new WaitForCommandState(start, end, reply_message)); 735 make_scoped_ptr(new WaitForCommandState(start, end, reply_message));
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 gpu::gles2::MailboxManager* mailbox_manager = 898 gpu::gles2::MailboxManager* mailbox_manager =
894 context_group_->mailbox_manager(); 899 context_group_->mailbox_manager();
895 if (mailbox_manager->UsesSync() && MakeCurrent()) 900 if (mailbox_manager->UsesSync() && MakeCurrent())
896 mailbox_manager->PushTextureUpdates(sync_point); 901 mailbox_manager->PushTextureUpdates(sync_point);
897 902
898 GpuChannelManager* manager = channel_->gpu_channel_manager(); 903 GpuChannelManager* manager = channel_->gpu_channel_manager();
899 manager->sync_point_manager()->RetireSyncPoint(sync_point); 904 manager->sync_point_manager()->RetireSyncPoint(sync_point);
900 } 905 }
901 906
902 bool GpuCommandBufferStub::OnWaitSyncPoint(uint32 sync_point) { 907 bool GpuCommandBufferStub::OnWaitSyncPoint(uint32 sync_point) {
908 DCHECK(!waiting_for_sync_point_);
903 if (!sync_point) 909 if (!sync_point)
904 return true; 910 return true;
905 GpuChannelManager* manager = channel_->gpu_channel_manager(); 911 GpuChannelManager* manager = channel_->gpu_channel_manager();
906 if (manager->sync_point_manager()->IsSyncPointRetired(sync_point)) { 912 if (manager->sync_point_manager()->IsSyncPointRetired(sync_point)) {
907 PullTextureUpdates(sync_point); 913 PullTextureUpdates(sync_point);
908 return true; 914 return true;
909 } 915 }
910 916
911 if (sync_point_wait_count_ == 0) { 917 TRACE_EVENT_ASYNC_BEGIN1("gpu", "WaitSyncPoint", this, "GpuCommandBufferStub",
912 TRACE_EVENT_ASYNC_BEGIN1("gpu", "WaitSyncPoint", this, 918 this);
913 "GpuCommandBufferStub", this); 919
914 }
915 scheduler_->SetScheduled(false); 920 scheduler_->SetScheduled(false);
916 ++sync_point_wait_count_; 921 waiting_for_sync_point_ = true;
917 manager->sync_point_manager()->AddSyncPointCallback( 922 manager->sync_point_manager()->AddSyncPointCallback(
918 sync_point, 923 sync_point,
919 base::Bind(&RunOnThread, task_runner_, 924 base::Bind(&RunOnThread, task_runner_,
920 base::Bind(&GpuCommandBufferStub::OnWaitSyncPointCompleted, 925 base::Bind(&GpuCommandBufferStub::OnWaitSyncPointCompleted,
921 this->AsWeakPtr(), sync_point))); 926 this->AsWeakPtr(), sync_point)));
922 return scheduler_->IsScheduled(); 927 return waiting_for_sync_point_;
piman 2015/09/16 23:21:09 return !waiting_for_sync_point_;
sunnyps 2015/09/16 23:38:42 Done.
923 } 928 }
924 929
925 void GpuCommandBufferStub::OnWaitSyncPointCompleted(uint32 sync_point) { 930 void GpuCommandBufferStub::OnWaitSyncPointCompleted(uint32 sync_point) {
931 DCHECK(waiting_for_sync_point_);
932 TRACE_EVENT_ASYNC_END1("gpu", "WaitSyncPoint", this, "GpuCommandBufferStub",
933 this);
926 PullTextureUpdates(sync_point); 934 PullTextureUpdates(sync_point);
927 --sync_point_wait_count_; 935 waiting_for_sync_point_ = false;
928 if (sync_point_wait_count_ == 0) {
929 TRACE_EVENT_ASYNC_END1("gpu", "WaitSyncPoint", this,
930 "GpuCommandBufferStub", this);
931 }
932 scheduler_->SetScheduled(true); 936 scheduler_->SetScheduled(true);
933 } 937 }
934 938
935 void GpuCommandBufferStub::PullTextureUpdates(uint32 sync_point) { 939 void GpuCommandBufferStub::PullTextureUpdates(uint32 sync_point) {
936 gpu::gles2::MailboxManager* mailbox_manager = 940 gpu::gles2::MailboxManager* mailbox_manager =
937 context_group_->mailbox_manager(); 941 context_group_->mailbox_manager();
938 if (mailbox_manager->UsesSync() && MakeCurrent()) 942 if (mailbox_manager->UsesSync() && MakeCurrent())
939 mailbox_manager->PullTextureUpdates(sync_point); 943 mailbox_manager->PullTextureUpdates(sync_point);
940 } 944 }
941 945
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 result)); 1178 result));
1175 } 1179 }
1176 1180
1177 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, 1181 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase,
1178 base::TimeDelta interval) { 1182 base::TimeDelta interval) {
1179 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, 1183 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase,
1180 interval)); 1184 interval));
1181 } 1185 }
1182 1186
1183 } // namespace content 1187 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698