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

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

Issue 12226039: Reland 179911 and 179910 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1364/src
Patch Set: Delta from original landing that's necessary for M25 (not ToT) Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/service/gpu_scheduler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "gpu/command_buffer/service/gpu_scheduler.h" 5 #include "gpu/command_buffer/service/gpu_scheduler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (!PollUnscheduleFences()) 58 if (!PollUnscheduleFences())
59 return; 59 return;
60 60
61 // One of the unschedule fence tasks might have unscheduled us. 61 // One of the unschedule fence tasks might have unscheduled us.
62 if (!IsScheduled()) 62 if (!IsScheduled())
63 return; 63 return;
64 64
65 base::TimeTicks begin_time(base::TimeTicks::HighResNow()); 65 base::TimeTicks begin_time(base::TimeTicks::HighResNow());
66 error::Error error = error::kNoError; 66 error::Error error = error::kNoError;
67 while (!parser_->IsEmpty()) { 67 while (!parser_->IsEmpty()) {
68 if (preempt_by_counter_.get() && 68 if (IsPreempted())
69 !was_preempted_ &&
70 !preempt_by_counter_->IsZero()) {
71 TRACE_COUNTER_ID1("gpu","GpuScheduler::Preempted", this, 1);
72 was_preempted_ = true;
73 break; 69 break;
74 } else if (was_preempted_) {
75 TRACE_COUNTER_ID1("gpu","GpuScheduler::Preempted", this, 0);
76 was_preempted_ = false;
77 }
78 70
79 DCHECK(IsScheduled()); 71 DCHECK(IsScheduled());
80 DCHECK(unschedule_fences_.empty()); 72 DCHECK(unschedule_fences_.empty());
81 73
82 error = parser_->ProcessCommand(); 74 error = parser_->ProcessCommand();
83 75
84 if (error == error::kDeferCommandUntilLater) { 76 if (error == error::kDeferCommandUntilLater) {
85 DCHECK(unscheduled_count_ > 0); 77 DCHECK(unscheduled_count_ > 0);
86 break; 78 break;
87 } 79 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 while (!unschedule_fences_.empty()) { 240 while (!unschedule_fences_.empty()) {
249 unschedule_fences_.front()->task.Run(); 241 unschedule_fences_.front()->task.Run();
250 unschedule_fences_.pop(); 242 unschedule_fences_.pop();
251 SetScheduled(true); 243 SetScheduled(true);
252 } 244 }
253 } 245 }
254 246
255 return true; 247 return true;
256 } 248 }
257 249
250 bool GpuScheduler::IsPreempted() {
251 if (!preemption_flag_.get())
252 return false;
253
254 if (!was_preempted_ && !preemption_flag_->IsSet()) {
255 TRACE_COUNTER_ID1("gpu", "GpuScheduler::Preempted", this, 1);
256 was_preempted_ = true;
257 } else if (was_preempted_) {
258 TRACE_COUNTER_ID1("gpu", "GpuScheduler::Preempted", this, 0);
259 was_preempted_ = false;
260 }
261
262 return !preemption_flag_->IsSet();
263 }
264
258 void GpuScheduler::RescheduleTimeOut() { 265 void GpuScheduler::RescheduleTimeOut() {
259 int new_count = unscheduled_count_ + rescheduled_count_; 266 int new_count = unscheduled_count_ + rescheduled_count_;
260 267
261 rescheduled_count_ = 0; 268 rescheduled_count_ = 0;
262 269
263 while (unscheduled_count_) 270 while (unscheduled_count_)
264 SetScheduled(true); 271 SetScheduled(true);
265 272
266 rescheduled_count_ = new_count; 273 rescheduled_count_ = new_count;
267 } 274 }
268 275
269 GpuScheduler::UnscheduleFence::UnscheduleFence( 276 GpuScheduler::UnscheduleFence::UnscheduleFence(
270 gfx::GLFence* fence_, base::Closure task_): fence(fence_), task(task_) { 277 gfx::GLFence* fence_, base::Closure task_): fence(fence_), task(task_) {
271 } 278 }
272 279
273 GpuScheduler::UnscheduleFence::~UnscheduleFence() { 280 GpuScheduler::UnscheduleFence::~UnscheduleFence() {
274 } 281 }
275 282
276 } // namespace gpu 283 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gpu_scheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698