summaryrefslogtreecommitdiffstats
path: root/gpu/perftests
diff options
context:
space:
mode:
authordyen <dyen@chromium.org>2015-02-25 17:54:00 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-26 01:55:12 +0000
commit5b1c02ff50ebb8af95b50b4ea1658eef2bb89546 (patch)
tree506eb5b7e32d346b1587f56a9e22d6081ea8837c /gpu/perftests
parent362ae2101b8a3710e1a07066746ed98bc577b52d (diff)
downloadchromium_src-5b1c02ff50ebb8af95b50b4ea1658eef2bb89546.zip
chromium_src-5b1c02ff50ebb8af95b50b4ea1658eef2bb89546.tar.gz
chromium_src-5b1c02ff50ebb8af95b50b4ea1658eef2bb89546.tar.bz2
Refactored GLContext to own GPUTiming which spawn GPUTimingClients.
GPUTiming is our abstraction layer for various GL timing extensions. It makes more sense for this abstraction layer to be owned by GLContext instead. Clients that want to do GPU Timing calls (GPUTracer, eventual support of WebGL tracer calls). One of the main reasons for this differentiation is to support disjoint queries across multiple virtual contexts. The actual support of this will be completed in another CL. BUG=451211 TEST=trybots Review URL: https://codereview.chromium.org/937263006 Cr-Commit-Position: refs/heads/master@{#318174}
Diffstat (limited to 'gpu/perftests')
-rw-r--r--gpu/perftests/measurements.cc10
-rw-r--r--gpu/perftests/measurements.h12
-rw-r--r--gpu/perftests/texture_upload_perftest.cc23
3 files changed, 25 insertions, 20 deletions
diff --git a/gpu/perftests/measurements.cc b/gpu/perftests/measurements.cc
index 527ce1b..db26fb3 100644
--- a/gpu/perftests/measurements.cc
+++ b/gpu/perftests/measurements.cc
@@ -5,8 +5,8 @@
#include "gpu/perftests/measurements.h"
#include "base/logging.h"
-#include "gpu/command_buffer/service/gpu_timing.h"
#include "testing/perf/perf_test.h"
+#include "ui/gl/gpu_timing.h"
namespace gpu {
@@ -52,9 +52,9 @@ Measurement Measurement::Divide(int a) const {
Measurement::~Measurement() {
}
-MeasurementTimers::MeasurementTimers(GPUTiming* gpu_timing)
+MeasurementTimers::MeasurementTimers(gfx::GPUTimingClient* gpu_timing_client)
: wall_time_start_(), cpu_time_start_(), gpu_timer_() {
- DCHECK(gpu_timing);
+ DCHECK(gpu_timing_client);
wall_time_start_ = base::TimeTicks::NowFromSystemTraceTime();
if (base::TimeTicks::IsThreadNowSupported()) {
cpu_time_start_ = base::TimeTicks::ThreadNow();
@@ -64,8 +64,8 @@ MeasurementTimers::MeasurementTimers(GPUTiming* gpu_timing)
logged_once = true;
}
- if (gpu_timing->IsAvailable()) {
- gpu_timer_.reset(new GPUTimer(gpu_timing));
+ if (gpu_timing_client->IsAvailable()) {
+ gpu_timer_ = gpu_timing_client->CreateGPUTimer();
gpu_timer_->Start();
}
}
diff --git a/gpu/perftests/measurements.h b/gpu/perftests/measurements.h
index 8cdcb30..35ede22 100644
--- a/gpu/perftests/measurements.h
+++ b/gpu/perftests/measurements.h
@@ -10,9 +10,13 @@
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
+namespace gfx {
+ class GPUTimingClient;
+ class GPUTimer;
+}
+
namespace gpu {
-class GPUTiming;
-class GPUTimer;
+
struct Measurement {
Measurement();
Measurement(const Measurement& m);
@@ -37,7 +41,7 @@ struct Measurement {
// creation up to when Record is called.
class MeasurementTimers {
public:
- explicit MeasurementTimers(GPUTiming* gpu_timing);
+ explicit MeasurementTimers(gfx::GPUTimingClient* gpu_timing_client);
void Record();
Measurement GetAsMeasurement(const std::string& name);
~MeasurementTimers();
@@ -45,7 +49,7 @@ class MeasurementTimers {
private:
base::TimeTicks wall_time_start_;
base::TimeTicks cpu_time_start_;
- scoped_ptr<gpu::GPUTimer> gpu_timer_;
+ scoped_ptr<gfx::GPUTimer> gpu_timer_;
base::TimeDelta wall_time_;
base::TimeDelta cpu_time_;
diff --git a/gpu/perftests/texture_upload_perftest.cc b/gpu/perftests/texture_upload_perftest.cc
index 487f9b2..495ef86 100644
--- a/gpu/perftests/texture_upload_perftest.cc
+++ b/gpu/perftests/texture_upload_perftest.cc
@@ -10,7 +10,6 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/stringprintf.h"
-#include "gpu/command_buffer/service/gpu_timing.h"
#include "gpu/perftests/measurements.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_test.h"
@@ -18,6 +17,7 @@
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface.h"
+#include "ui/gl/gpu_timing.h"
#include "ui/gl/scoped_make_current.h"
namespace gpu {
@@ -124,12 +124,12 @@ class TextureUploadPerfTest : public testing::Test {
glCheckFramebufferStatusEXT(GL_FRAMEBUFFER));
glViewport(0, 0, fbo_size_.width(), fbo_size_.height());
+ gpu_timing_client_ = gl_context_->CreateGPUTimingClient();
- if (gpu_timing_.Initialize(gl_context_.get())) {
+ if (gpu_timing_client_->IsAvailable()) {
LOG(INFO) << "Gpu timing initialized with timer type: "
- << gpu_timing_.GetTimerTypeName();
- gpu_timing_.CheckAndResetTimerErrors();
- gpu_timing_.InvalidateTimerOffset();
+ << gpu_timing_client_->GetTimerTypeName();
+ gpu_timing_client_->InvalidateTimerOffset();
} else {
LOG(WARNING) << "Can't initialize gpu timing";
}
@@ -205,10 +205,10 @@ class TextureUploadPerfTest : public testing::Test {
const std::vector<uint8>& pixels,
const GLenum format,
const GLenum type) {
- MeasurementTimers total_timers(&gpu_timing_);
+ MeasurementTimers total_timers(gpu_timing_client_.get());
GLuint texture_id = 0;
- MeasurementTimers tex_timers(&gpu_timing_);
+ MeasurementTimers tex_timers(gpu_timing_client_.get());
glActiveTexture(GL_TEXTURE0);
glGenTextures(1, &texture_id);
glBindTexture(GL_TEXTURE_2D, texture_id);
@@ -222,7 +222,7 @@ class TextureUploadPerfTest : public testing::Test {
CheckNoGlError();
tex_timers.Record();
- MeasurementTimers draw_timers(&gpu_timing_);
+ MeasurementTimers draw_timers(gpu_timing_client_.get());
glUseProgram(program_object_);
glUniform1i(sampler_location_, 0);
@@ -237,7 +237,7 @@ class TextureUploadPerfTest : public testing::Test {
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
draw_timers.Record();
- MeasurementTimers finish_timers(&gpu_timing_);
+ MeasurementTimers finish_timers(gpu_timing_client_.get());
glFinish();
CheckNoGlError();
finish_timers.Record();
@@ -257,7 +257,8 @@ class TextureUploadPerfTest : public testing::Test {
std::vector<Measurement> measurements;
bool gpu_timer_errors =
- gpu_timing_.IsAvailable() && gpu_timing_.CheckAndResetTimerErrors();
+ gpu_timing_client_->IsAvailable() &&
+ gpu_timing_client_->CheckAndResetTimerErrors();
if (!gpu_timer_errors) {
measurements.push_back(total_timers.GetAsMeasurement("total"));
measurements.push_back(tex_timers.GetAsMeasurement("teximage2d"));
@@ -298,7 +299,7 @@ class TextureUploadPerfTest : public testing::Test {
const gfx::Size fbo_size_; // for the fbo
scoped_refptr<gfx::GLContext> gl_context_;
scoped_refptr<gfx::GLSurface> surface_;
- GPUTiming gpu_timing_;
+ scoped_refptr<gfx::GPUTimingClient> gpu_timing_client_;
GLuint color_texture_ = 0;
GLuint framebuffer_object_ = 0;