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