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

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

Issue 932863004: Use an array of nonpurgeable resources in GrResourceCache (Closed) Base URL: https://skia.googlesource.com/skia.git@queue
Patch Set: skdebugf- 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/GrResourceCache.cpp ('k') | no next file » | 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
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 out->appendf("Shader Compilations: %d\n", fShaderCompilations); 72 out->appendf("Shader Compilations: %d\n", fShaderCompilations);
73 out->appendf("Textures Created: %d\n", fTextureCreates); 73 out->appendf("Textures Created: %d\n", fTextureCreates);
74 out->appendf("Texture Uploads: %d\n", fTextureUploads); 74 out->appendf("Texture Uploads: %d\n", fTextureUploads);
75 } 75 }
76 #endif 76 #endif
77 77
78 #if GR_CACHE_STATS 78 #if GR_CACHE_STATS
79 void GrResourceCache::dumpStats(SkString* out) const { 79 void GrResourceCache::dumpStats(SkString* out) const {
80 this->validate(); 80 this->validate();
81 81
82 int locked = 0; 82 int locked = fNonpurgeableResources.count();
83 int scratch = 0;
84 int wrapped = 0;
85 size_t unbudgetedSize = 0;
86 83
87 ResourceList::Iter iter; 84 struct Stats {
88 GrGpuResource* resource = iter.init(fResources, ResourceList::Iter::kHead_It erStart); 85 int fScratch;
86 int fWrapped;
87 size_t fUnbudgetedSize;
89 88
90 for ( ; resource; resource = iter.next()) { 89 Stats() : fScratch(0), fWrapped(0), fUnbudgetedSize(0) {}
91 if (!resource->isPurgeable()) { 90
92 ++locked; 91 void update(GrGpuResource* resource) {
92 if (resource->cacheAccess().isScratch()) {
93 ++fScratch;
94 }
95 if (resource->cacheAccess().isWrapped()) {
96 ++fWrapped;
97 }
98 if (!resource->resourcePriv().isBudgeted()) {
99 fUnbudgetedSize += resource->gpuMemorySize();
100 }
93 } 101 }
94 if (resource->cacheAccess().isScratch()) { 102 };
95 ++scratch; 103
96 } 104 Stats stats;
97 if (resource->cacheAccess().isWrapped()) { 105
98 ++wrapped; 106 for (int i = 0; i < fNonpurgeableResources.count(); ++i) {
99 } 107 stats.update(fNonpurgeableResources[i]);
100 if (!resource->resourcePriv().isBudgeted()) { 108 }
101 unbudgetedSize += resource->gpuMemorySize(); 109 for (int i = 0; i < fPurgeableQueue.count(); ++i) {
102 } 110 stats.update(fPurgeableQueue.at(i));
103 } 111 }
104 112
105 float countUtilization = (100.f * fBudgetedCount) / fMaxCount; 113 float countUtilization = (100.f * fBudgetedCount) / fMaxCount;
106 float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes; 114 float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes;
107 115
108 out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes); 116 out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes);
109 out->appendf("\t\tEntry Count: current %d" 117 out->appendf("\t\tEntry Count: current %d"
110 " (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full), high %d\n", 118 " (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full), high %d\n",
111 fCount, fBudgetedCount, wrapped, locked, scratch, countUtilizat ion, 119 fCount, fBudgetedCount, stats.fWrapped, locked, stats.fScratch, countUtilization,
112 fHighWaterCount); 120 fHighWaterCount);
113 out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbu dgeted) high %d\n", 121 out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbu dgeted) high %d\n",
114 (int)fBytes, (int)fBudgetedBytes, byteUtilization, 122 SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization,
115 (int)unbudgetedSize, (int)fHighWaterBytes); 123 SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes));
116 } 124 }
117 125
118 #endif 126 #endif
119 127
120 128
121 /////////////////////////////////////////////////////////////////////////////// 129 ///////////////////////////////////////////////////////////////////////////////
122 // Code for the mock context. It's built on a mock GrGpu class that does nothing . 130 // Code for the mock context. It's built on a mock GrGpu class that does nothing .
123 //// 131 ////
124 132
125 #include "GrBufferAllocPool.h" 133 #include "GrBufferAllocPool.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 // these objects are required for any of tests that use this context. TODO: make stop allocating 264 // these objects are required for any of tests that use this context. TODO: make stop allocating
257 // resources in the buffer pools. 265 // resources in the buffer pools.
258 SkDELETE(fDrawBuffer); 266 SkDELETE(fDrawBuffer);
259 SkDELETE(fDrawBufferVBAllocPool); 267 SkDELETE(fDrawBufferVBAllocPool);
260 SkDELETE(fDrawBufferIBAllocPool); 268 SkDELETE(fDrawBufferIBAllocPool);
261 269
262 fDrawBuffer = NULL; 270 fDrawBuffer = NULL;
263 fDrawBufferVBAllocPool = NULL; 271 fDrawBufferVBAllocPool = NULL;
264 fDrawBufferIBAllocPool = NULL; 272 fDrawBufferIBAllocPool = NULL;
265 } 273 }
OLDNEW
« no previous file with comments | « src/gpu/GrResourceCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698