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

Side by Side Diff: src/gpu/gl/GrGLGpuProgramCache.cpp

Issue 1491823003: reset shader compilations for stats (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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/gl/GrGLGpu.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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrGLGpu.h" 8 #include "GrGLGpu.h"
9 9
10 #include "builders/GrGLProgramBuilder.h" 10 #include "builders/GrGLProgramBuilder.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 SkDebugf("Cache miss %%: %f\n", (fTotalRequests > 0) ? 70 SkDebugf("Cache miss %%: %f\n", (fTotalRequests > 0) ?
71 100.f * fCacheMisses / fTotalRequest s : 71 100.f * fCacheMisses / fTotalRequest s :
72 0.f); 72 0.f);
73 int cacheHits = fTotalRequests - fCacheMisses; 73 int cacheHits = fTotalRequests - fCacheMisses;
74 SkDebugf("Hash miss %%: %f\n", (cacheHits > 0) ? 100.f * fHashMisses / c acheHits : 0.f); 74 SkDebugf("Hash miss %%: %f\n", (cacheHits > 0) ? 100.f * fHashMisses / c acheHits : 0.f);
75 SkDebugf("---------------------\n"); 75 SkDebugf("---------------------\n");
76 } 76 }
77 #endif 77 #endif
78 } 78 }
79 79
80 void GrGLGpu::ProgramCache::reset() {
81 for (int i = 0; i < fCount; ++i) {
82 SkASSERT(fEntries[i]->fProgram.get());
83 fEntries[i]->fProgram->abandon();
84 delete fEntries[i];
85 fEntries[i] = nullptr;
86 }
87 fCount = 0;
88
89 // zero out hash table
90 for (int i = 0; i < 1 << kHashBits; i++) {
91 fHashTable[i] = nullptr;
92 }
93
94 fCurrLRUStamp = 0;
95 #ifdef PROGRAM_CACHE_STATS
96 fTotalRequests = 0;
97 fCacheMisses = 0;
98 fHashMisses = 0;
99 #endif
100 }
101
80 void GrGLGpu::ProgramCache::abandon() { 102 void GrGLGpu::ProgramCache::abandon() {
81 for (int i = 0; i < fCount; ++i) { 103 this->reset();
82 SkASSERT(fEntries[i]->fProgram.get());
83 fEntries[i]->fProgram->abandon();
84 delete fEntries[i];
85 }
86 fCount = 0;
87 } 104 }
88 105
89 int GrGLGpu::ProgramCache::search(const GrProgramDesc& desc) const { 106 int GrGLGpu::ProgramCache::search(const GrProgramDesc& desc) const {
90 ProgDescLess less; 107 ProgDescLess less;
91 return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less); 108 return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less);
92 } 109 }
93 110
94 GrGLProgram* GrGLGpu::ProgramCache::refProgram(const DrawArgs& args) { 111 GrGLProgram* GrGLGpu::ProgramCache::refProgram(const DrawArgs& args) {
95 #ifdef PROGRAM_CACHE_STATS 112 #ifdef PROGRAM_CACHE_STATS
96 ++fTotalRequests; 113 ++fTotalRequests;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 206
190 if (SK_MaxU32 == fCurrLRUStamp) { 207 if (SK_MaxU32 == fCurrLRUStamp) {
191 // wrap around! just trash our LRU, one time hit. 208 // wrap around! just trash our LRU, one time hit.
192 for (int i = 0; i < fCount; ++i) { 209 for (int i = 0; i < fCount; ++i) {
193 fEntries[i]->fLRUStamp = 0; 210 fEntries[i]->fLRUStamp = 0;
194 } 211 }
195 } 212 }
196 ++fCurrLRUStamp; 213 ++fCurrLRUStamp;
197 return SkRef(entry->fProgram.get()); 214 return SkRef(entry->fProgram.get());
198 } 215 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698