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

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

Issue 586503003: Fixed issue where disjoint timer offsets were incorrectly calculated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only check if offset is 0 for disjoint timers Created 6 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
« no previous file with comments | « no previous file | ui/gl/generate_bindings.py » ('j') | 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_tracer.h" 5 #include "gpu/command_buffer/service/gpu_tracer.h"
6 6
7 #include <deque> 7 #include <deque>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 95 }
96 96
97 void GPUTrace::Start() { 97 void GPUTrace::Start() {
98 TRACE_EVENT_COPY_ASYNC_BEGIN0( 98 TRACE_EVENT_COPY_ASYNC_BEGIN0(
99 TRACE_DISABLED_BY_DEFAULT("gpu.service"), name().c_str(), this); 99 TRACE_DISABLED_BY_DEFAULT("gpu.service"), name().c_str(), this);
100 100
101 switch (tracer_type_) { 101 switch (tracer_type_) {
102 case kTracerTypeInvalid: 102 case kTracerTypeInvalid:
103 break; 103 break;
104 104
105 case kTracerTypeDisjointTimer:
106 // For the disjoint timer, GPU idle team does not seem to increment the
vmiura 2014/09/19 22:55:09 nit: team -> time?
David Yen 2014/09/19 23:01:18 Done.
107 // internal counter. We must calculate the offset before any query. The
108 // good news is any device that supports disjoint timer will also support
109 // glGetInteger64v, so we can query it directly unlike the ARBTimer case.
110 if (offset_ == 0) {
111 GLint64 gl_now = 0;
112 glGetInteger64v(GL_TIMESTAMP, &gl_now);
113 offset_ = base::TimeTicks::NowFromSystemTraceTime().ToInternalValue() -
114 gl_now / base::Time::kNanosecondsPerMicrosecond;
115 }
116
vmiura 2014/09/19 22:55:09 nit: Could you add a comment that this intentional
David Yen 2014/09/19 23:01:18 Done.
105 case kTracerTypeARBTimer: 117 case kTracerTypeARBTimer:
106 case kTracerTypeDisjointTimer:
107 // GL_TIMESTAMP and GL_TIMESTAMP_EXT both have the same value. 118 // GL_TIMESTAMP and GL_TIMESTAMP_EXT both have the same value.
108 glQueryCounter(queries_[0], GL_TIMESTAMP); 119 glQueryCounter(queries_[0], GL_TIMESTAMP);
109 break; 120 break;
110 } 121 }
111 } 122 }
112 123
113 void GPUTrace::End() { 124 void GPUTrace::End() {
114 end_requested_ = true; 125 end_requested_ = true;
115 switch (tracer_type_) { 126 switch (tracer_type_) {
116 case kTracerTypeInvalid: 127 case kTracerTypeInvalid:
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } 346 }
336 347
337 // Clear pending traces if there were are any errors 348 // Clear pending traces if there were are any errors
338 GLenum err = glGetError(); 349 GLenum err = glGetError();
339 if (err != GL_NO_ERROR) 350 if (err != GL_NO_ERROR)
340 traces_.clear(); 351 traces_.clear();
341 } 352 }
342 353
343 void GPUTracer::CalculateTimerOffset() { 354 void GPUTracer::CalculateTimerOffset() {
344 if (tracer_type_ != kTracerTypeInvalid) { 355 if (tracer_type_ != kTracerTypeInvalid) {
345 // If GPU device category is off, invalidate timing sync.
346 if (*gpu_trace_dev_category == '\0') { 356 if (*gpu_trace_dev_category == '\0') {
357 // If GPU device category is off, invalidate timing sync.
347 gpu_timing_synced_ = false; 358 gpu_timing_synced_ = false;
348 return; 359 return;
360 } else if (tracer_type_ == kTracerTypeDisjointTimer) {
361 // Disjoint timers offsets should be calculated before every query.
362 gpu_timing_synced_ = true;
363 timer_offset_ = 0;
349 } 364 }
350 365
351 if (gpu_timing_synced_) 366 if (gpu_timing_synced_)
352 return; 367 return;
353 368
354 TRACE_EVENT0("gpu", "GPUTracer::CalculateTimerOffset"); 369 TRACE_EVENT0("gpu", "GPUTracer::CalculateTimerOffset");
355 370
356 // NOTE(vmiura): It would be better to use glGetInteger64v, however 371 // NOTE(vmiura): It would be better to use glGetInteger64v, however
357 // it's not available everywhere. 372 // it's not available everywhere.
358 GLuint64 gl_now = 0; 373 GLuint64 gl_now = 0;
359 GLuint query; 374 GLuint query;
360 GLint disjoint_value = 0;
361 375
362 if (tracer_type_ == kTracerTypeDisjointTimer) { 376 glGenQueriesARB(1, &query);
363 // Clear the disjoint bit before we do any queries.
364 glGetIntegerv(GL_GPU_DISJOINT_EXT, &disjoint_value);
365 }
vmiura 2014/09/19 22:55:09 Should we clear existing GL_GPU_DISJOINT_EXT value
David Yen 2014/09/19 23:01:18 It gets cleared under BeginDecoding() as well, thi
366 377
367 glFinish(); 378 glFinish();
368 glGenQueriesARB(1, &query);
369 glQueryCounter(query, GL_TIMESTAMP); 379 glQueryCounter(query, GL_TIMESTAMP);
370 glFinish(); 380 glFinish();
371 381
372 glGetQueryObjectui64v(query, GL_QUERY_RESULT, &gl_now); 382 glGetQueryObjectui64v(query, GL_QUERY_RESULT, &gl_now);
373 glDeleteQueriesARB(1, &query); 383 glDeleteQueriesARB(1, &query);
374 384
375 if (tracer_type_ == kTracerTypeDisjointTimer) {
376 glGetIntegerv(GL_GPU_DISJOINT_EXT, &disjoint_value);
377 if (disjoint_value)
378 return;
379 }
380
381 base::TimeTicks system_now = base::TimeTicks::NowFromSystemTraceTime(); 385 base::TimeTicks system_now = base::TimeTicks::NowFromSystemTraceTime();
382 386
383 gl_now /= base::Time::kNanosecondsPerMicrosecond; 387 gl_now /= base::Time::kNanosecondsPerMicrosecond;
384 timer_offset_ = system_now.ToInternalValue() - gl_now; 388 timer_offset_ = system_now.ToInternalValue() - gl_now;
385 gpu_timing_synced_ = true; 389 gpu_timing_synced_ = true;
386 } 390 }
387 } 391 }
388 392
389 void GPUTracer::IssueProcessTask() { 393 void GPUTracer::IssueProcessTask() {
390 if (traces_.empty() || process_posted_) 394 if (traces_.empty() || process_posted_)
391 return; 395 return;
392 396
393 process_posted_ = true; 397 process_posted_ = true;
394 base::MessageLoop::current()->PostDelayedTask( 398 base::MessageLoop::current()->PostDelayedTask(
395 FROM_HERE, 399 FROM_HERE,
396 base::Bind(&GPUTracer::Process, base::AsWeakPtr(this)), 400 base::Bind(&GPUTracer::Process, base::AsWeakPtr(this)),
397 base::TimeDelta::FromMilliseconds(kProcessInterval)); 401 base::TimeDelta::FromMilliseconds(kProcessInterval));
398 } 402 }
399 403
400 } // namespace gles2 404 } // namespace gles2
401 } // namespace gpu 405 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | ui/gl/generate_bindings.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698