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

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

Issue 808593003: Rename GrGpuGL to GrGLGpu for consistency (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 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/GrGpuGL.cpp ('k') | src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp » ('j') | 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 "GrGpuGL.h" 8 #include "GrGpuGL.h"
9 9
10 #include "builders/GrGLProgramBuilder.h" 10 #include "builders/GrGLProgramBuilder.h"
11 #include "GrProcessor.h" 11 #include "GrProcessor.h"
12 #include "GrGLProcessor.h" 12 #include "GrGLProcessor.h"
13 #include "GrGLPathRendering.h" 13 #include "GrGLPathRendering.h"
14 #include "GrOptDrawState.h" 14 #include "GrOptDrawState.h"
15 #include "SkRTConf.h" 15 #include "SkRTConf.h"
16 #include "SkTSearch.h" 16 #include "SkTSearch.h"
17 17
18 #ifdef PROGRAM_CACHE_STATS 18 #ifdef PROGRAM_CACHE_STATS
19 SK_CONF_DECLARE(bool, c_DisplayCache, "gpu.displayCache", false, 19 SK_CONF_DECLARE(bool, c_DisplayCache, "gpu.displayCache", false,
20 "Display program cache usage."); 20 "Display program cache usage.");
21 #endif 21 #endif
22 22
23 typedef GrGLProgramDataManager::UniformHandle UniformHandle; 23 typedef GrGLProgramDataManager::UniformHandle UniformHandle;
24 24
25 struct GrGpuGL::ProgramCache::Entry { 25 struct GrGLGpu::ProgramCache::Entry {
26 SK_DECLARE_INST_COUNT_ROOT(Entry); 26 SK_DECLARE_INST_COUNT_ROOT(Entry);
27 Entry() : fProgram(NULL), fLRUStamp(0) {} 27 Entry() : fProgram(NULL), fLRUStamp(0) {}
28 28
29 SkAutoTUnref<GrGLProgram> fProgram; 29 SkAutoTUnref<GrGLProgram> fProgram;
30 unsigned int fLRUStamp; 30 unsigned int fLRUStamp;
31 }; 31 };
32 32
33 struct GrGpuGL::ProgramCache::ProgDescLess { 33 struct GrGLGpu::ProgramCache::ProgDescLess {
34 bool operator() (const GrProgramDesc& desc, const Entry* entry) { 34 bool operator() (const GrProgramDesc& desc, const Entry* entry) {
35 SkASSERT(entry->fProgram.get()); 35 SkASSERT(entry->fProgram.get());
36 return GrProgramDesc::Less(desc, entry->fProgram->getDesc()); 36 return GrProgramDesc::Less(desc, entry->fProgram->getDesc());
37 } 37 }
38 38
39 bool operator() (const Entry* entry, const GrProgramDesc& desc) { 39 bool operator() (const Entry* entry, const GrProgramDesc& desc) {
40 SkASSERT(entry->fProgram.get()); 40 SkASSERT(entry->fProgram.get());
41 return GrProgramDesc::Less(entry->fProgram->getDesc(), desc); 41 return GrProgramDesc::Less(entry->fProgram->getDesc(), desc);
42 } 42 }
43 }; 43 };
44 44
45 GrGpuGL::ProgramCache::ProgramCache(GrGpuGL* gpu) 45 GrGLGpu::ProgramCache::ProgramCache(GrGLGpu* gpu)
46 : fCount(0) 46 : fCount(0)
47 , fCurrLRUStamp(0) 47 , fCurrLRUStamp(0)
48 , fGpu(gpu) 48 , fGpu(gpu)
49 #ifdef PROGRAM_CACHE_STATS 49 #ifdef PROGRAM_CACHE_STATS
50 , fTotalRequests(0) 50 , fTotalRequests(0)
51 , fCacheMisses(0) 51 , fCacheMisses(0)
52 , fHashMisses(0) 52 , fHashMisses(0)
53 #endif 53 #endif
54 { 54 {
55 for (int i = 0; i < 1 << kHashBits; ++i) { 55 for (int i = 0; i < 1 << kHashBits; ++i) {
56 fHashTable[i] = NULL; 56 fHashTable[i] = NULL;
57 } 57 }
58 } 58 }
59 59
60 GrGpuGL::ProgramCache::~ProgramCache() { 60 GrGLGpu::ProgramCache::~ProgramCache() {
61 for (int i = 0; i < fCount; ++i){ 61 for (int i = 0; i < fCount; ++i){
62 SkDELETE(fEntries[i]); 62 SkDELETE(fEntries[i]);
63 } 63 }
64 // dump stats 64 // dump stats
65 #ifdef PROGRAM_CACHE_STATS 65 #ifdef PROGRAM_CACHE_STATS
66 if (c_DisplayCache) { 66 if (c_DisplayCache) {
67 SkDebugf("--- Program Cache ---\n"); 67 SkDebugf("--- Program Cache ---\n");
68 SkDebugf("Total requests: %d\n", fTotalRequests); 68 SkDebugf("Total requests: %d\n", fTotalRequests);
69 SkDebugf("Cache misses: %d\n", fCacheMisses); 69 SkDebugf("Cache misses: %d\n", fCacheMisses);
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 GrGpuGL::ProgramCache::abandon() { 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 SkDELETE(fEntries[i]); 84 SkDELETE(fEntries[i]);
85 } 85 }
86 fCount = 0; 86 fCount = 0;
87 } 87 }
88 88
89 int GrGpuGL::ProgramCache::search(const GrProgramDesc& desc) const { 89 int GrGLGpu::ProgramCache::search(const GrProgramDesc& desc) const {
90 ProgDescLess less; 90 ProgDescLess less;
91 return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less); 91 return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less);
92 } 92 }
93 93
94 GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState) { 94 GrGLProgram* GrGLGpu::ProgramCache::getProgram(const GrOptDrawState& optState) {
95 #ifdef PROGRAM_CACHE_STATS 95 #ifdef PROGRAM_CACHE_STATS
96 ++fTotalRequests; 96 ++fTotalRequests;
97 #endif 97 #endif
98 98
99 Entry* entry = NULL; 99 Entry* entry = NULL;
100 100
101 uint32_t hashIdx = optState.programDesc().getChecksum(); 101 uint32_t hashIdx = optState.programDesc().getChecksum();
102 hashIdx ^= hashIdx >> 16; 102 hashIdx ^= hashIdx >> 16;
103 if (kHashBits <= 8) { 103 if (kHashBits <= 8) {
104 hashIdx ^= hashIdx >> 8; 104 hashIdx ^= hashIdx >> 8;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 if (SK_MaxU32 == fCurrLRUStamp) { 190 if (SK_MaxU32 == fCurrLRUStamp) {
191 // wrap around! just trash our LRU, one time hit. 191 // wrap around! just trash our LRU, one time hit.
192 for (int i = 0; i < fCount; ++i) { 192 for (int i = 0; i < fCount; ++i) {
193 fEntries[i]->fLRUStamp = 0; 193 fEntries[i]->fLRUStamp = 0;
194 } 194 }
195 } 195 }
196 ++fCurrLRUStamp; 196 ++fCurrLRUStamp;
197 return entry->fProgram; 197 return entry->fProgram;
198 } 198 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.cpp ('k') | src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698