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

Side by Side Diff: src/gpu/GrTest.cpp

Issue 894013002: patch from issue 886233004 at patchset 40001 (http://crrev.com/886233004#ps40001) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrResourceCache2.cpp ('k') | src/gpu/gl/GrGLGpu.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrTest.h" 9 #include "GrTest.h"
10 10
11 #include "GrInOrderDrawBuffer.h" 11 #include "GrInOrderDrawBuffer.h"
12 #include "GrResourceCache2.h" 12 #include "GrResourceCache2.h"
13 #include "SkString.h"
13 14
14 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target) { 15 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target) {
15 SkASSERT(!fContext); 16 SkASSERT(!fContext);
16 17
17 fContext.reset(SkRef(ctx)); 18 fContext.reset(SkRef(ctx));
18 fDrawTarget.reset(SkRef(target)); 19 fDrawTarget.reset(SkRef(target));
19 20
20 SkNEW_IN_TLAZY(&fACR, GrDrawTarget::AutoClipRestore, (target)); 21 SkNEW_IN_TLAZY(&fACR, GrDrawTarget::AutoClipRestore, (target));
21 SkNEW_IN_TLAZY(&fAGP, GrDrawTarget::AutoGeometryPush, (target)); 22 SkNEW_IN_TLAZY(&fAGP, GrDrawTarget::AutoGeometryPush, (target));
22 } 23 }
(...skipping 10 matching lines...) Expand all
33 /////////////////////////////////////////////////////////////////////////////// 34 ///////////////////////////////////////////////////////////////////////////////
34 35
35 void GrContext::setMaxTextureSizeOverride(int maxTextureSizeOverride) { 36 void GrContext::setMaxTextureSizeOverride(int maxTextureSizeOverride) {
36 fMaxTextureSizeOverride = maxTextureSizeOverride; 37 fMaxTextureSizeOverride = maxTextureSizeOverride;
37 } 38 }
38 39
39 void GrContext::purgeAllUnlockedResources() { 40 void GrContext::purgeAllUnlockedResources() {
40 fResourceCache2->purgeAllUnlocked(); 41 fResourceCache2->purgeAllUnlocked();
41 } 42 }
42 43
44 void GrContext::dumpCacheStats(SkString* out) const {
45 #if GR_CACHE_STATS
46 fResourceCache2->dumpStats(out);
47 #endif
48 }
49
50 void GrContext::printCacheStats() const {
51 SkString out;
52 this->dumpCacheStats(&out);
53 SkDebugf(out.c_str());
54 }
55
56 void GrContext::dumpGpuStats(SkString* out) const {
57 #if GR_GPU_STATS
58 return fGpu->stats()->dump(out);
59 #endif
60 }
61
62 void GrContext::printGpuStats() const {
63 SkString out;
64 this->dumpGpuStats(&out);
65 SkDebugf(out.c_str());
66 }
67
68 #if GR_GPU_STATS
69 void GrGpu::Stats::dump(SkString* out) {
70 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds);
71 out->appendf("Shader Compilations: %d\n", fShaderCompilations);
72 }
73 #endif
74
75 #if GR_CACHE_STATS
76 void GrResourceCache2::dumpStats(SkString* out) const {
77 this->validate();
78
79 int locked = 0;
80 int scratch = 0;
81 int wrapped = 0;
82 size_t unbudgetedSize = 0;
83
84 ResourceList::Iter iter;
85 GrGpuResource* resource = iter.init(fResources, ResourceList::Iter::kHead_It erStart);
86
87 for ( ; resource; resource = iter.next()) {
88 if (!resource->isPurgeable()) {
89 ++locked;
90 }
91 if (resource->cacheAccess().isScratch()) {
92 ++scratch;
93 }
94 if (resource->cacheAccess().isWrapped()) {
95 ++wrapped;
96 }
97 if (!resource->cacheAccess().isBudgeted()) {
98 unbudgetedSize += resource->gpuMemorySize();
99 }
100 }
101
102 float countUtilization = (100.f * fBudgetedCount) / fMaxCount;
103 float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes;
104
105 out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes);
106 out->appendf("\t\tEntry Count: current %d"
107 " (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full), high %d\n",
108 fCount, fBudgetedCount, wrapped, locked, scratch, countUtilizat ion,
109 fHighWaterCount);
110 out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbu dgeted) high %d\n",
111 (int)fBytes, (int)fBudgetedBytes, byteUtilization,
112 (int)unbudgetedSize, (int)fHighWaterBytes);
113 }
114
115 #endif
116
117
43 /////////////////////////////////////////////////////////////////////////////// 118 ///////////////////////////////////////////////////////////////////////////////
44 // Code for the mock context. It's built on a mock GrGpu class that does nothing . 119 // Code for the mock context. It's built on a mock GrGpu class that does nothing .
45 //// 120 ////
46 121
47 #include "GrBufferAllocPool.h" 122 #include "GrBufferAllocPool.h"
48 #include "GrInOrderDrawBuffer.h" 123 #include "GrInOrderDrawBuffer.h"
49 #include "GrGpu.h" 124 #include "GrGpu.h"
50 125
51 class GrPipeline; 126 class GrPipeline;
52 127
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // these objects are required for any of tests that use this context. TODO: make stop allocating 254 // these objects are required for any of tests that use this context. TODO: make stop allocating
180 // resources in the buffer pools. 255 // resources in the buffer pools.
181 SkDELETE(fDrawBuffer); 256 SkDELETE(fDrawBuffer);
182 SkDELETE(fDrawBufferVBAllocPool); 257 SkDELETE(fDrawBufferVBAllocPool);
183 SkDELETE(fDrawBufferIBAllocPool); 258 SkDELETE(fDrawBufferIBAllocPool);
184 259
185 fDrawBuffer = NULL; 260 fDrawBuffer = NULL;
186 fDrawBufferVBAllocPool = NULL; 261 fDrawBufferVBAllocPool = NULL;
187 fDrawBufferIBAllocPool = NULL; 262 fDrawBufferIBAllocPool = NULL;
188 } 263 }
OLDNEW
« no previous file with comments | « src/gpu/GrResourceCache2.cpp ('k') | src/gpu/gl/GrGLGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698