summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authordyen <dyen@chromium.org>2015-02-19 15:22:22 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-19 23:23:08 +0000
commitc2bff8d3e630fb137b949a8cec45b79783b5d25e (patch)
tree5fd92e73ad1805dae3d74efedade5c25191edf3e /gpu
parent1da99a5269886c5aeea31a4509a178748e8ad5f8 (diff)
downloadchromium_src-c2bff8d3e630fb137b949a8cec45b79783b5d25e.zip
chromium_src-c2bff8d3e630fb137b949a8cec45b79783b5d25e.tar.gz
chromium_src-c2bff8d3e630fb137b949a8cec45b79783b5d25e.tar.bz2
Fix GPU tracing offset calculation on android.
The previous fix only made the offset calculation more stable, but it still seems to race with when the device can go idle. I think this is due to the trace command not being flushed. Since beginning a trace is an asynchronous command, it is possible that the GPU can still go idle after the we synchronize the timer because that is a synchronous command. In order to guarantee that we are calculating the offset after the asynchronous command has already begun, I have made it so the offset is calculated before we issue the asynchronous end trace call instead. Technically this is still not completely fool proof because we can have a case where we issue a trace begin and trace end immediately and calculate the offset time before both commands are flushed, but assuming we are actually tracing some GPU command that takes GPU time, this should not happen very often. BUG=None TEST=local, trace a page for a minute. Review URL: https://codereview.chromium.org/929543002 Cr-Commit-Position: refs/heads/master@{#317164}
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/gpu_timing.cc2
-rw-r--r--gpu/command_buffer/service/gpu_tracer_unittest.cc3
2 files changed, 3 insertions, 2 deletions
diff --git a/gpu/command_buffer/service/gpu_timing.cc b/gpu/command_buffer/service/gpu_timing.cc
index 9a7d52b..6ab3e83 100644
--- a/gpu/command_buffer/service/gpu_timing.cc
+++ b/gpu/command_buffer/service/gpu_timing.cc
@@ -24,11 +24,11 @@ GPUTimer::~GPUTimer() {
void GPUTimer::Start() {
// GL_TIMESTAMP and GL_TIMESTAMP_EXT both have the same value.
glQueryCounter(queries_[0], GL_TIMESTAMP);
- offset_ = gpu_timing_->CalculateTimerOffset();
}
void GPUTimer::End() {
end_requested_ = true;
+ offset_ = gpu_timing_->CalculateTimerOffset();
glQueryCounter(queries_[1], GL_TIMESTAMP);
}
diff --git a/gpu/command_buffer/service/gpu_tracer_unittest.cc b/gpu/command_buffer/service/gpu_tracer_unittest.cc
index 9005421..ba61ba3 100644
--- a/gpu/command_buffer/service/gpu_tracer_unittest.cc
+++ b/gpu/command_buffer/service/gpu_tracer_unittest.cc
@@ -356,6 +356,7 @@ class BaseGpuTraceTest : public BaseGpuTest {
// Shouldn't be available before End() call
gl_fake_queries_.SetCurrentGLTime(end_timestamp);
+ g_fakeCPUTime = expect_end_time;
EXPECT_FALSE(trace->IsAvailable());
trace->End(true);
@@ -474,7 +475,7 @@ class BaseGpuTracerTest : public BaseGpuTest {
gl_fake_queries_.SetCurrentGLTime(
end_timestamp +
(i * base::Time::kNanosecondsPerMicrosecond));
- g_fakeCPUTime = expect_start_time + i;
+ g_fakeCPUTime = expect_end_time + i;
// Each trace name should be different to differentiate.
const char num_char = static_cast<char>('0' + i);