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

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

Issue 647183002: Revert of Opt state takes a GP instead of a GeometryStage (Closed) Base URL: https://skia.googlesource.com/skia.git@builder_cleanup
Patch Set: Created 6 years, 2 months 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.h ('k') | src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.h » ('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"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 fCount = 0; 86 fCount = 0;
87 } 87 }
88 88
89 int GrGpuGL::ProgramCache::search(const GrGLProgramDesc& desc) const { 89 int GrGpuGL::ProgramCache::search(const GrGLProgramDesc& 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* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState,
95 const GrGLProgramDesc& desc, 95 const GrGLProgramDesc& desc,
96 DrawType type) { 96 DrawType type,
97 const GrGeometryStage* geometryPr ocessor,
98 const GrFragmentStage* colorStage s[],
99 const GrFragmentStage* coverageSt ages[]) {
97 #ifdef PROGRAM_CACHE_STATS 100 #ifdef PROGRAM_CACHE_STATS
98 ++fTotalRequests; 101 ++fTotalRequests;
99 #endif 102 #endif
100 103
101 Entry* entry = NULL; 104 Entry* entry = NULL;
102 105
103 uint32_t hashIdx = desc.getChecksum(); 106 uint32_t hashIdx = desc.getChecksum();
104 hashIdx ^= hashIdx >> 16; 107 hashIdx ^= hashIdx >> 16;
105 if (kHashBits <= 8) { 108 if (kHashBits <= 8) {
106 hashIdx ^= hashIdx >> 8; 109 hashIdx ^= hashIdx >> 8;
(...skipping 14 matching lines...) Expand all
121 ++fHashMisses; 124 ++fHashMisses;
122 #endif 125 #endif
123 } 126 }
124 } 127 }
125 128
126 if (NULL == entry) { 129 if (NULL == entry) {
127 // We have a cache miss 130 // We have a cache miss
128 #ifdef PROGRAM_CACHE_STATS 131 #ifdef PROGRAM_CACHE_STATS
129 ++fCacheMisses; 132 ++fCacheMisses;
130 #endif 133 #endif
131 GrGLProgram* program = GrGLProgramBuilder::CreateProgram(optState, desc, type, fGpu); 134 GrGLProgram* program = GrGLProgramBuilder::CreateProgram(optState, desc, type,
135 geometryProcess or, colorStages,
136 coverageStages, fGpu);
132 if (NULL == program) { 137 if (NULL == program) {
133 return NULL; 138 return NULL;
134 } 139 }
135 int purgeIdx = 0; 140 int purgeIdx = 0;
136 if (fCount < kMaxEntries) { 141 if (fCount < kMaxEntries) {
137 entry = SkNEW(Entry); 142 entry = SkNEW(Entry);
138 purgeIdx = fCount++; 143 purgeIdx = fCount++;
139 fEntries[purgeIdx] = entry; 144 fEntries[purgeIdx] = entry;
140 } else { 145 } else {
141 SkASSERT(fCount == kMaxEntries); 146 SkASSERT(fCount == kMaxEntries);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 230
226 GrBlendCoeff srcCoeff = optState->getSrcBlendCoeff(); 231 GrBlendCoeff srcCoeff = optState->getSrcBlendCoeff();
227 GrBlendCoeff dstCoeff = optState->getDstBlendCoeff(); 232 GrBlendCoeff dstCoeff = optState->getDstBlendCoeff();
228 233
229 // In these blend coeff's we end up drawing nothing so we can skip draw all together 234 // In these blend coeff's we end up drawing nothing so we can skip draw all together
230 if (kZero_GrBlendCoeff == srcCoeff && kOne_GrBlendCoeff == dstCoeff && 235 if (kZero_GrBlendCoeff == srcCoeff && kOne_GrBlendCoeff == dstCoeff &&
231 !optState->getStencil().doesWrite()) { 236 !optState->getStencil().doesWrite()) {
232 return false; 237 return false;
233 } 238 }
234 239
240 const GrGeometryStage* geometryProcessor = NULL;
241 SkSTArray<8, const GrFragmentStage*, true> colorStages;
242 SkSTArray<8, const GrFragmentStage*, true> coverageStages;
235 GrGLProgramDesc desc; 243 GrGLProgramDesc desc;
236 if (!GrGLProgramDesc::Build(*optState.get(), type, this, dstCopy, &desc) ) { 244 if (!GrGLProgramDesc::Build(*optState.get(),
245 type,
246 srcCoeff,
247 dstCoeff,
248 this,
249 dstCopy,
250 &geometryProcessor,
251 &colorStages,
252 &coverageStages,
253 &desc)) {
237 SkDEBUGFAIL("Failed to generate GL program descriptor"); 254 SkDEBUGFAIL("Failed to generate GL program descriptor");
238 return false; 255 return false;
239 } 256 }
240 257
241 fCurrentProgram.reset(fProgramCache->getProgram(*optState.get(), desc, t ype)); 258 fCurrentProgram.reset(fProgramCache->getProgram(*optState.get(),
259 desc,
260 type,
261 geometryProcessor,
262 colorStages.begin(),
263 coverageStages.begin())) ;
242 if (NULL == fCurrentProgram.get()) { 264 if (NULL == fCurrentProgram.get()) {
243 SkDEBUGFAIL("Failed to create program!"); 265 SkDEBUGFAIL("Failed to create program!");
244 return false; 266 return false;
245 } 267 }
246 268
247 fCurrentProgram.get()->ref(); 269 fCurrentProgram.get()->ref();
248 270
249 GrGLuint programID = fCurrentProgram->programID(); 271 GrGLuint programID = fCurrentProgram->programID();
250 if (fHWProgramID != programID) { 272 if (fHWProgramID != programID) {
251 GL_CALL(UseProgram(programID)); 273 GL_CALL(UseProgram(programID));
252 fHWProgramID = programID; 274 fHWProgramID = programID;
253 } 275 }
254 276
255 this->flushBlend(*optState.get(), kDrawLines_DrawType == type, srcCoeff, dstCoeff); 277 this->flushBlend(*optState.get(), kDrawLines_DrawType == type, srcCoeff, dstCoeff);
256 278
257 fCurrentProgram->setData(*optState.get(), type, dstCopy, &fSharedGLProgr amState); 279 fCurrentProgram->setData(*optState.get(),
280 type,
281 geometryProcessor,
282 colorStages.begin(),
283 coverageStages.begin(),
284 dstCopy,
285 &fSharedGLProgramState);
258 } 286 }
259 287
260 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState->getRenderT arget()); 288 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState->getRenderT arget());
261 this->flushStencil(type); 289 this->flushStencil(type);
262 this->flushScissor(glRT->getViewport(), glRT->origin()); 290 this->flushScissor(glRT->getViewport(), glRT->origin());
263 this->flushAAState(*optState.get(), type); 291 this->flushAAState(*optState.get(), type);
264 292
265 SkIRect* devRect = NULL; 293 SkIRect* devRect = NULL;
266 SkIRect devClipBounds; 294 SkIRect devClipBounds;
267 if (optState->isClipState()) { 295 if (optState->isClipState()) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 GrGLAttribTypeToLayout(attribType).fCount, 380 GrGLAttribTypeToLayout(attribType).fCount,
353 GrGLAttribTypeToLayout(attribType).fType, 381 GrGLAttribTypeToLayout(attribType).fType,
354 GrGLAttribTypeToLayout(attribType).fNormalized, 382 GrGLAttribTypeToLayout(attribType).fNormalized,
355 stride, 383 stride,
356 reinterpret_cast<GrGLvoid*>( 384 reinterpret_cast<GrGLvoid*>(
357 vertexOffsetInBytes + vertexAttrib->fOffset)); 385 vertexOffsetInBytes + vertexAttrib->fOffset));
358 } 386 }
359 attribState->disableUnusedArrays(this, usedAttribArraysMask); 387 attribState->disableUnusedArrays(this, usedAttribArraysMask);
360 } 388 }
361 } 389 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698