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 "GrGpuGL.h" | 8 #include "GrGpuGL.h" |
9 | 9 |
10 #include "GrEffect.h" | 10 #include "GrEffect.h" |
11 #include "GrGLEffect.h" | 11 #include "GrGLEffect.h" |
| 12 #include "SkRTConf.h" |
12 #include "SkTSearch.h" | 13 #include "SkTSearch.h" |
13 | 14 |
| 15 SK_CONF_DECLARE(bool, c_DisplayCache, "gpu.displayCache", false, |
| 16 "Display program cache usage."); |
| 17 |
14 typedef GrGLUniformManager::UniformHandle UniformHandle; | 18 typedef GrGLUniformManager::UniformHandle UniformHandle; |
15 | 19 |
16 struct GrGpuGL::ProgramCache::Entry { | 20 struct GrGpuGL::ProgramCache::Entry { |
17 SK_DECLARE_INST_COUNT_ROOT(Entry); | 21 SK_DECLARE_INST_COUNT_ROOT(Entry); |
18 Entry() : fProgram(NULL), fLRUStamp(0) {} | 22 Entry() : fProgram(NULL), fLRUStamp(0) {} |
19 | 23 |
20 SkAutoTUnref<GrGLProgram> fProgram; | 24 SkAutoTUnref<GrGLProgram> fProgram; |
21 unsigned int fLRUStamp; | 25 unsigned int fLRUStamp; |
22 }; | 26 }; |
23 | 27 |
(...skipping 25 matching lines...) Expand all Loading... |
49 fHashTable[i] = NULL; | 53 fHashTable[i] = NULL; |
50 } | 54 } |
51 } | 55 } |
52 | 56 |
53 GrGpuGL::ProgramCache::~ProgramCache() { | 57 GrGpuGL::ProgramCache::~ProgramCache() { |
54 for (int i = 0; i < fCount; ++i){ | 58 for (int i = 0; i < fCount; ++i){ |
55 SkDELETE(fEntries[i]); | 59 SkDELETE(fEntries[i]); |
56 } | 60 } |
57 // dump stats | 61 // dump stats |
58 #ifdef PROGRAM_CACHE_STATS | 62 #ifdef PROGRAM_CACHE_STATS |
59 SkDebugf("--- Program Cache ---\n"); | 63 if (c_DisplayCache) { |
60 SkDebugf("Total requests: %d\n", fTotalRequests); | 64 SkDebugf("--- Program Cache ---\n"); |
61 SkDebugf("Cache misses: %d\n", fCacheMisses); | 65 SkDebugf("Total requests: %d\n", fTotalRequests); |
62 SkDebugf("Cache miss %%: %f\n", (fTotalRequests > 0) ? | 66 SkDebugf("Cache misses: %d\n", fCacheMisses); |
63 100.f * fCacheMisses / fTotalRequests : | 67 SkDebugf("Cache miss %%: %f\n", (fTotalRequests > 0) ? |
64 0.f); | 68 100.f * fCacheMisses / fTotalRequest
s : |
65 int cacheHits = fTotalRequests - fCacheMisses; | 69 0.f); |
66 SkDebugf("Hash miss %%: %f\n", (cacheHits > 0) ? 100.f * fHashMisses / cache
Hits : 0.f); | 70 int cacheHits = fTotalRequests - fCacheMisses; |
67 SkDebugf("---------------------\n"); | 71 SkDebugf("Hash miss %%: %f\n", (cacheHits > 0) ? 100.f * fHashMisses / c
acheHits : 0.f); |
| 72 SkDebugf("---------------------\n"); |
| 73 } |
68 #endif | 74 #endif |
69 } | 75 } |
70 | 76 |
71 void GrGpuGL::ProgramCache::abandon() { | 77 void GrGpuGL::ProgramCache::abandon() { |
72 for (int i = 0; i < fCount; ++i) { | 78 for (int i = 0; i < fCount; ++i) { |
73 SkASSERT(NULL != fEntries[i]->fProgram.get()); | 79 SkASSERT(NULL != fEntries[i]->fProgram.get()); |
74 fEntries[i]->fProgram->abandon(); | 80 fEntries[i]->fProgram->abandon(); |
75 fEntries[i]->fProgram.reset(NULL); | 81 fEntries[i]->fProgram.reset(NULL); |
76 } | 82 } |
77 fCount = 0; | 83 fCount = 0; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 GrGLAttribTypeToLayout(attribType).fCount, | 372 GrGLAttribTypeToLayout(attribType).fCount, |
367 GrGLAttribTypeToLayout(attribType).fType, | 373 GrGLAttribTypeToLayout(attribType).fType, |
368 GrGLAttribTypeToLayout(attribType).fNormalized, | 374 GrGLAttribTypeToLayout(attribType).fNormalized, |
369 stride, | 375 stride, |
370 reinterpret_cast<GrGLvoid*>( | 376 reinterpret_cast<GrGLvoid*>( |
371 vertexOffsetInBytes + vertexAttrib->fOffset)); | 377 vertexOffsetInBytes + vertexAttrib->fOffset)); |
372 } | 378 } |
373 | 379 |
374 attribState->disableUnusedArrays(this, usedAttribArraysMask, false); | 380 attribState->disableUnusedArrays(this, usedAttribArraysMask, false); |
375 } | 381 } |
OLD | NEW |