summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service
diff options
context:
space:
mode:
Diffstat (limited to 'gpu/command_buffer/service')
-rw-r--r--gpu/command_buffer/service/BUILD.gn2
-rw-r--r--gpu/command_buffer/service/gl_context_virtual.cc5
-rw-r--r--gpu/command_buffer/service/gl_context_virtual.h1
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc4
-rw-r--r--gpu/command_buffer/service/gpu_timing.cc146
-rw-r--r--gpu/command_buffer/service/gpu_timing.h87
-rw-r--r--gpu/command_buffer/service/gpu_tracer.cc36
-rw-r--r--gpu/command_buffer/service/gpu_tracer.h12
-rw-r--r--gpu/command_buffer/service/gpu_tracer_unittest.cc66
9 files changed, 71 insertions, 288 deletions
diff --git a/gpu/command_buffer/service/BUILD.gn b/gpu/command_buffer/service/BUILD.gn
index 219a4c6d..ee92509 100644
--- a/gpu/command_buffer/service/BUILD.gn
+++ b/gpu/command_buffer/service/BUILD.gn
@@ -67,8 +67,6 @@ source_set("service") {
"gpu_state_tracer.h",
"gpu_switches.cc",
"gpu_switches.h",
- "gpu_timing.cc",
- "gpu_timing.h",
"gpu_tracer.cc",
"gpu_tracer.h",
"id_manager.cc",
diff --git a/gpu/command_buffer/service/gl_context_virtual.cc b/gpu/command_buffer/service/gl_context_virtual.cc
index 765dbee..7747407 100644
--- a/gpu/command_buffer/service/gl_context_virtual.cc
+++ b/gpu/command_buffer/service/gl_context_virtual.cc
@@ -7,6 +7,7 @@
#include "gpu/command_buffer/service/gl_state_restorer_impl.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "ui/gl/gl_surface.h"
+#include "ui/gl/gpu_timing.h"
namespace gpu {
@@ -82,6 +83,10 @@ void* GLContextVirtual::GetHandle() {
return shared_context_->GetHandle();
}
+scoped_refptr<gfx::GPUTimingClient> GLContextVirtual::CreateGPUTimingClient() {
+ return shared_context_->CreateGPUTimingClient();
+}
+
void GLContextVirtual::OnSetSwapInterval(int interval) {
shared_context_->SetSwapInterval(interval);
}
diff --git a/gpu/command_buffer/service/gl_context_virtual.h b/gpu/command_buffer/service/gl_context_virtual.h
index 7a79928..42c6d42 100644
--- a/gpu/command_buffer/service/gl_context_virtual.h
+++ b/gpu/command_buffer/service/gl_context_virtual.h
@@ -41,6 +41,7 @@ class GPU_EXPORT GLContextVirtual : public gfx::GLContext {
void ReleaseCurrent(gfx::GLSurface* surface) override;
bool IsCurrent(gfx::GLSurface* surface) override;
void* GetHandle() override;
+ scoped_refptr<gfx::GPUTimingClient> CreateGPUTimingClient() override;
void OnSetSwapInterval(int interval) override;
std::string GetExtensions() override;
bool GetTotalGpuMemory(size_t* bytes) override;
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 8f4a624..8c24d3c 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -2444,7 +2444,6 @@ bool GLES2DecoderImpl::Initialize(
surfaceless_ = surface->IsSurfaceless() && !offscreen;
set_initialized();
- gpu_tracer_.reset(new GPUTracer(this));
gpu_state_tracer_ = GPUStateTracer::Create(&state_);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
@@ -2475,6 +2474,9 @@ bool GLES2DecoderImpl::Initialize(
if (!attrib_parser.Parse(attribs))
return false;
+ // Create GPU Tracer for timing values.
+ gpu_tracer_.reset(new GPUTracer(this));
+
// Save the loseContextWhenOutOfMemory context creation attribute.
lose_context_when_out_of_memory_ =
attrib_parser.lose_context_when_out_of_memory;
diff --git a/gpu/command_buffer/service/gpu_timing.cc b/gpu/command_buffer/service/gpu_timing.cc
deleted file mode 100644
index 6ab3e83..0000000
--- a/gpu/command_buffer/service/gpu_timing.cc
+++ /dev/null
@@ -1,146 +0,0 @@
-// Copyright (c) 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "gpu/command_buffer/service/gpu_timing.h"
-
-#include "base/time/time.h"
-#include "ui/gl/gl_bindings.h"
-#include "ui/gl/gl_context.h"
-#include "ui/gl/gl_version_info.h"
-
-namespace gpu {
-
-GPUTimer::GPUTimer(GPUTiming* gpu_timing) : gpu_timing_(gpu_timing) {
- DCHECK(gpu_timing_);
- memset(queries_, 0, sizeof(queries_));
- glGenQueriesARB(2, queries_);
-}
-
-GPUTimer::~GPUTimer() {
- glDeleteQueriesARB(2, queries_);
-}
-
-void GPUTimer::Start() {
- // GL_TIMESTAMP and GL_TIMESTAMP_EXT both have the same value.
- glQueryCounter(queries_[0], GL_TIMESTAMP);
-}
-
-void GPUTimer::End() {
- end_requested_ = true;
- offset_ = gpu_timing_->CalculateTimerOffset();
- glQueryCounter(queries_[1], GL_TIMESTAMP);
-}
-
-bool GPUTimer::IsAvailable() {
- if (!gpu_timing_->IsAvailable() || !end_requested_) {
- return false;
- }
- GLint done = 0;
- glGetQueryObjectivARB(queries_[1], GL_QUERY_RESULT_AVAILABLE, &done);
- return done != 0;
-}
-
-void GPUTimer::GetStartEndTimestamps(int64* start, int64* end) {
- DCHECK(start && end);
- DCHECK(IsAvailable());
- GLuint64 begin_stamp = 0;
- GLuint64 end_stamp = 0;
- // TODO(dsinclair): It's possible for the timer to wrap during the start/end.
- // We need to detect if the end is less then the start and correct for the
- // wrapping.
- glGetQueryObjectui64v(queries_[0], GL_QUERY_RESULT, &begin_stamp);
- glGetQueryObjectui64v(queries_[1], GL_QUERY_RESULT, &end_stamp);
-
- *start = (begin_stamp / base::Time::kNanosecondsPerMicrosecond) + offset_;
- *end = (end_stamp / base::Time::kNanosecondsPerMicrosecond) + offset_;
-}
-
-int64 GPUTimer::GetDeltaElapsed() {
- int64 start = 0;
- int64 end = 0;
- GetStartEndTimestamps(&start, &end);
- return end - start;
-}
-
-GPUTiming::GPUTiming() : cpu_time_for_testing_() {
-}
-
-GPUTiming::~GPUTiming() {
-}
-
-bool GPUTiming::Initialize(gfx::GLContext* gl_context) {
- DCHECK(gl_context);
- DCHECK_EQ(kTimerTypeInvalid, timer_type_);
-
- const gfx::GLVersionInfo* version_info = gl_context->GetVersionInfo();
- DCHECK(version_info);
- if (version_info->is_es3 && // glGetInteger64v is supported under ES3.
- gfx::g_driver_gl.ext.b_GL_EXT_disjoint_timer_query) {
- timer_type_ = kTimerTypeDisjoint;
- return true;
- } else if (gfx::g_driver_gl.ext.b_GL_ARB_timer_query) {
- timer_type_ = kTimerTypeARB;
- return true;
- }
- return false;
-}
-
-bool GPUTiming::IsAvailable() {
- return timer_type_ != kTimerTypeInvalid;
-}
-
-const char* GPUTiming::GetTimerTypeName() const {
- switch (timer_type_) {
- case kTimerTypeDisjoint:
- return "GL_EXT_disjoint_timer_query";
- case kTimerTypeARB:
- return "GL_ARB_timer_query";
- default:
- return "Unknown";
- }
-}
-
-bool GPUTiming::CheckAndResetTimerErrors() {
- if (timer_type_ == kTimerTypeDisjoint) {
- GLint disjoint_value = 0;
- glGetIntegerv(GL_GPU_DISJOINT_EXT, &disjoint_value);
- return disjoint_value != 0;
- } else {
- return false;
- }
-}
-
-int64 GPUTiming::CalculateTimerOffset() {
- if (!offset_valid_) {
- GLint64 gl_now = 0;
- glGetInteger64v(GL_TIMESTAMP, &gl_now);
- int64 now =
- cpu_time_for_testing_.is_null()
- ? base::TimeTicks::NowFromSystemTraceTime().ToInternalValue()
- : cpu_time_for_testing_.Run();
- offset_ = now - gl_now / base::Time::kNanosecondsPerMicrosecond;
- offset_valid_ = timer_type_ == kTimerTypeARB;
- }
- return offset_;
-}
-
-void GPUTiming::InvalidateTimerOffset() {
- offset_valid_ = false;
-}
-
-void GPUTiming::SetCpuTimeForTesting(
- const base::Callback<int64(void)>& cpu_time) {
- cpu_time_for_testing_ = cpu_time;
-}
-
-void GPUTiming::SetOffsetForTesting(int64 offset, bool cache_it) {
- offset_ = offset;
- offset_valid_ = cache_it;
-}
-
-void GPUTiming::SetTimerTypeForTesting(TimerType type) {
- timer_type_ = type;
-}
-
-} // namespace gpu
diff --git a/gpu/command_buffer/service/gpu_timing.h b/gpu/command_buffer/service/gpu_timing.h
deleted file mode 100644
index 726ac4e..0000000
--- a/gpu/command_buffer/service/gpu_timing.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef GPU_COMMAND_BUFFER_SERVICE_GPU_TIMING_H_
-#define GPU_COMMAND_BUFFER_SERVICE_GPU_TIMING_H_
-
-#include "base/callback.h"
-#include "base/memory/scoped_ptr.h"
-#include "gpu/gpu_export.h"
-
-namespace gfx {
-class GLContext;
-}
-
-namespace gpu {
-class GPUTiming;
-
-// Class to compute the amount of time it takes to fully
-// complete a set of GL commands
-class GPU_EXPORT GPUTimer {
- public:
- // gpu_timing must outlive GPUTimer instance we're creating.
- explicit GPUTimer(GPUTiming* gpu_timing);
- ~GPUTimer();
-
- void Start();
- void End();
- bool IsAvailable();
-
- void GetStartEndTimestamps(int64* start, int64* end);
- int64 GetDeltaElapsed();
-
- private:
- unsigned int queries_[2];
- int64 offset_ = 0;
- bool end_requested_ = false;
- GPUTiming* gpu_timing_;
-
- DISALLOW_COPY_AND_ASSIGN(GPUTimer);
-};
-
-// GPUTiming contains all the gl timing logic that is not specific
-// to a single GPUTimer.
-class GPU_EXPORT GPUTiming {
- public:
- enum TimerType {
- kTimerTypeInvalid = -1,
-
- kTimerTypeARB, // ARB_timer_query
- kTimerTypeDisjoint // EXT_disjoint_timer_query
- };
-
- GPUTiming();
- virtual ~GPUTiming();
-
- bool Initialize(gfx::GLContext* context);
- bool IsAvailable();
-
- // CheckAndResetTimerErrors has to be called before reading timestamps
- // from GPUTimers instances and after making sure all the timers
- // were available.
- // If the returned value is false, all the previous timers should be
- // discarded.
- bool CheckAndResetTimerErrors();
-
- const char* GetTimerTypeName() const;
-
- // Returns the offset between the current gpu time and the cpu time.
- int64 CalculateTimerOffset();
- void InvalidateTimerOffset();
-
- void SetCpuTimeForTesting(const base::Callback<int64(void)>& cpu_time);
- void SetOffsetForTesting(int64 offset, bool cache_it);
- void SetTimerTypeForTesting(TimerType type);
-
- private:
- TimerType timer_type_ = kTimerTypeInvalid;
- int64 offset_ = 0; // offset cache when timer_type_ == kTimerTypeARB
- bool offset_valid_ = false;
- base::Callback<int64(void)> cpu_time_for_testing_;
- friend class GPUTimer;
- DISALLOW_COPY_AND_ASSIGN(GPUTiming);
-};
-} // namespace gpu
-
-#endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TIMING_H_
diff --git a/gpu/command_buffer/service/gpu_tracer.cc b/gpu/command_buffer/service/gpu_tracer.cc
index cc484dc..2fbf46c 100644
--- a/gpu/command_buffer/service/gpu_tracer.cc
+++ b/gpu/command_buffer/service/gpu_tracer.cc
@@ -14,6 +14,7 @@
#include "gpu/command_buffer/service/context_group.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_version_info.h"
+#include "ui/gl/gpu_timing.h"
namespace gpu {
namespace gles2 {
@@ -81,7 +82,7 @@ void TraceOutputter::TraceServiceEnd(const std::string& category,
}
GPUTrace::GPUTrace(scoped_refptr<Outputter> outputter,
- gpu::GPUTiming* gpu_timing,
+ gfx::GPUTimingClient* gpu_timing_client,
const std::string& category,
const std::string& name,
const bool enabled)
@@ -89,8 +90,8 @@ GPUTrace::GPUTrace(scoped_refptr<Outputter> outputter,
name_(name),
outputter_(outputter),
enabled_(enabled) {
- if (gpu_timing->IsAvailable()) {
- gpu_timer_.reset(new GPUTimer(gpu_timing));
+ if (gpu_timing_client->IsAvailable()) {
+ gpu_timer_ = gpu_timing_client->CreateGPUTimer();
}
}
@@ -136,9 +137,15 @@ GPUTracer::GPUTracer(gles2::GLES2Decoder* decoder)
gpu_trace_dev_category(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(
TRACE_DISABLED_BY_DEFAULT("gpu.device"))),
decoder_(decoder),
- gpu_timing_(),
gpu_executing_(false),
process_posted_(false) {
+ DCHECK(decoder_);
+ gfx::GLContext* context = decoder_->GetGLContext();
+ if (context) {
+ gpu_timing_client_ = context->CreateGPUTimingClient();
+ } else {
+ gpu_timing_client_ = new gfx::GPUTimingClient();
+ }
}
GPUTracer::~GPUTracer() {
@@ -148,26 +155,26 @@ bool GPUTracer::BeginDecoding() {
if (gpu_executing_)
return false;
- if (outputter_ == NULL) {
- outputter_ = CreateOutputter(gpu_timing_.GetTimerTypeName());
- gpu_timing_.Initialize(decoder_->GetGLContext());
+ if (!outputter_) {
+ outputter_ = CreateOutputter(gpu_timing_client_->GetTimerTypeName());
}
if (*gpu_trace_dev_category == '\0') {
// If GPU device category is off, invalidate timing sync.
- gpu_timing_.InvalidateTimerOffset();
+ gpu_timing_client_->InvalidateTimerOffset();
}
gpu_executing_ = true;
if (IsTracing()) {
- gpu_timing_.CheckAndResetTimerErrors();
+ gpu_timing_client_->CheckAndResetTimerErrors();
// Begin a Trace for all active markers
for (int n = 0; n < NUM_TRACER_SOURCES; n++) {
for (size_t i = 0; i < markers_[n].size(); i++) {
TraceMarker& trace_marker = markers_[n][i];
trace_marker.trace_ =
- new GPUTrace(outputter_, &gpu_timing_, trace_marker.category_,
- trace_marker.name_, *gpu_trace_dev_category != 0);
+ new GPUTrace(outputter_, gpu_timing_client_.get(),
+ trace_marker.category_, trace_marker.name_,
+ *gpu_trace_dev_category != 0);
trace_marker.trace_->Start(*gpu_trace_srv_category != 0);
}
}
@@ -216,7 +223,8 @@ bool GPUTracer::Begin(const std::string& category, const std::string& name,
// Create trace
if (IsTracing()) {
scoped_refptr<GPUTrace> trace = new GPUTrace(
- outputter_, &gpu_timing_, category, name, *gpu_trace_dev_category != 0);
+ outputter_, gpu_timing_client_.get(), category, name,
+ *gpu_trace_dev_category != 0);
trace->Start(*gpu_trace_srv_category != 0);
markers_[source].back().trace_ = trace;
}
@@ -288,7 +296,7 @@ void GPUTracer::Process() {
}
void GPUTracer::ProcessTraces() {
- if (!gpu_timing_.IsAvailable()) {
+ if (!gpu_timing_client_->IsAvailable()) {
traces_.clear();
return;
}
@@ -304,7 +312,7 @@ void GPUTracer::ProcessTraces() {
// Check if timers are still valid (e.g: a disjoint operation
// might have occurred.)
- if (gpu_timing_.CheckAndResetTimerErrors())
+ if (gpu_timing_client_->CheckAndResetTimerErrors())
traces_.clear();
while (!traces_.empty() && traces_.front()->IsAvailable()) {
diff --git a/gpu/command_buffer/service/gpu_tracer.h b/gpu/command_buffer/service/gpu_tracer.h
index 7aba612..1b2c315 100644
--- a/gpu/command_buffer/service/gpu_tracer.h
+++ b/gpu/command_buffer/service/gpu_tracer.h
@@ -15,9 +15,13 @@
#include "base/memory/weak_ptr.h"
#include "base/threading/thread.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
-#include "gpu/command_buffer/service/gpu_timing.h"
#include "gpu/gpu_export.h"
+namespace gfx {
+ class GPUTimingClient;
+ class GPUTimer;
+}
+
namespace gpu {
namespace gles2 {
@@ -82,6 +86,7 @@ class GPU_EXPORT GPUTracer
void IssueProcessTask();
+ scoped_refptr<gfx::GPUTimingClient> gpu_timing_client_;
scoped_refptr<Outputter> outputter_;
std::vector<TraceMarker> markers_[NUM_TRACER_SOURCES];
std::deque<scoped_refptr<GPUTrace> > traces_;
@@ -89,7 +94,6 @@ class GPU_EXPORT GPUTracer
const unsigned char* gpu_trace_srv_category;
const unsigned char* gpu_trace_dev_category;
gles2::GLES2Decoder* decoder_;
- gpu::GPUTiming gpu_timing_;
bool gpu_executing_;
bool process_posted_;
@@ -146,7 +150,7 @@ class GPU_EXPORT GPUTrace
: public base::RefCounted<GPUTrace> {
public:
GPUTrace(scoped_refptr<Outputter> outputter,
- gpu::GPUTiming* gpu_timing,
+ gfx::GPUTimingClient* gpu_timing_client,
const std::string& category,
const std::string& name,
const bool enabled);
@@ -167,7 +171,7 @@ class GPU_EXPORT GPUTrace
std::string category_;
std::string name_;
scoped_refptr<Outputter> outputter_;
- scoped_ptr<gpu::GPUTimer> gpu_timer_;
+ scoped_ptr<gfx::GPUTimer> gpu_timer_;
const bool enabled_ = false;
DISALLOW_COPY_AND_ASSIGN(GPUTrace);
diff --git a/gpu/command_buffer/service/gpu_tracer_unittest.cc b/gpu/command_buffer/service/gpu_tracer_unittest.cc
index ba61ba3..6566f6a 100644
--- a/gpu/command_buffer/service/gpu_tracer_unittest.cc
+++ b/gpu/command_buffer/service/gpu_tracer_unittest.cc
@@ -8,10 +8,10 @@
#include "base/bind.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
#include "gpu/command_buffer/service/gpu_service_test.h"
-#include "gpu/command_buffer/service/gpu_timing.h"
#include "gpu/command_buffer/service/gpu_tracer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_mock.h"
+#include "ui/gl/gpu_timing.h"
namespace gpu {
namespace gles2 {
@@ -152,7 +152,7 @@ class GPUTracerTester : public GPUTracer {
public:
explicit GPUTracerTester(gles2::GLES2Decoder* decoder)
: GPUTracer(decoder), tracing_enabled_(0) {
- gpu_timing_.SetCpuTimeForTesting(base::Bind(&FakeCpuTime));
+ gpu_timing_client_->SetCpuTimeForTesting(base::Bind(&FakeCpuTime));
// Force tracing to be dependent on our mock variable here.
gpu_trace_srv_category = &tracing_enabled_;
@@ -189,10 +189,8 @@ class GPUTracerTester : public GPUTracer {
class BaseGpuTest : public GpuServiceTest {
public:
- explicit BaseGpuTest(GPUTiming::TimerType test_timer_type)
+ explicit BaseGpuTest(gfx::GPUTiming::TimerType test_timer_type)
: test_timer_type_(test_timer_type) {
- gpu_timing_.SetCpuTimeForTesting(base::Bind(&FakeCpuTime));
- gpu_timing_.SetTimerTypeForTesting(test_timer_type);
}
protected:
@@ -200,15 +198,17 @@ class BaseGpuTest : public GpuServiceTest {
g_fakeCPUTime = 0;
const char* gl_version = "3.2";
const char* extensions = "";
- if (GetTimerType() == GPUTiming::kTimerTypeDisjoint) {
+ if (GetTimerType() == gfx::GPUTiming::kTimerTypeDisjoint) {
gl_version = "opengl es 3.0";
extensions = "GL_EXT_disjoint_timer_query";
- } else if (GetTimerType() == GPUTiming::kTimerTypeARB) {
+ } else if (GetTimerType() == gfx::GPUTiming::kTimerTypeARB) {
// TODO(sievers): The tracer should not depend on ARB_occlusion_query.
// Try merge Query APIs (core, ARB, EXT) into a single binding each.
extensions = "GL_ARB_timer_query GL_ARB_occlusion_query";
}
GpuServiceTest::SetUpWithGLVersion(gl_version, extensions);
+ gpu_timing_client_ = GetGLContext()->CreateGPUTimingClient();
+ gpu_timing_client_->SetCpuTimeForTesting(base::Bind(&FakeCpuTime));
gl_fake_queries_.Reset();
outputter_ref_ = new MockOutputter();
@@ -222,22 +222,20 @@ class BaseGpuTest : public GpuServiceTest {
}
void ExpectTraceQueryMocks() {
- if (GetTimerType() != GPUTiming::kTimerTypeInvalid) {
+ if (GetTimerType() != gfx::GPUTiming::kTimerTypeInvalid) {
// Delegate query APIs used by GPUTrace to a GlFakeQueries
EXPECT_CALL(*gl_, GenQueriesARB(2, NotNull())).Times(AtLeast(1))
.WillRepeatedly(
Invoke(&gl_fake_queries_, &GlFakeQueries::GenQueriesARB));
EXPECT_CALL(*gl_, GetQueryObjectivARB(_, GL_QUERY_RESULT_AVAILABLE,
- NotNull()))
+ NotNull()))
.WillRepeatedly(
- Invoke(&gl_fake_queries_, &GlFakeQueries::GetQueryObjectivARB));
+ Invoke(&gl_fake_queries_, &GlFakeQueries::GetQueryObjectivARB));
- if (GetTimerType() == GPUTiming::kTimerTypeDisjoint) {
- EXPECT_CALL(*gl_, GetInteger64v(GL_TIMESTAMP, _))
+ EXPECT_CALL(*gl_, GetInteger64v(GL_TIMESTAMP, _))
.WillRepeatedly(
- Invoke(&gl_fake_queries_, &GlFakeQueries::GetInteger64v));
- }
+ Invoke(&gl_fake_queries_, &GlFakeQueries::GetInteger64v));
EXPECT_CALL(*gl_, QueryCounter(_, GL_TIMESTAMP)).Times(AtLeast(2))
.WillRepeatedly(
@@ -286,14 +284,14 @@ class BaseGpuTest : public GpuServiceTest {
const std::string& name, int64 expect_start_time,
int64 expect_end_time) {
ExpectOutputterBeginMocks(outputter, category, name);
+ bool valid_timer = GetTimerType() != gfx::GPUTiming::kTimerTypeInvalid;
ExpectOutputterEndMocks(outputter, category, name, expect_start_time,
- expect_end_time,
- GetTimerType() != GPUTiming::kTimerTypeInvalid);
+ expect_end_time, valid_timer);
}
void ExpectTracerOffsetQueryMocks() {
// Disjoint check should only be called by kTracerTypeDisjointTimer type.
- if (GetTimerType() == GPUTiming::kTimerTypeDisjoint) {
+ if (GetTimerType() == gfx::GPUTiming::kTimerTypeDisjoint) {
EXPECT_CALL(*gl_, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(AtLeast(1))
.WillRepeatedly(
Invoke(&gl_fake_queries_, &GlFakeQueries::GetIntegerv));
@@ -301,7 +299,7 @@ class BaseGpuTest : public GpuServiceTest {
EXPECT_CALL(*gl_, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(Exactly(0));
}
- if (GetTimerType() != GPUTiming::kTimerTypeARB) {
+ if (GetTimerType() != gfx::GPUTiming::kTimerTypeARB) {
EXPECT_CALL(*gl_, GetInteger64v(GL_TIMESTAMP, NotNull()))
.Times(Exactly(0));
} else {
@@ -312,19 +310,19 @@ class BaseGpuTest : public GpuServiceTest {
}
}
- GPUTiming::TimerType GetTimerType() { return test_timer_type_; }
+ gfx::GPUTiming::TimerType GetTimerType() { return test_timer_type_; }
- GPUTiming::TimerType test_timer_type_;
+ gfx::GPUTiming::TimerType test_timer_type_;
GlFakeQueries gl_fake_queries_;
- GPUTiming gpu_timing_;
+ scoped_refptr<gfx::GPUTimingClient> gpu_timing_client_;
scoped_refptr<MockOutputter> outputter_ref_;
};
// Test GPUTrace calls all the correct gl calls.
class BaseGpuTraceTest : public BaseGpuTest {
public:
- explicit BaseGpuTraceTest(GPUTiming::TimerType test_timer_type)
+ explicit BaseGpuTraceTest(gfx::GPUTiming::TimerType test_timer_type)
: BaseGpuTest(test_timer_type) {}
void DoTraceTest() {
@@ -345,10 +343,8 @@ class BaseGpuTraceTest : public BaseGpuTest {
expect_start_time, expect_end_time);
scoped_refptr<GPUTrace> trace = new GPUTrace(
- outputter_ref_, &gpu_timing_, category_name, trace_name, true);
-
- gpu_timing_.SetOffsetForTesting(
- offset_time, test_timer_type_ == GPUTiming::kTimerTypeARB);
+ outputter_ref_, gpu_timing_client_.get(),
+ category_name, trace_name, true);
gl_fake_queries_.SetCurrentGLTime(start_timestamp);
g_fakeCPUTime = expect_start_time;
@@ -379,13 +375,13 @@ class BaseGpuTraceTest : public BaseGpuTest {
class GpuARBTimerTraceTest : public BaseGpuTraceTest {
public:
- GpuARBTimerTraceTest() : BaseGpuTraceTest(GPUTiming::kTimerTypeARB) {}
+ GpuARBTimerTraceTest() : BaseGpuTraceTest(gfx::GPUTiming::kTimerTypeARB) {}
};
class GpuDisjointTimerTraceTest : public BaseGpuTraceTest {
public:
GpuDisjointTimerTraceTest()
- : BaseGpuTraceTest(GPUTiming::kTimerTypeDisjoint) {}
+ : BaseGpuTraceTest(gfx::GPUTiming::kTimerTypeDisjoint) {}
};
TEST_F(GpuARBTimerTraceTest, ARBTimerTraceTest) {
@@ -399,7 +395,7 @@ TEST_F(GpuDisjointTimerTraceTest, DisjointTimerTraceTest) {
// Test GPUTracer calls all the correct gl calls.
class BaseGpuTracerTest : public BaseGpuTest {
public:
- explicit BaseGpuTracerTest(GPUTiming::TimerType test_timer_type)
+ explicit BaseGpuTracerTest(gfx::GPUTiming::TimerType test_timer_type)
: BaseGpuTest(test_timer_type) {}
void DoBasicTracerTest() {
@@ -482,10 +478,10 @@ class BaseGpuTracerTest : public BaseGpuTest {
std::string source_category = category_name + num_char;
std::string source_trace_name = trace_name + num_char;
+ bool valid_timer = GetTimerType() != gfx::GPUTiming::kTimerTypeInvalid;
ExpectOutputterEndMocks(outputter_ref_.get(), source_category,
source_trace_name, expect_start_time + i,
- expect_end_time + i,
- GetTimerType() != GPUTiming::kTimerTypeInvalid);
+ expect_end_time + i, valid_timer);
const GpuTracerSource source = static_cast<GpuTracerSource>(i);
@@ -555,18 +551,20 @@ class BaseGpuTracerTest : public BaseGpuTest {
class InvalidTimerTracerTest : public BaseGpuTracerTest {
public:
- InvalidTimerTracerTest() : BaseGpuTracerTest(GPUTiming::kTimerTypeInvalid) {}
+ InvalidTimerTracerTest()
+ : BaseGpuTracerTest(gfx::GPUTiming::kTimerTypeInvalid) {}
};
class GpuARBTimerTracerTest : public BaseGpuTracerTest {
public:
- GpuARBTimerTracerTest() : BaseGpuTracerTest(GPUTiming::kTimerTypeARB) {}
+ GpuARBTimerTracerTest()
+ : BaseGpuTracerTest(gfx::GPUTiming::kTimerTypeARB) {}
};
class GpuDisjointTimerTracerTest : public BaseGpuTracerTest {
public:
GpuDisjointTimerTracerTest()
- : BaseGpuTracerTest(GPUTiming::kTimerTypeDisjoint) {}
+ : BaseGpuTracerTest(gfx::GPUTiming::kTimerTypeDisjoint) {}
};
TEST_F(InvalidTimerTracerTest, InvalidTimerBasicTracerTest) {