| OLD | NEW |
| 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 Loading... |
| 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() { | 80 void GrGLGpu::ProgramCache::abandon() { |
| 81 for (int i = 0; i < fCount; ++i) { | 81 for (int i = 0; i < fCount; ++i) { |
| 82 SkASSERT(fEntries[i]->fProgram.get()); | 82 SkASSERT(fEntries[i]->fProgram.get()); |
| 83 fEntries[i]->fProgram->abandon(); | 83 fEntries[i]->fProgram->abandon(); |
| 84 delete fEntries[i]; | 84 delete fEntries[i]; |
| 85 fEntries[i] = nullptr; | 85 fEntries[i] = nullptr; |
| 86 } | 86 } |
| 87 fCount = 0; | 87 fCount = 0; |
| 88 | 88 |
| 89 // zero out hash table | 89 // zero out hash table |
| 90 for (int i = 0; i < 1 << kHashBits; i++) { | 90 for (int i = 0; i < 1 << kHashBits; i++) { |
| 91 fHashTable[i] = nullptr; | 91 fHashTable[i] = nullptr; |
| 92 } | 92 } |
| 93 | 93 |
| 94 fCurrLRUStamp = 0; | 94 fCurrLRUStamp = 0; |
| 95 #ifdef PROGRAM_CACHE_STATS | 95 #ifdef PROGRAM_CACHE_STATS |
| 96 fTotalRequests = 0; | 96 fTotalRequests = 0; |
| 97 fCacheMisses = 0; | 97 fCacheMisses = 0; |
| 98 fHashMisses = 0; | 98 fHashMisses = 0; |
| 99 #endif | 99 #endif |
| 100 } | 100 } |
| 101 | 101 |
| 102 void GrGLGpu::ProgramCache::abandon() { | |
| 103 this->reset(); | |
| 104 } | |
| 105 | |
| 106 int GrGLGpu::ProgramCache::search(const GrProgramDesc& desc) const { | 102 int GrGLGpu::ProgramCache::search(const GrProgramDesc& desc) const { |
| 107 ProgDescLess less; | 103 ProgDescLess less; |
| 108 return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less); | 104 return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less); |
| 109 } | 105 } |
| 110 | 106 |
| 111 GrGLProgram* GrGLGpu::ProgramCache::refProgram(const GrGLGpu* gpu, | 107 GrGLProgram* GrGLGpu::ProgramCache::refProgram(const GrGLGpu* gpu, |
| 112 const GrPipeline& pipeline, | 108 const GrPipeline& pipeline, |
| 113 const GrPrimitiveProcessor& primP
roc) { | 109 const GrPrimitiveProcessor& primP
roc) { |
| 114 #ifdef PROGRAM_CACHE_STATS | 110 #ifdef PROGRAM_CACHE_STATS |
| 115 ++fTotalRequests; | 111 ++fTotalRequests; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 211 |
| 216 if (SK_MaxU32 == fCurrLRUStamp) { | 212 if (SK_MaxU32 == fCurrLRUStamp) { |
| 217 // wrap around! just trash our LRU, one time hit. | 213 // wrap around! just trash our LRU, one time hit. |
| 218 for (int i = 0; i < fCount; ++i) { | 214 for (int i = 0; i < fCount; ++i) { |
| 219 fEntries[i]->fLRUStamp = 0; | 215 fEntries[i]->fLRUStamp = 0; |
| 220 } | 216 } |
| 221 } | 217 } |
| 222 ++fCurrLRUStamp; | 218 ++fCurrLRUStamp; |
| 223 return SkRef(entry->fProgram.get()); | 219 return SkRef(entry->fProgram.get()); |
| 224 } | 220 } |
| OLD | NEW |