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 "builders/GrGLProgramBuilder.h" |
10 #include "GrProcessor.h" | 11 #include "GrProcessor.h" |
11 #include "GrGLProcessor.h" | 12 #include "GrGLProcessor.h" |
12 #include "GrGLPathRendering.h" | 13 #include "GrGLPathRendering.h" |
13 #include "GrOptDrawState.h" | 14 #include "GrOptDrawState.h" |
14 #include "SkRTConf.h" | 15 #include "SkRTConf.h" |
15 #include "SkTSearch.h" | 16 #include "SkTSearch.h" |
16 | 17 |
17 #ifdef PROGRAM_CACHE_STATS | 18 #ifdef PROGRAM_CACHE_STATS |
18 SK_CONF_DECLARE(bool, c_DisplayCache, "gpu.displayCache", false, | 19 SK_CONF_DECLARE(bool, c_DisplayCache, "gpu.displayCache", false, |
19 "Display program cache usage."); | 20 "Display program cache usage."); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 85 } |
85 fCount = 0; | 86 fCount = 0; |
86 } | 87 } |
87 | 88 |
88 int GrGpuGL::ProgramCache::search(const GrGLProgramDesc& desc) const { | 89 int GrGpuGL::ProgramCache::search(const GrGLProgramDesc& desc) const { |
89 ProgDescLess less; | 90 ProgDescLess less; |
90 return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less); | 91 return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less); |
91 } | 92 } |
92 | 93 |
93 GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrGLProgramDesc& desc, | 94 GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrGLProgramDesc& desc, |
| 95 DrawType type, |
94 const GrGeometryStage* geometryPr
ocessor, | 96 const GrGeometryStage* geometryPr
ocessor, |
95 const GrFragmentStage* colorStage
s[], | 97 const GrFragmentStage* colorStage
s[], |
96 const GrFragmentStage* coverageSt
ages[]) { | 98 const GrFragmentStage* coverageSt
ages[]) { |
97 #ifdef PROGRAM_CACHE_STATS | 99 #ifdef PROGRAM_CACHE_STATS |
98 ++fTotalRequests; | 100 ++fTotalRequests; |
99 #endif | 101 #endif |
100 | 102 |
101 Entry* entry = NULL; | 103 Entry* entry = NULL; |
102 | 104 |
103 uint32_t hashIdx = desc.getChecksum(); | 105 uint32_t hashIdx = desc.getChecksum(); |
(...skipping 17 matching lines...) Expand all Loading... |
121 ++fHashMisses; | 123 ++fHashMisses; |
122 #endif | 124 #endif |
123 } | 125 } |
124 } | 126 } |
125 | 127 |
126 if (NULL == entry) { | 128 if (NULL == entry) { |
127 // We have a cache miss | 129 // We have a cache miss |
128 #ifdef PROGRAM_CACHE_STATS | 130 #ifdef PROGRAM_CACHE_STATS |
129 ++fCacheMisses; | 131 ++fCacheMisses; |
130 #endif | 132 #endif |
131 GrGLProgram* program = GrGLProgram::Create(fGpu, desc, geometryProcessor
, | 133 GrGLProgram* program = GrGLProgramBuilder::CreateProgram(desc, type, geo
metryProcessor, |
132 colorStages, coverageStages); | 134 colorStages, co
verageStages, fGpu); |
133 if (NULL == program) { | 135 if (NULL == program) { |
134 return NULL; | 136 return NULL; |
135 } | 137 } |
136 int purgeIdx = 0; | 138 int purgeIdx = 0; |
137 if (fCount < kMaxEntries) { | 139 if (fCount < kMaxEntries) { |
138 entry = SkNEW(Entry); | 140 entry = SkNEW(Entry); |
139 purgeIdx = fCount++; | 141 purgeIdx = fCount++; |
140 fEntries[purgeIdx] = entry; | 142 fEntries[purgeIdx] = entry; |
141 } else { | 143 } else { |
142 SkASSERT(fCount == kMaxEntries); | 144 SkASSERT(fCount == kMaxEntries); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 dstCopy, | 241 dstCopy, |
240 &geometryProcessor, | 242 &geometryProcessor, |
241 &colorStages, | 243 &colorStages, |
242 &coverageStages, | 244 &coverageStages, |
243 &desc)) { | 245 &desc)) { |
244 SkDEBUGFAIL("Failed to generate GL program descriptor"); | 246 SkDEBUGFAIL("Failed to generate GL program descriptor"); |
245 return false; | 247 return false; |
246 } | 248 } |
247 | 249 |
248 fCurrentProgram.reset(fProgramCache->getProgram(desc, | 250 fCurrentProgram.reset(fProgramCache->getProgram(desc, |
| 251 type, |
249 geometryProcessor, | 252 geometryProcessor, |
250 colorStages.begin(), | 253 colorStages.begin(), |
251 coverageStages.begin()))
; | 254 coverageStages.begin()))
; |
252 if (NULL == fCurrentProgram.get()) { | 255 if (NULL == fCurrentProgram.get()) { |
253 SkDEBUGFAIL("Failed to create program!"); | 256 SkDEBUGFAIL("Failed to create program!"); |
254 return false; | 257 return false; |
255 } | 258 } |
256 | 259 |
257 fCurrentProgram.get()->ref(); | 260 fCurrentProgram.get()->ref(); |
258 | 261 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 GrGLAttribTypeToLayout(attribType).fCount, | 365 GrGLAttribTypeToLayout(attribType).fCount, |
363 GrGLAttribTypeToLayout(attribType).fType, | 366 GrGLAttribTypeToLayout(attribType).fType, |
364 GrGLAttribTypeToLayout(attribType).fNormalized, | 367 GrGLAttribTypeToLayout(attribType).fNormalized, |
365 stride, | 368 stride, |
366 reinterpret_cast<GrGLvoid*>( | 369 reinterpret_cast<GrGLvoid*>( |
367 vertexOffsetInBytes + vertexAttrib->fOffset)); | 370 vertexOffsetInBytes + vertexAttrib->fOffset)); |
368 } | 371 } |
369 attribState->disableUnusedArrays(this, usedAttribArraysMask); | 372 attribState->disableUnusedArrays(this, usedAttribArraysMask); |
370 } | 373 } |
371 } | 374 } |
OLD | NEW |