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

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

Issue 1541903002: added support for PLS path rendering (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix for ASAN failure Created 4 years, 10 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/GrGLSLProgramBuilder.h ('k') | src/gpu/glsl/GrGLSLShaderVar.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 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 return false; 46 return false;
47 } 47 }
48 } 48 }
49 49
50 this->emitAndInstallPrimProc(primProc, inputColor, inputCoverage); 50 this->emitAndInstallPrimProc(primProc, inputColor, inputCoverage);
51 51
52 int numProcs = this->pipeline().numFragmentProcessors(); 52 int numProcs = this->pipeline().numFragmentProcessors();
53 this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentProcessors (), inputColor); 53 this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentProcessors (), inputColor);
54 this->emitAndInstallFragProcs(this->pipeline().numColorFragmentProcessors(), numProcs, 54 this->emitAndInstallFragProcs(this->pipeline().numColorFragmentProcessors(), numProcs,
55 inputCoverage); 55 inputCoverage);
56 this->emitAndInstallXferProc(this->pipeline().getXferProcessor(), *inputColo r, *inputCoverage, 56 if (primProc.getPixelLocalStorageState() !=
57 this->pipeline().ignoresCoverage()); 57 GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) {
58 this->emitFSOutputSwizzle(this->pipeline().getXferProcessor().hasSecondaryOu tput()); 58 this->emitAndInstallXferProc(this->pipeline().getXferProcessor(), *input Color,
59 *inputCoverage, this->pipeline().ignoresCov erage(),
60 primProc.getPixelLocalStorageState());
61 this->emitFSOutputSwizzle(this->pipeline().getXferProcessor().hasSeconda ryOutput());
62 }
59 return true; 63 return true;
60 } 64 }
61 65
62 void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr oc, 66 void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr oc,
63 GrGLSLExpr4* outputColor, 67 GrGLSLExpr4* outputColor,
64 GrGLSLExpr4* outputCoverage) { 68 GrGLSLExpr4* outputCoverage) {
65 // Program builders have a bit of state we need to clear with each effect 69 // Program builders have a bit of state we need to clear with each effect
66 AutoStageAdvance adv(this); 70 AutoStageAdvance adv(this);
67 this->nameExpression(outputColor, "outputColor"); 71 this->nameExpression(outputColor, "outputColor");
68 this->nameExpression(outputCoverage, "outputCoverage"); 72 this->nameExpression(outputCoverage, "outputCoverage");
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // asks for dst color, then the emit code needs to follow suit 148 // asks for dst color, then the emit code needs to follow suit
145 verify(fp); 149 verify(fp);
146 fFragmentProcessors.push_back(fragProc); 150 fFragmentProcessors.push_back(fragProc);
147 151
148 fFS.codeAppend("}"); 152 fFS.codeAppend("}");
149 } 153 }
150 154
151 void GrGLSLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp, 155 void GrGLSLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp,
152 const GrGLSLExpr4& colorIn, 156 const GrGLSLExpr4& colorIn,
153 const GrGLSLExpr4& coverageIn, 157 const GrGLSLExpr4& coverageIn,
154 bool ignoresCoverage) { 158 bool ignoresCoverage,
159 GrPixelLocalStorageState plsSt ate) {
155 // Program builders have a bit of state we need to clear with each effect 160 // Program builders have a bit of state we need to clear with each effect
156 AutoStageAdvance adv(this); 161 AutoStageAdvance adv(this);
157 162
158 SkASSERT(!fXferProcessor); 163 SkASSERT(!fXferProcessor);
159 fXferProcessor = xp.createGLSLInstance(); 164 fXferProcessor = xp.createGLSLInstance();
160 165
161 // Enable dual source secondary output if we have one 166 // Enable dual source secondary output if we have one
162 if (xp.hasSecondaryOutput()) { 167 if (xp.hasSecondaryOutput()) {
163 fFS.enableSecondaryOutput(); 168 fFS.enableSecondaryOutput();
164 } 169 }
165 170
166 if (this->glslCaps()->mustDeclareFragmentShaderOutput()) { 171 if (this->glslCaps()->mustDeclareFragmentShaderOutput()) {
167 fFS.enableCustomOutput(); 172 fFS.enableCustomOutput();
168 } 173 }
169 174
170 SkString openBrace; 175 SkString openBrace;
171 openBrace.printf("{ // Xfer Processor: %s\n", xp.name()); 176 openBrace.printf("{ // Xfer Processor: %s\n", xp.name());
172 fFS.codeAppend(openBrace.c_str()); 177 fFS.codeAppend(openBrace.c_str());
173 178
174 SkSTArray<4, GrGLSLTextureSampler> samplers(xp.numTextures()); 179 SkSTArray<4, GrGLSLTextureSampler> samplers(xp.numTextures());
175 this->emitSamplers(xp, &samplers); 180 this->emitSamplers(xp, &samplers);
176 181
182 bool usePLSDstRead = (plsState == GrPixelLocalStorageState::kFinish_GrPixelL ocalStorageState);
177 GrGLSLXferProcessor::EmitArgs args(&fFS, 183 GrGLSLXferProcessor::EmitArgs args(&fFS,
178 this->uniformHandler(), 184 this->uniformHandler(),
179 this->glslCaps(), 185 this->glslCaps(),
180 xp, colorIn.c_str(), 186 xp, colorIn.c_str(),
181 ignoresCoverage ? nullptr : coverageIn.c_ str(), 187 ignoresCoverage ? nullptr : coverageIn.c_ str(),
182 fFS.getPrimaryColorOutputName(), 188 fFS.getPrimaryColorOutputName(),
183 fFS.getSecondaryColorOutputName(), 189 fFS.getSecondaryColorOutputName(),
184 samplers); 190 samplers,
191 usePLSDstRead);
185 fXferProcessor->emitCode(args); 192 fXferProcessor->emitCode(args);
186 193
187 // We have to check that effects and the code they emit are consistent, ie i f an effect 194 // We have to check that effects and the code they emit are consistent, ie i f an effect
188 // asks for dst color, then the emit code needs to follow suit 195 // asks for dst color, then the emit code needs to follow suit
189 verify(xp); 196 verify(xp);
190 fFS.codeAppend("}"); 197 fFS.codeAppend("}");
191 } 198 }
192 199
193 void GrGLSLProgramBuilder::emitFSOutputSwizzle(bool hasSecondaryOutput) { 200 void GrGLSLProgramBuilder::emitFSOutputSwizzle(bool hasSecondaryOutput) {
194 // Swizzle the fragment shader outputs if necessary. 201 // Swizzle the fragment shader outputs if necessary.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 kFloat_GrSLType, kDefault_Gr SLPrecision, 279 kFloat_GrSLType, kDefault_Gr SLPrecision,
273 name, false, 0, outName); 280 name, false, 0, outName);
274 } 281 }
275 282
276 void GrGLSLProgramBuilder::cleanupFragmentProcessors() { 283 void GrGLSLProgramBuilder::cleanupFragmentProcessors() {
277 for (int i = 0; i < fFragmentProcessors.count(); ++i) { 284 for (int i = 0; i < fFragmentProcessors.count(); ++i) {
278 delete fFragmentProcessors[i]; 285 delete fFragmentProcessors[i];
279 } 286 }
280 } 287 }
281 288
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLProgramBuilder.h ('k') | src/gpu/glsl/GrGLSLShaderVar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698