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

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 10868048: Report texture upload time in renderingStats. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add totalProcessingCommandsTime stat and fix nits Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 69f1e135462e1fcbc9626ffc5c026ce289afa8fe..d2298e976c73cc051635d0ad667bad369e898dc3 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -318,6 +318,18 @@ class ScopedResolvedFrameBufferBinder {
DISALLOW_COPY_AND_ASSIGN(ScopedResolvedFrameBufferBinder);
};
+// This class records texture upload time when in scope.
+class ScopedTextureUploadTimer {
+ public:
+ explicit ScopedTextureUploadTimer(GLES2DecoderImpl* decoder);
+ ~ScopedTextureUploadTimer();
+
+ private:
+ GLES2DecoderImpl* decoder_;
+ base::TimeTicks begin_time_;
+ DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer);
+};
+
// Encapsulates an OpenGL texture.
class Texture {
public:
@@ -518,6 +530,10 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
virtual uint32 GetGLError() OVERRIDE;
+ virtual uint32 GetTextureUploadCount() OVERRIDE;
+ virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
+ virtual base::TimeDelta GetTotalProcessingCommandsTime() OVERRIDE;
+
// Restores the current state to the user's settings.
void RestoreCurrentFramebufferBindings();
void RestoreCurrentRenderbufferBindings();
@@ -540,6 +556,7 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
private:
friend class ScopedGLErrorSuppressor;
friend class ScopedResolvedFrameBufferBinder;
+ friend class ScopedTextureUploadTimer;
friend class Texture;
friend class RenderBuffer;
friend class FrameBuffer;
@@ -1583,6 +1600,11 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
GLsizei viewport_width_, viewport_height_;
GLsizei viewport_max_width_, viewport_max_height_;
+ // Command buffer stats.
+ int texture_upload_count_;
+ base::TimeDelta total_texture_upload_time_;
+ base::TimeDelta total_processing_commands_time_;
+
DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl);
};
@@ -1698,6 +1720,17 @@ ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() {
}
}
+ScopedTextureUploadTimer::ScopedTextureUploadTimer(GLES2DecoderImpl* decoder)
+ : decoder_(decoder),
+ begin_time_(base::TimeTicks::HighResNow()) {
+}
+
+ScopedTextureUploadTimer::~ScopedTextureUploadTimer() {
+ decoder_->texture_upload_count_++;
+ decoder_->total_texture_upload_time_ +=
+ base::TimeTicks::HighResNow() - begin_time_;
+}
+
Texture::Texture(GLES2DecoderImpl* decoder)
: decoder_(decoder),
memory_tracker_(decoder->GetContextGroup()->memory_tracker(),
@@ -1988,7 +2021,8 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
viewport_width_(0),
viewport_height_(0),
viewport_max_width_(0),
- viewport_max_height_(0) {
+ viewport_max_height_(0),
+ texture_upload_count_(0) {
DCHECK(group);
GLES2DecoderImpl* this_temp = this;
@@ -2834,6 +2868,18 @@ bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id,
return false;
}
+uint32 GLES2DecoderImpl::GetTextureUploadCount() {
+ return texture_upload_count_;
+}
+
+base::TimeDelta GLES2DecoderImpl::GetTotalTextureUploadTime() {
+ return total_texture_upload_time_;
+}
+
+base::TimeDelta GLES2DecoderImpl::GetTotalProcessingCommandsTime() {
+ return total_processing_commands_time_;
+}
+
void GLES2DecoderImpl::Destroy(bool have_context) {
DCHECK(!have_context || context_->IsCurrent(NULL));
@@ -3211,6 +3257,7 @@ error::Error GLES2DecoderImpl::DoCommand(
unsigned int arg_count,
const void* cmd_data) {
error::Error result = error::kNoError;
+ base::TimeTicks begin_time(base::TimeTicks::HighResNow());
if (log_commands()) {
// TODO(notme): Change this to a LOG/VLOG that works in release. Tried
// LOG(INFO), tried VLOG(1), no luck.
@@ -3255,6 +3302,8 @@ error::Error GLES2DecoderImpl::DoCommand(
result = current_decoder_error_;
current_decoder_error_ = error::kNoError;
}
+ total_processing_commands_time_ +=
+ base::TimeTicks::HighResNow() - begin_time;
return result;
}
@@ -7798,17 +7847,20 @@ void GLES2DecoderImpl::DoTexSubImage2D(
SetGLError(GL_OUT_OF_MEMORY, "glTexSubImage2D", "dimensions too big");
return;
}
+ ScopedTextureUploadTimer timer(this);
glTexSubImage2D(
target, level, xoffset, yoffset, width, height, format, type, data);
return;
}
if (teximage2d_faster_than_texsubimage2d_ && !info->IsImmutable()) {
+ ScopedTextureUploadTimer timer(this);
// NOTE: In OpenGL ES 2.0 border is always zero and format is always the
// same as internal_foramt. If that changes we'll need to look them up.
WrappedTexImage2D(
target, level, format, width, height, 0, format, type, data);
} else {
+ ScopedTextureUploadTimer timer(this);
glTexSubImage2D(
target, level, xoffset, yoffset, width, height, format, type, data);
}

Powered by Google App Engine
This is Rietveld 408576698