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..fa7e91795b1b702ebd8978338ba024fef56dd3ae 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,9 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, |
virtual uint32 GetGLError() OVERRIDE; |
+ virtual uint32 GetTextureUploadCount() OVERRIDE; |
+ virtual double GetTotalTextureUploadTimeInSeconds() OVERRIDE; |
+ |
// Restores the current state to the user's settings. |
void RestoreCurrentFramebufferBindings(); |
void RestoreCurrentRenderbufferBindings(); |
@@ -540,6 +555,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 +1599,10 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, |
GLsizei viewport_width_, viewport_height_; |
GLsizei viewport_max_width_, viewport_max_height_; |
+ // Texture upload stats. |
+ int texture_upload_count_; |
+ base::TimeDelta total_texture_upload_time_; |
+ |
DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
}; |
@@ -1698,6 +1718,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 +2019,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 +2866,14 @@ bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id, |
return false; |
} |
+uint32 GLES2DecoderImpl::GetTextureUploadCount() { |
+ return texture_upload_count_; |
+} |
+ |
+double GLES2DecoderImpl::GetTotalTextureUploadTimeInSeconds() { |
+ return total_texture_upload_time_.InSecondsF(); |
+} |
+ |
nduca
2012/08/28 19:45:10
while we're at it, can we add tracking for "time s
|
void GLES2DecoderImpl::Destroy(bool have_context) { |
DCHECK(!have_context || context_->IsCurrent(NULL)); |
@@ -7798,17 +7838,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); |
} |