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

Side by Side Diff: src/gpu/glsl/GrGLSLProgramBuilder.cpp

Issue 2201613002: Revert of GrFP can express distance vector field req., program builder declares variable for it (Closed) Base URL: https://skia.googlesource.com/skia@dvonbeck-bevel-api-change
Patch Set: Created 4 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/glsl/GrGLSLPrimitiveProcessor.h ('k') | no next file » | 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 2015 Google Inc. 2 * Copyright 2015 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 "glsl/GrGLSLProgramBuilder.h" 8 #include "glsl/GrGLSLProgramBuilder.h"
9 9
10 #include "GrPipeline.h" 10 #include "GrPipeline.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 80 }
81 81
82 void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr oc, 82 void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr oc,
83 GrGLSLExpr4* outputColor, 83 GrGLSLExpr4* outputColor,
84 GrGLSLExpr4* outputCoverage) { 84 GrGLSLExpr4* outputCoverage) {
85 // Program builders have a bit of state we need to clear with each effect 85 // Program builders have a bit of state we need to clear with each effect
86 AutoStageAdvance adv(this); 86 AutoStageAdvance adv(this);
87 this->nameExpression(outputColor, "outputColor"); 87 this->nameExpression(outputColor, "outputColor");
88 this->nameExpression(outputCoverage, "outputCoverage"); 88 this->nameExpression(outputCoverage, "outputCoverage");
89 89
90 const char* distanceVectorName = nullptr;
91 if (this->fPipeline.usesDistanceVectorField() && proc.implementsDistanceVect or()) {
92 distanceVectorName = fFS.distanceVectorName();
93 fFS.codeAppend( "// Un-normalized vector to the closed geometric edge (i n source space)\n");
94 fFS.codeAppendf("vec2 %s;", distanceVectorName);
95 }
96
97 // Enclose custom code in a block to avoid namespace conflicts 90 // Enclose custom code in a block to avoid namespace conflicts
98 SkString openBrace; 91 SkString openBrace;
99 openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name()); 92 openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name());
100 fFS.codeAppend(openBrace.c_str()); 93 fFS.codeAppend(openBrace.c_str());
101 fVS.codeAppendf("// Primitive Processor %s\n", proc.name()); 94 fVS.codeAppendf("// Primitive Processor %s\n", proc.name());
102 95
103 SkASSERT(!fGeometryProcessor); 96 SkASSERT(!fGeometryProcessor);
104 fGeometryProcessor = proc.createGLSLInstance(*this->glslCaps()); 97 fGeometryProcessor = proc.createGLSLInstance(*this->glslCaps());
105 98
106 SkSTArray<4, SamplerHandle> texSamplers(proc.numTextures()); 99 SkSTArray<4, SamplerHandle> texSamplers(proc.numTextures());
107 SkSTArray<2, SamplerHandle> bufferSamplers(proc.numBuffers()); 100 SkSTArray<2, SamplerHandle> bufferSamplers(proc.numBuffers());
108 this->emitSamplers(proc, &texSamplers, &bufferSamplers); 101 this->emitSamplers(proc, &texSamplers, &bufferSamplers);
109 102
110 GrGLSLGeometryProcessor::EmitArgs args(&fVS, 103 GrGLSLGeometryProcessor::EmitArgs args(&fVS,
111 &fFS, 104 &fFS,
112 this->varyingHandler(), 105 this->varyingHandler(),
113 this->uniformHandler(), 106 this->uniformHandler(),
114 this->glslCaps(), 107 this->glslCaps(),
115 proc, 108 proc,
116 outputColor->c_str(), 109 outputColor->c_str(),
117 outputCoverage->c_str(), 110 outputCoverage->c_str(),
118 distanceVectorName,
119 texSamplers.begin(), 111 texSamplers.begin(),
120 bufferSamplers.begin(), 112 bufferSamplers.begin(),
121 fCoordTransforms, 113 fCoordTransforms,
122 &fOutCoords); 114 &fOutCoords);
123 fGeometryProcessor->emitCode(args); 115 fGeometryProcessor->emitCode(args);
124 116
125 // We have to check that effects and the code they emit are consistent, ie i f an effect 117 // We have to check that effects and the code they emit are consistent, ie i f an effect
126 // asks for dst color, then the emit code needs to follow suit 118 // asks for dst color, then the emit code needs to follow suit
127 SkDEBUGCODE(verify(proc);) 119 SkDEBUGCODE(verify(proc);)
128 120
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 this->emitSamplers(fp, &texSamplers, &bufferSamplers); 154 this->emitSamplers(fp, &texSamplers, &bufferSamplers);
163 155
164 GrGLSLFragmentProcessor::EmitArgs args(&fFS, 156 GrGLSLFragmentProcessor::EmitArgs args(&fFS,
165 this->uniformHandler(), 157 this->uniformHandler(),
166 this->glslCaps(), 158 this->glslCaps(),
167 fp, 159 fp,
168 output->c_str(), 160 output->c_str(),
169 input.isOnes() ? nullptr : input.c_st r(), 161 input.isOnes() ? nullptr : input.c_st r(),
170 fOutCoords[index], 162 fOutCoords[index],
171 texSamplers.begin(), 163 texSamplers.begin(),
172 bufferSamplers.begin(), 164 bufferSamplers.begin());
173 this->primitiveProcessor().implements DistanceVector());
174
175 fragProc->emitCode(args); 165 fragProc->emitCode(args);
176 166
177 // We have to check that effects and the code they emit are consistent, ie i f an effect 167 // We have to check that effects and the code they emit are consistent, ie i f an effect
178 // asks for dst color, then the emit code needs to follow suit 168 // asks for dst color, then the emit code needs to follow suit
179 SkDEBUGCODE(verify(fp);) 169 SkDEBUGCODE(verify(fp);)
180 fFragmentProcessors.push_back(fragProc); 170 fFragmentProcessors.push_back(fragProc);
181 171
182 fFS.codeAppend("}"); 172 fFS.codeAppend("}");
183 } 173 }
184 174
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 delete fFragmentProcessors[i]; 401 delete fFragmentProcessors[i];
412 } 402 }
413 } 403 }
414 404
415 void GrGLSLProgramBuilder::finalizeShaders() { 405 void GrGLSLProgramBuilder::finalizeShaders() {
416 this->varyingHandler()->finalize(); 406 this->varyingHandler()->finalize();
417 fVS.finalize(kVertex_GrShaderFlag); 407 fVS.finalize(kVertex_GrShaderFlag);
418 fFS.finalize(kFragment_GrShaderFlag); 408 fFS.finalize(kFragment_GrShaderFlag);
419 409
420 } 410 }
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLPrimitiveProcessor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698