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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 GrOptDrawState& optState, | 94 GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState, |
94 const GrGLProgramDesc& desc, | 95 const GrGLProgramDesc& desc, |
| 96 DrawType type, |
95 const GrGeometryStage* geometryPr
ocessor, | 97 const GrGeometryStage* geometryPr
ocessor, |
96 const GrFragmentStage* colorStage
s[], | 98 const GrFragmentStage* colorStage
s[], |
97 const GrFragmentStage* coverageSt
ages[]) { | 99 const GrFragmentStage* coverageSt
ages[]) { |
98 #ifdef PROGRAM_CACHE_STATS | 100 #ifdef PROGRAM_CACHE_STATS |
99 ++fTotalRequests; | 101 ++fTotalRequests; |
100 #endif | 102 #endif |
101 | 103 |
102 Entry* entry = NULL; | 104 Entry* entry = NULL; |
103 | 105 |
104 uint32_t hashIdx = desc.getChecksum(); | 106 uint32_t hashIdx = desc.getChecksum(); |
(...skipping 17 matching lines...) Expand all Loading... |
122 ++fHashMisses; | 124 ++fHashMisses; |
123 #endif | 125 #endif |
124 } | 126 } |
125 } | 127 } |
126 | 128 |
127 if (NULL == entry) { | 129 if (NULL == entry) { |
128 // We have a cache miss | 130 // We have a cache miss |
129 #ifdef PROGRAM_CACHE_STATS | 131 #ifdef PROGRAM_CACHE_STATS |
130 ++fCacheMisses; | 132 ++fCacheMisses; |
131 #endif | 133 #endif |
132 GrGLProgram* program = GrGLProgram::Create(fGpu, optState, desc, geometr
yProcessor, | 134 GrGLProgram* program = GrGLProgramBuilder::CreateProgram(optState, desc,
type, |
133 colorStages, coverageStages); | 135 geometryProcess
or, colorStages, |
| 136 coverageStages,
fGpu); |
134 if (NULL == program) { | 137 if (NULL == program) { |
135 return NULL; | 138 return NULL; |
136 } | 139 } |
137 int purgeIdx = 0; | 140 int purgeIdx = 0; |
138 if (fCount < kMaxEntries) { | 141 if (fCount < kMaxEntries) { |
139 entry = SkNEW(Entry); | 142 entry = SkNEW(Entry); |
140 purgeIdx = fCount++; | 143 purgeIdx = fCount++; |
141 fEntries[purgeIdx] = entry; | 144 fEntries[purgeIdx] = entry; |
142 } else { | 145 } else { |
143 SkASSERT(fCount == kMaxEntries); | 146 SkASSERT(fCount == kMaxEntries); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 &geometryProcessor, | 250 &geometryProcessor, |
248 &colorStages, | 251 &colorStages, |
249 &coverageStages, | 252 &coverageStages, |
250 &desc)) { | 253 &desc)) { |
251 SkDEBUGFAIL("Failed to generate GL program descriptor"); | 254 SkDEBUGFAIL("Failed to generate GL program descriptor"); |
252 return false; | 255 return false; |
253 } | 256 } |
254 | 257 |
255 fCurrentProgram.reset(fProgramCache->getProgram(*optState.get(), | 258 fCurrentProgram.reset(fProgramCache->getProgram(*optState.get(), |
256 desc, | 259 desc, |
| 260 type, |
257 geometryProcessor, | 261 geometryProcessor, |
258 colorStages.begin(), | 262 colorStages.begin(), |
259 coverageStages.begin()))
; | 263 coverageStages.begin()))
; |
260 if (NULL == fCurrentProgram.get()) { | 264 if (NULL == fCurrentProgram.get()) { |
261 SkDEBUGFAIL("Failed to create program!"); | 265 SkDEBUGFAIL("Failed to create program!"); |
262 return false; | 266 return false; |
263 } | 267 } |
264 | 268 |
265 fCurrentProgram.get()->ref(); | 269 fCurrentProgram.get()->ref(); |
266 | 270 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 GrGLAttribTypeToLayout(attribType).fCount, | 380 GrGLAttribTypeToLayout(attribType).fCount, |
377 GrGLAttribTypeToLayout(attribType).fType, | 381 GrGLAttribTypeToLayout(attribType).fType, |
378 GrGLAttribTypeToLayout(attribType).fNormalized, | 382 GrGLAttribTypeToLayout(attribType).fNormalized, |
379 stride, | 383 stride, |
380 reinterpret_cast<GrGLvoid*>( | 384 reinterpret_cast<GrGLvoid*>( |
381 vertexOffsetInBytes + vertexAttrib->fOffset)); | 385 vertexOffsetInBytes + vertexAttrib->fOffset)); |
382 } | 386 } |
383 attribState->disableUnusedArrays(this, usedAttribArraysMask); | 387 attribState->disableUnusedArrays(this, usedAttribArraysMask); |
384 } | 388 } |
385 } | 389 } |
OLD | NEW |