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

Side by Side Diff: src/gpu/gl/builders/GrGLProgramBuilder.cpp

Issue 1266633003: Added registerChild; transforms, textures, glKey automatically handled. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: refactored to onGetGLProcessorKey; removed emitSamplers specialized template; fixed nits Created 5 years, 4 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/GrGLProgramDesc.cpp ('k') | tests/GLProgramsTest.cpp » ('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 2014 Google Inc. 2 * Copyright 2014 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 "GrGLProgramBuilder.h" 8 #include "GrGLProgramBuilder.h"
9 9
10 #include "gl/GrGLGeometryProcessor.h" 10 #include "gl/GrGLGeometryProcessor.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 fUniforms[i].fVariable.appendDecl(this->ctxInfo(), out); 172 fUniforms[i].fVariable.appendDecl(this->ctxInfo(), out);
173 out->append(";\n"); 173 out->append(";\n");
174 } 174 }
175 } 175 }
176 } 176 }
177 177
178 const GrGLContextInfo& GrGLProgramBuilder::ctxInfo() const { 178 const GrGLContextInfo& GrGLProgramBuilder::ctxInfo() const {
179 return fGpu->ctxInfo(); 179 return fGpu->ctxInfo();
180 } 180 }
181 181
182 static void append_gr_fp_coord_transforms(const GrFragmentProcessor* processor,
183 SkTArray<const GrCoordTransform*, true >* procCoords) {
184 // add the coord transforms of this processor
185 for (int i = 0; i < processor->numTransforms(); ++i) {
186 procCoords->push_back(&processor->coordTransform(i));
187 }
188 // recursively add the coord transforms of this processor's child processors
189 for (int i = 0; i < processor->numChildProcessors(); ++i) {
190 append_gr_fp_coord_transforms(processor->childProcessor(i), procCoords);
191 }
192 }
193
182 bool GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr 4* inputCoverage) { 194 bool GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr 4* inputCoverage) {
183 // First we loop over all of the installed processors and collect coord tran sforms. These will 195 // First we loop over all of the installed processors and collect coord tran sforms. These will
184 // be sent to the GrGLPrimitiveProcessor in its emitCode function 196 // be sent to the GrGLPrimitiveProcessor in its emitCode function
185 const GrPrimitiveProcessor& primProc = this->primitiveProcessor(); 197 const GrPrimitiveProcessor& primProc = this->primitiveProcessor();
186 int totalTextures = primProc.numTextures(); 198 int totalTextures = primProc.numTextures();
187 const int maxTextureUnits = fGpu->glCaps().maxFragmentTextureUnits(); 199 const int maxTextureUnits = fGpu->glCaps().maxFragmentTextureUnits();
188 SkSTArray<8, GrGLProcessor::TransformedCoordsArray> outCoords; 200 SkSTArray<8, GrGLProcessor::TransformedCoordsArray> outCoords;
189 for (int i = 0; i < this->pipeline().numFragmentStages(); i++) { 201 for (int i = 0; i < this->pipeline().numFragmentStages(); i++) {
190 const GrFragmentProcessor* processor = this->pipeline().getFragmentStage (i).processor(); 202 const GrFragmentProcessor* processor = this->pipeline().getFragmentStage (i).processor();
191 SkSTArray<2, const GrCoordTransform*, true>& procCoords = fCoordTransfor ms.push_back(); 203 SkSTArray<2, const GrCoordTransform*, true>& procCoords = fCoordTransfor ms.push_back();
192 for (int t = 0; t < processor->numTransforms(); t++) {
193 procCoords.push_back(&processor->coordTransform(t));
194 }
195 204
196 totalTextures += processor->numTextures(); 205 append_gr_fp_coord_transforms(processor, &procCoords);
206
207 totalTextures += processor->numTexturesIncludeChildProcs();
197 if (totalTextures >= maxTextureUnits) { 208 if (totalTextures >= maxTextureUnits) {
198 GrCapsDebugf(fGpu->caps(), "Program would use too many texture units \n"); 209 GrCapsDebugf(fGpu->caps(), "Program would use too many texture units \n");
199 return false; 210 return false;
200 } 211 }
201 } 212 }
202 213
203 this->emitAndInstallProc(primProc, inputColor, inputCoverage); 214 this->emitAndInstallProc(primProc, inputColor, inputCoverage);
204 215
205 fFragmentProcessors.reset(SkNEW(GrGLInstalledFragProcs)); 216 fFragmentProcessors.reset(SkNEW(GrGLInstalledFragProcs));
206 int numProcs = this->pipeline().numFragmentStages(); 217 int numProcs = this->pipeline().numFragmentStages();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 288
278 void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& fs, 289 void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& fs,
279 int index, 290 int index,
280 const char* outColor, 291 const char* outColor,
281 const char* inColor) { 292 const char* inColor) {
282 GrGLInstalledFragProc* ifp = SkNEW(GrGLInstalledFragProc); 293 GrGLInstalledFragProc* ifp = SkNEW(GrGLInstalledFragProc);
283 294
284 const GrFragmentProcessor& fp = *fs.processor(); 295 const GrFragmentProcessor& fp = *fs.processor();
285 ifp->fGLProc.reset(fp.createGLInstance()); 296 ifp->fGLProc.reset(fp.createGLInstance());
286 297
287 SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTextures()); 298 SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTexturesIncludeCh ildProcs());
288 this->emitSamplers(fp, &samplers, ifp); 299 this->emitSamplers(fp, &samplers, ifp);
289 300
290 GrGLFragmentProcessor::EmitArgs args(this, fp, outColor, inColor, fOutCoords [index], samplers); 301 GrGLFragmentProcessor::EmitArgs args(this, fp, outColor, inColor, fOutCoords [index], samplers);
291 ifp->fGLProc->emitCode(args); 302 ifp->fGLProc->emitCode(args);
292 303
293 // We have to check that effects and the code they emit are consistent, ie i f an effect 304 // We have to check that effects and the code they emit are consistent, ie i f an effect
294 // asks for dst color, then the emit code needs to follow suit 305 // asks for dst color, then the emit code needs to follow suit
295 verify(fp); 306 verify(fp);
296 fFragmentProcessors->fProcs.push_back(ifp); 307 fFragmentProcessors->fProcs.push_back(ifp);
297 } 308 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 } 508 }
498 509
499 //////////////////////////////////////////////////////////////////////////////// /////////////////// 510 //////////////////////////////////////////////////////////////////////////////// ///////////////////
500 511
501 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { 512 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() {
502 int numProcs = fProcs.count(); 513 int numProcs = fProcs.count();
503 for (int e = 0; e < numProcs; ++e) { 514 for (int e = 0; e < numProcs; ++e) {
504 SkDELETE(fProcs[e]); 515 SkDELETE(fProcs[e]);
505 } 516 }
506 } 517 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgramDesc.cpp ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698