diff options
author | 2015-02-02 21:19:50 -0800 | |
---|---|---|
committer | 2015-02-02 21:19:50 -0800 | |
commit | b12ea41286ce36e085c5a14711da0cf9f240fdf1 (patch) | |
tree | b15b05bd994299e18753a1bb7d37942e447f22a5 /src | |
parent | 9bf4e5bbf6ca96042c0e0f5dca9a52a943f25716 (diff) |
Add texture create/upload stats and make nanobench have explicit gpu stats flag
Review URL: https://codereview.chromium.org/891973002
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrGpu.cpp | 14 | ||||
-rw-r--r-- | src/gpu/GrGpu.h | 15 | ||||
-rw-r--r-- | src/gpu/GrTest.cpp | 2 |
3 files changed, 28 insertions, 3 deletions
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 1566aab67f..67637e741a 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -74,6 +74,12 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, bool budgeted, if (!this->caps()->reuseScratchTextures() && !isRT) { tex->cacheAccess().removeScratchKey(); } + if (tex) { + fStats.incTextureCreates(); + if (srcData) { + fStats.incTextureUploads(); + } + } return tex; } @@ -203,8 +209,12 @@ bool GrGpu::writeTexturePixels(GrTexture* texture, GrPixelConfig config, const void* buffer, size_t rowBytes) { this->handleDirtyContext(); - return this->onWriteTexturePixels(texture, left, top, width, height, - config, buffer, rowBytes); + if (this->onWriteTexturePixels(texture, left, top, width, height, + config, buffer, rowBytes)) { + fStats.incTextureUploads(); + return true; + } + return false; } void GrGpu::resolveRenderTarget(GrRenderTarget* target) { diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index c989589117..8c458f18e8 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -369,21 +369,34 @@ public: #if GR_GPU_STATS Stats() { this->reset(); } - void reset() { fRenderTargetBinds = 0; fShaderCompilations = 0; } + void reset() { + fRenderTargetBinds = 0; + fShaderCompilations = 0; + fTextureCreates = 0; + fTextureUploads = 0; + } int renderTargetBinds() const { return fRenderTargetBinds; } void incRenderTargetBinds() { fRenderTargetBinds++; } int shaderCompilations() const { return fShaderCompilations; } void incShaderCompilations() { fShaderCompilations++; } + int textureCreates() const { return fTextureCreates; } + void incTextureCreates() { fTextureCreates++; } + int textureUploads() const { return fTextureUploads; } + void incTextureUploads() { fTextureUploads++; } void dump(SkString*); private: int fRenderTargetBinds; int fShaderCompilations; + int fTextureCreates; + int fTextureUploads; #else void dump(SkString*) {}; void incRenderTargetBinds() {} void incShaderCompilations() {} + void incTextureCreates() {} + void incTextureUploads() {} #endif }; diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp index 1689070308..05a4a5f956 100644 --- a/src/gpu/GrTest.cpp +++ b/src/gpu/GrTest.cpp @@ -69,6 +69,8 @@ void GrContext::printGpuStats() const { void GrGpu::Stats::dump(SkString* out) { out->appendf("Render Target Binds: %d\n", fRenderTargetBinds); out->appendf("Shader Compilations: %d\n", fShaderCompilations); + out->appendf("Textures Created: %d\n", fTextureCreates); + out->appendf("Texture Uploads: %d\n", fTextureUploads); } #endif |