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

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

Issue 1457543003: Add ShaderBuilders to EmitArgs and remove gettings from ProgBuilder. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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/effects/GrYUVtoRGBEffect.cpp ('k') | src/gpu/glsl/GrGLSLFragmentProcessor.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 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 "GrAutoLocaleSetter.h" 10 #include "GrAutoLocaleSetter.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 const ch ar* name, 88 const ch ar* name,
89 GrGLSLVe rtToFrag* v, 89 GrGLSLVe rtToFrag* v,
90 GrSLPrec ision fsPrecision) { 90 GrSLPrec ision fsPrecision) {
91 // This call is not used for non-NVPR backends. 91 // This call is not used for non-NVPR backends.
92 SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport() && 92 SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport() &&
93 fArgs.fPrimitiveProcessor->isPathRendering() && 93 fArgs.fPrimitiveProcessor->isPathRendering() &&
94 !fArgs.fPrimitiveProcessor->willUseGeoShader() && 94 !fArgs.fPrimitiveProcessor->willUseGeoShader() &&
95 fArgs.fPrimitiveProcessor->numAttribs() == 0); 95 fArgs.fPrimitiveProcessor->numAttribs() == 0);
96 this->addVarying(name, v, fsPrecision); 96 this->addVarying(name, v, fsPrecision);
97 SeparableVaryingInfo& varyingInfo = fSeparableVaryingInfos.push_back(); 97 SeparableVaryingInfo& varyingInfo = fSeparableVaryingInfos.push_back();
98 varyingInfo.fVariable = this->getFragmentShaderBuilder()->fInputs.back(); 98 varyingInfo.fVariable = fFS.fInputs.back();
99 varyingInfo.fLocation = fSeparableVaryingInfos.count() - 1; 99 varyingInfo.fLocation = fSeparableVaryingInfos.count() - 1;
100 return SeparableVaryingHandle(varyingInfo.fLocation); 100 return SeparableVaryingHandle(varyingInfo.fLocation);
101 } 101 }
102 102
103 GrGLSLProgramDataManager::UniformHandle GrGLProgramBuilder::internalAddUniformAr ray( 103 GrGLSLProgramDataManager::UniformHandle GrGLProgramBuilder::internalAddUniformAr ray(
104 uint32_t visibil ity, 104 uint32_t visibil ity,
105 GrSLType type, 105 GrSLType type,
106 GrSLPrecision pr ecision, 106 GrSLPrecision pr ecision,
107 const char* name , 107 const char* name ,
108 bool mangleName, 108 bool mangleName,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 const char* outColor, 253 const char* outColor,
254 const char* inColor) { 254 const char* inColor) {
255 GrGLInstalledFragProc* ifp = new GrGLInstalledFragProc; 255 GrGLInstalledFragProc* ifp = new GrGLInstalledFragProc;
256 256
257 ifp->fGLProc.reset(fp.createGLSLInstance()); 257 ifp->fGLProc.reset(fp.createGLSLInstance());
258 258
259 SkSTArray<4, GrGLSLTextureSampler> samplers(fp.numTextures()); 259 SkSTArray<4, GrGLSLTextureSampler> samplers(fp.numTextures());
260 this->emitSamplers(fp, &samplers, ifp); 260 this->emitSamplers(fp, &samplers, ifp);
261 261
262 GrGLSLFragmentProcessor::EmitArgs args(this, 262 GrGLSLFragmentProcessor::EmitArgs args(this,
263 &fFS,
263 fp, 264 fp,
264 outColor, 265 outColor,
265 inColor, 266 inColor,
266 fOutCoords[index], 267 fOutCoords[index],
267 samplers); 268 samplers);
268 ifp->fGLProc->emitCode(args); 269 ifp->fGLProc->emitCode(args);
269 270
270 // We have to check that effects and the code they emit are consistent, ie i f an effect 271 // We have to check that effects and the code they emit are consistent, ie i f an effect
271 // asks for dst color, then the emit code needs to follow suit 272 // asks for dst color, then the emit code needs to follow suit
272 verify(fp); 273 verify(fp);
273 fFragmentProcessors->fProcs.push_back(ifp); 274 fFragmentProcessors->fProcs.push_back(ifp);
274 } 275 }
275 276
276 void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& gp, 277 void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& gp,
277 const char* outColor, 278 const char* outColor,
278 const char* outCoverage) { 279 const char* outCoverage) {
279 SkASSERT(!fGeometryProcessor); 280 SkASSERT(!fGeometryProcessor);
280 fGeometryProcessor = new GrGLInstalledGeoProc; 281 fGeometryProcessor = new GrGLInstalledGeoProc;
281 282
282 fGeometryProcessor->fGLProc.reset(gp.createGLSLInstance(*fGpu->glCaps().glsl Caps())); 283 fGeometryProcessor->fGLProc.reset(gp.createGLSLInstance(*fGpu->glCaps().glsl Caps()));
283 284
284 SkSTArray<4, GrGLSLTextureSampler> samplers(gp.numTextures()); 285 SkSTArray<4, GrGLSLTextureSampler> samplers(gp.numTextures());
285 this->emitSamplers(gp, &samplers, fGeometryProcessor); 286 this->emitSamplers(gp, &samplers, fGeometryProcessor);
286 287
287 GrGLSLGeometryProcessor::EmitArgs args(this, gp, outColor, outCoverage, samp lers, 288 GrGLSLGeometryProcessor::EmitArgs args(this, &fVS, &fFS, gp, outColor, outCo verage, samplers,
288 fCoordTransforms, &fOutCoords); 289 fCoordTransforms, &fOutCoords);
289 fGeometryProcessor->fGLProc->emitCode(args); 290 fGeometryProcessor->fGLProc->emitCode(args);
290 291
291 // We have to check that effects and the code they emit are consistent, ie i f an effect 292 // We have to check that effects and the code they emit are consistent, ie i f an effect
292 // asks for dst color, then the emit code needs to follow suit 293 // asks for dst color, then the emit code needs to follow suit
293 verify(gp); 294 verify(gp);
294 } 295 }
295 296
296 void GrGLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp, 297 void GrGLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp,
297 const GrGLSLExpr4& colorIn, 298 const GrGLSLExpr4& colorIn,
(...skipping 15 matching lines...) Expand all
313 fFS.enableCustomOutput(); 314 fFS.enableCustomOutput();
314 } 315 }
315 316
316 SkString openBrace; 317 SkString openBrace;
317 openBrace.printf("{ // Xfer Processor: %s\n", xp.name()); 318 openBrace.printf("{ // Xfer Processor: %s\n", xp.name());
318 fFS.codeAppend(openBrace.c_str()); 319 fFS.codeAppend(openBrace.c_str());
319 320
320 SkSTArray<4, GrGLSLTextureSampler> samplers(xp.numTextures()); 321 SkSTArray<4, GrGLSLTextureSampler> samplers(xp.numTextures());
321 this->emitSamplers(xp, &samplers, fXferProcessor); 322 this->emitSamplers(xp, &samplers, fXferProcessor);
322 323
323 GrGLSLXferProcessor::EmitArgs args(this, xp, colorIn.c_str(), coverageIn.c_s tr(), 324 GrGLSLXferProcessor::EmitArgs args(this, &fFS, xp, colorIn.c_str(), coverage In.c_str(),
324 fFS.getPrimaryColorOutputName(), 325 fFS.getPrimaryColorOutputName(),
325 fFS.getSecondaryColorOutputName(), samplers ); 326 fFS.getSecondaryColorOutputName(), sample rs);
326 fXferProcessor->fGLProc->emitCode(args); 327 fXferProcessor->fGLProc->emitCode(args);
327 328
328 // We have to check that effects and the code they emit are consistent, ie i f an effect 329 // We have to check that effects and the code they emit are consistent, ie i f an effect
329 // asks for dst color, then the emit code needs to follow suit 330 // asks for dst color, then the emit code needs to follow suit
330 verify(xp); 331 verify(xp);
331 fFS.codeAppend("}"); 332 fFS.codeAppend("}");
332 } 333 }
333 334
334 void GrGLProgramBuilder::verify(const GrPrimitiveProcessor& gp) { 335 void GrGLProgramBuilder::verify(const GrPrimitiveProcessor& gp) {
335 SkASSERT(fFS.hasReadFragmentPosition() == gp.willReadFragmentPosition()); 336 SkASSERT(fFS.hasReadFragmentPosition() == gp.willReadFragmentPosition());
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 537 }
537 538
538 //////////////////////////////////////////////////////////////////////////////// /////////////////// 539 //////////////////////////////////////////////////////////////////////////////// ///////////////////
539 540
540 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { 541 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() {
541 int numProcs = fProcs.count(); 542 int numProcs = fProcs.count();
542 for (int i = 0; i < numProcs; ++i) { 543 for (int i = 0; i < numProcs; ++i) {
543 delete fProcs[i]; 544 delete fProcs[i];
544 } 545 }
545 } 546 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrYUVtoRGBEffect.cpp ('k') | src/gpu/glsl/GrGLSLFragmentProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698