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

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

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