| 1 |
/* |
| 2 |
* Copyright 2021 Google Inc. |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
*/ |
| 7 |
|
| 8 |
#include "src/gpu/ganesh/GrThreadSafePipelineBuilder.h" |
| 9 |
|
| 10 |
#if GR_GPU_STATS |
| 11 |
#if defined(GPU_TEST_UTILS) |
| 12 |
#include "include/core/SkString.h" |
| 13 |
|
| 14 |
using namespace skia_private; |
| 15 |
|
| 16 |
using Stats = GrThreadSafePipelineBuilder::Stats; |
| 17 |
|
| 18 |
static const char* cache_result_to_str(int i) { |
| 19 |
const char* kCacheResultStrings[Stats::kNumProgramCacheResults] = { |
| 20 |
"hits", |
| 21 |
"misses", |
| 22 |
"partials" |
| 23 |
}; |
| 24 |
static_assert(0 == (int) Stats::ProgramCacheResult::kHit); |
| 25 |
static_assert(1 == (int) Stats::ProgramCacheResult::kMiss); |
| 26 |
static_assert(2 == (int) Stats::ProgramCacheResult::kPartial); |
| 27 |
static_assert(Stats::kNumProgramCacheResults == 3); |
| 28 |
return kCacheResultStrings[i]; |
| 29 |
} |
| 30 |
|
| 31 |
void GrThreadSafePipelineBuilder::Stats::dump(SkString* out) { |
| 32 |
out->appendf("Shader Compilations: %d\n", fShaderCompilations.load()); |
| 33 |
|
| 34 |
SkASSERT(fNumInlineCompilationFailures == 0); |
| 35 |
out->appendf("Number of Inline compile failures %d\n", fNumInlineCompilationFailures.load()); |
| 36 |
for (int i = 0; i < Stats::kNumProgramCacheResults-1; ++i) { |
| 37 |
out->appendf("Inline Program Cache %s %d\n", cache_result_to_str(i), |
| 38 |
fInlineProgramCacheStats[i].load()); |
| 39 |
} |
| 40 |
|
| 41 |
SkASSERT(fNumPreCompilationFailures == 0); |
| 42 |
out->appendf("Number of precompile failures %d\n", fNumPreCompilationFailures.load()); |
| 43 |
for (int i = 0; i < Stats::kNumProgramCacheResults-1; ++i) { |
| 44 |
out->appendf("Precompile Program Cache %s %d\n", cache_result_to_str(i), |
| 45 |
fPreProgramCacheStats[i].load()); |
| 46 |
} |
| 47 |
|
| 48 |
SkASSERT(fNumCompilationFailures == 0); |
| 49 |
out->appendf("Total number of compilation failures %d\n", fNumCompilationFailures.load()); |
| 50 |
out->appendf("Total number of partial compilation successes %d\n", |
| 51 |
fNumPartialCompilationSuccesses.load()); |
| 52 |
out->appendf("Total number of compilation successes %d\n", fNumCompilationSuccesses.load()); |
| 53 |
} |
| 54 |
|
| 55 |
void GrThreadSafePipelineBuilder::Stats::dumpKeyValuePairs(TArray<SkString>* keys, |
| 56 |
TArray<double>* values) { |
| 57 |
keys->push_back(SkString("shader_compilations")); values->push_back(fShaderCompilations); |
| 58 |
} |
| 59 |
|
| 60 |
#endif // defined(GPU_TEST_UTILS) |
| 61 |
#endif // GR_GPU_STATS |