Add texture create/upload stats and make nanobench have explicit gpu stats flag

Review URL: https://codereview.chromium.org/891973002
This commit is contained in:
bsalomon 2015-02-02 21:19:50 -08:00 committed by Commit bot
parent 9bf4e5bbf6
commit b12ea41286
4 changed files with 32 additions and 5 deletions

View File

@ -75,6 +75,7 @@ DEFINE_bool(bbh, true, "Build a BBH for SKPs?");
DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?");
DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run.");
DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test.");
DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?");
static SkString humanize(double ms) {
if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6));
@ -766,10 +767,11 @@ int nanobench_main() {
, bench->getUniqueName()
);
}
#if SK_SUPPORT_GPU && GR_CACHE_STATS
if (FLAGS_veryVerbose &&
#if SK_SUPPORT_GPU
if (FLAGS_gpuStats &&
Benchmark::kGPU_Backend == targets[j]->config.backend) {
gGrFactory->get(targets[j]->config.ctxType)->printCacheStats();
gGrFactory->get(targets[j]->config.ctxType)->printGpuStats();
}
#endif
}

View File

@ -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) {

View File

@ -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
};

View File

@ -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