OLD | NEW |
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 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds); | 133 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds); |
134 out->appendf("Shader Compilations: %d\n", fShaderCompilations); | 134 out->appendf("Shader Compilations: %d\n", fShaderCompilations); |
135 out->appendf("Textures Created: %d\n", fTextureCreates); | 135 out->appendf("Textures Created: %d\n", fTextureCreates); |
136 out->appendf("Texture Uploads: %d\n", fTextureUploads); | 136 out->appendf("Texture Uploads: %d\n", fTextureUploads); |
137 out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates); | 137 out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates); |
138 out->appendf("Number of draws: %d\n", fNumDraws); | 138 out->appendf("Number of draws: %d\n", fNumDraws); |
139 } | 139 } |
140 #endif | 140 #endif |
141 | 141 |
142 #if GR_CACHE_STATS | 142 #if GR_CACHE_STATS |
| 143 void GrResourceCache::getStats(Stats* stats) const { |
| 144 stats->reset(); |
| 145 |
| 146 stats->fTotal = this->getResourceCount(); |
| 147 stats->fNumNonPurgeable = fNonpurgeableResources.count(); |
| 148 stats->fNumPurgeable = fPurgeableQueue.count(); |
| 149 |
| 150 for (int i = 0; i < fNonpurgeableResources.count(); ++i) { |
| 151 stats->update(fNonpurgeableResources[i]); |
| 152 } |
| 153 for (int i = 0; i < fPurgeableQueue.count(); ++i) { |
| 154 stats->update(fPurgeableQueue.at(i)); |
| 155 } |
| 156 } |
| 157 |
143 void GrResourceCache::dumpStats(SkString* out) const { | 158 void GrResourceCache::dumpStats(SkString* out) const { |
144 this->validate(); | 159 this->validate(); |
145 | 160 |
146 int locked = fNonpurgeableResources.count(); | |
147 | |
148 struct Stats { | |
149 int fScratch; | |
150 int fExternal; | |
151 int fBorrowed; | |
152 int fAdopted; | |
153 size_t fUnbudgetedSize; | |
154 | |
155 Stats() : fScratch(0), fExternal(0), fBorrowed(0), fAdopted(0), fUnbudge
tedSize(0) {} | |
156 | |
157 void update(GrGpuResource* resource) { | |
158 if (resource->cacheAccess().isScratch()) { | |
159 ++fScratch; | |
160 } | |
161 if (resource->cacheAccess().isExternal()) { | |
162 ++fExternal; | |
163 } | |
164 if (resource->cacheAccess().isBorrowed()) { | |
165 ++fBorrowed; | |
166 } | |
167 if (resource->cacheAccess().isAdopted()) { | |
168 ++fAdopted; | |
169 } | |
170 if (!resource->resourcePriv().isBudgeted()) { | |
171 fUnbudgetedSize += resource->gpuMemorySize(); | |
172 } | |
173 } | |
174 }; | |
175 | |
176 Stats stats; | 161 Stats stats; |
177 | 162 |
178 for (int i = 0; i < fNonpurgeableResources.count(); ++i) { | 163 this->getStats(&stats); |
179 stats.update(fNonpurgeableResources[i]); | |
180 } | |
181 for (int i = 0; i < fPurgeableQueue.count(); ++i) { | |
182 stats.update(fPurgeableQueue.at(i)); | |
183 } | |
184 | 164 |
185 float countUtilization = (100.f * fBudgetedCount) / fMaxCount; | 165 float countUtilization = (100.f * fBudgetedCount) / fMaxCount; |
186 float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes; | 166 float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes; |
187 | 167 |
188 out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes); | 168 out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes); |
189 out->appendf("\t\tEntry Count: current %d" | 169 out->appendf("\t\tEntry Count: current %d" |
190 " (%d budgeted, %d external(%d borrowed, %d adopted), %d locked
, %d scratch %.2g%% full), high %d\n", | 170 " (%d budgeted, %d external(%d borrowed, %d adopted), %d locked
, %d scratch %.2g%% full), high %d\n", |
191 this->getResourceCount(), fBudgetedCount, stats.fExternal, stat
s.fBorrowed, | 171 stats.fTotal, fBudgetedCount, stats.fExternal, stats.fBorrowed, |
192 stats.fAdopted, locked, stats.fScratch, countUtilization, fHigh
WaterCount); | 172 stats.fAdopted, stats.fNumNonPurgeable, stats.fScratch, countUt
ilization, |
| 173 fHighWaterCount); |
193 out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbu
dgeted) high %d\n", | 174 out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbu
dgeted) high %d\n", |
194 SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization, | 175 SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization, |
195 SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes)); | 176 SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes)); |
196 } | 177 } |
197 | 178 |
198 #endif | 179 #endif |
199 | 180 |
200 /////////////////////////////////////////////////////////////////////////////// | 181 /////////////////////////////////////////////////////////////////////////////// |
201 | 182 |
202 void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newT
imestamp; } | 183 void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newT
imestamp; } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 SkASSERT(nullptr == fGpu); | 300 SkASSERT(nullptr == fGpu); |
320 fGpu = new MockGpu(this, options); | 301 fGpu = new MockGpu(this, options); |
321 SkASSERT(fGpu); | 302 SkASSERT(fGpu); |
322 this->initCommon(options); | 303 this->initCommon(options); |
323 | 304 |
324 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of | 305 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of |
325 // these objects are required for any of tests that use this context. TODO:
make stop allocating | 306 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
326 // resources in the buffer pools. | 307 // resources in the buffer pools. |
327 fDrawingManager->abandon(); | 308 fDrawingManager->abandon(); |
328 } | 309 } |
OLD | NEW |