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

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

Issue 1406013006: Update Layer Hoisting to store its atlas texture in the resource cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix build Created 5 years, 1 month 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
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
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds); 102 out->appendf("Render Target Binds: %d\n", fRenderTargetBinds);
103 out->appendf("Shader Compilations: %d\n", fShaderCompilations); 103 out->appendf("Shader Compilations: %d\n", fShaderCompilations);
104 out->appendf("Textures Created: %d\n", fTextureCreates); 104 out->appendf("Textures Created: %d\n", fTextureCreates);
105 out->appendf("Texture Uploads: %d\n", fTextureUploads); 105 out->appendf("Texture Uploads: %d\n", fTextureUploads);
106 out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates); 106 out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates);
107 out->appendf("Number of draws: %d\n", fNumDraws); 107 out->appendf("Number of draws: %d\n", fNumDraws);
108 } 108 }
109 #endif 109 #endif
110 110
111 #if GR_CACHE_STATS 111 #if GR_CACHE_STATS
112 void GrResourceCache::getStats(Stats* stats) const {
113 stats->reset();
114
115 stats->fTotal = this->getResourceCount();
116 stats->fNumNonPurgeable = fNonpurgeableResources.count();
117 stats->fNumPurgeable = fPurgeableQueue.count();
118
119 for (int i = 0; i < fNonpurgeableResources.count(); ++i) {
120 stats->update(fNonpurgeableResources[i]);
121 }
122 for (int i = 0; i < fPurgeableQueue.count(); ++i) {
123 stats->update(fPurgeableQueue.at(i));
124 }
125 }
126
112 void GrResourceCache::dumpStats(SkString* out) const { 127 void GrResourceCache::dumpStats(SkString* out) const {
113 this->validate(); 128 this->validate();
114 129
115 int locked = fNonpurgeableResources.count();
116
117 struct Stats {
118 int fScratch;
119 int fExternal;
120 int fBorrowed;
121 int fAdopted;
122 size_t fUnbudgetedSize;
123
124 Stats() : fScratch(0), fExternal(0), fBorrowed(0), fAdopted(0), fUnbudge tedSize(0) {}
125
126 void update(GrGpuResource* resource) {
127 if (resource->cacheAccess().isScratch()) {
128 ++fScratch;
129 }
130 if (resource->cacheAccess().isExternal()) {
131 ++fExternal;
132 }
133 if (resource->cacheAccess().isBorrowed()) {
134 ++fBorrowed;
135 }
136 if (resource->cacheAccess().isAdopted()) {
137 ++fAdopted;
138 }
139 if (!resource->resourcePriv().isBudgeted()) {
140 fUnbudgetedSize += resource->gpuMemorySize();
141 }
142 }
143 };
144
145 Stats stats; 130 Stats stats;
146 131
147 for (int i = 0; i < fNonpurgeableResources.count(); ++i) { 132 this->getStats(&stats);
148 stats.update(fNonpurgeableResources[i]);
149 }
150 for (int i = 0; i < fPurgeableQueue.count(); ++i) {
151 stats.update(fPurgeableQueue.at(i));
152 }
153 133
154 float countUtilization = (100.f * fBudgetedCount) / fMaxCount; 134 float countUtilization = (100.f * fBudgetedCount) / fMaxCount;
155 float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes; 135 float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes;
156 136
157 out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes); 137 out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes);
158 out->appendf("\t\tEntry Count: current %d" 138 out->appendf("\t\tEntry Count: current %d"
159 " (%d budgeted, %d external(%d borrowed, %d adopted), %d locked , %d scratch %.2g%% full), high %d\n", 139 " (%d budgeted, %d external(%d borrowed, %d adopted), %d locked , %d scratch %.2g%% full), high %d\n",
160 this->getResourceCount(), fBudgetedCount, stats.fExternal, stat s.fBorrowed, 140 stats.fTotal, fBudgetedCount, stats.fExternal, stats.fBorrowed,
161 stats.fAdopted, locked, stats.fScratch, countUtilization, fHigh WaterCount); 141 stats.fAdopted, stats.fNumNonPurgeable, stats.fScratch, countUt ilization,
142 fHighWaterCount);
162 out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbu dgeted) high %d\n", 143 out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbu dgeted) high %d\n",
163 SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization, 144 SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization,
164 SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes)); 145 SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes));
165 } 146 }
166 147
167 #endif 148 #endif
168 149
169 /////////////////////////////////////////////////////////////////////////////// 150 ///////////////////////////////////////////////////////////////////////////////
170 151
171 void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newT imestamp; } 152 void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newT imestamp; }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 SkASSERT(nullptr == fGpu); 269 SkASSERT(nullptr == fGpu);
289 fGpu = new MockGpu(this, options); 270 fGpu = new MockGpu(this, options);
290 SkASSERT(fGpu); 271 SkASSERT(fGpu);
291 this->initCommon(options); 272 this->initCommon(options);
292 273
293 // We delete these because we want to test the cache starting with zero reso urces. Also, none of 274 // We delete these because we want to test the cache starting with zero reso urces. Also, none of
294 // these objects are required for any of tests that use this context. TODO: make stop allocating 275 // these objects are required for any of tests that use this context. TODO: make stop allocating
295 // resources in the buffer pools. 276 // resources in the buffer pools.
296 fDrawingManager->abandon(); 277 fDrawingManager->abandon();
297 } 278 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698