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

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

Issue 1682703003: Add some backend flexibility for shader declarations in ProgramBuilding. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix dtor 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/gl/GrGLVaryingHandler.h ('k') | src/gpu/glsl/GrGLSLProgramBuilder.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 "GrGLSLFragmentShaderBuilder.h" 8 #include "GrGLSLFragmentShaderBuilder.h"
9 #include "GrRenderTarget.h" 9 #include "GrRenderTarget.h"
10 #include "gl/GrGLGpu.h" 10 #include "gl/GrGLGpu.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 } 210 }
211 211
212 void GrGLSLFragmentShaderBuilder::enableCustomOutput() { 212 void GrGLSLFragmentShaderBuilder::enableCustomOutput() {
213 if (!fHasCustomColorOutput) { 213 if (!fHasCustomColorOutput) {
214 fHasCustomColorOutput = true; 214 fHasCustomColorOutput = true;
215 fCustomColorOutputIndex = fOutputs.count(); 215 fCustomColorOutputIndex = fOutputs.count();
216 fOutputs.push_back().set(kVec4f_GrSLType, 216 fOutputs.push_back().set(kVec4f_GrSLType,
217 GrGLSLShaderVar::kOut_TypeModifier, 217 GrGLSLShaderVar::kOut_TypeModifier,
218 DeclaredColorOutputName()); 218 DeclaredColorOutputName());
219 fProgramBuilder->finalizeFragmentOutputColor(fOutputs.back());
219 } 220 }
220 } 221 }
221 222
222 void GrGLSLFragmentShaderBuilder::enableSecondaryOutput() { 223 void GrGLSLFragmentShaderBuilder::enableSecondaryOutput() {
223 SkASSERT(!fHasSecondaryOutput); 224 SkASSERT(!fHasSecondaryOutput);
224 fHasSecondaryOutput = true; 225 fHasSecondaryOutput = true;
225 const GrGLSLCaps& caps = *fProgramBuilder->glslCaps(); 226 const GrGLSLCaps& caps = *fProgramBuilder->glslCaps();
226 if (const char* extension = caps.secondaryOutputExtensionString()) { 227 if (const char* extension = caps.secondaryOutputExtensionString()) {
227 this->addFeature(1 << kBlendFuncExtended_GLSLPrivateFeature, extension); 228 this->addFeature(1 << kBlendFuncExtended_GLSLPrivateFeature, extension);
228 } 229 }
229 230
230 // If the primary output is declared, we must declare also the secondary out put 231 // If the primary output is declared, we must declare also the secondary out put
231 // and vice versa, since it is not allowed to use a built-in gl_FragColor an d a custom 232 // and vice versa, since it is not allowed to use a built-in gl_FragColor an d a custom
232 // output. The condition also co-incides with the condition in whici GLES SL 2.0 233 // output. The condition also co-incides with the condition in whici GLES SL 2.0
233 // requires the built-in gl_SecondaryFragColorEXT, where as 3.0 requires a c ustom output. 234 // requires the built-in gl_SecondaryFragColorEXT, where as 3.0 requires a c ustom output.
234 if (caps.mustDeclareFragmentShaderOutput()) { 235 if (caps.mustDeclareFragmentShaderOutput()) {
235 fOutputs.push_back().set(kVec4f_GrSLType, GrGLSLShaderVar::kOut_TypeModi fier, 236 fOutputs.push_back().set(kVec4f_GrSLType, GrGLSLShaderVar::kOut_TypeModi fier,
236 DeclaredSecondaryColorOutputName()); 237 DeclaredSecondaryColorOutputName());
238 fProgramBuilder->finalizeFragmentSecondaryColor(fOutputs.back());
237 } 239 }
238 } 240 }
239 241
240 const char* GrGLSLFragmentShaderBuilder::getPrimaryColorOutputName() const { 242 const char* GrGLSLFragmentShaderBuilder::getPrimaryColorOutputName() const {
241 return fHasCustomColorOutput ? DeclaredColorOutputName() : "gl_FragColor"; 243 return fHasCustomColorOutput ? DeclaredColorOutputName() : "gl_FragColor";
242 } 244 }
243 245
244 void GrGLSLFragmentBuilder::declAppendf(const char* fmt, ...) { 246 void GrGLSLFragmentBuilder::declAppendf(const char* fmt, ...) {
245 va_list argp; 247 va_list argp;
246 va_start(argp, fmt); 248 va_start(argp, fmt);
(...skipping 23 matching lines...) Expand all
270 } 272 }
271 273
272 void GrGLSLFragmentBuilder::onAfterChildProcEmitCode() { 274 void GrGLSLFragmentBuilder::onAfterChildProcEmitCode() {
273 SkASSERT(fSubstageIndices.count() >= 2); 275 SkASSERT(fSubstageIndices.count() >= 2);
274 fSubstageIndices.pop_back(); 276 fSubstageIndices.pop_back();
275 fSubstageIndices.back()++; 277 fSubstageIndices.back()++;
276 int removeAt = fMangleString.findLastOf('_'); 278 int removeAt = fMangleString.findLastOf('_');
277 fMangleString.remove(removeAt, fMangleString.size() - removeAt); 279 fMangleString.remove(removeAt, fMangleString.size() - removeAt);
278 } 280 }
279 281
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLVaryingHandler.h ('k') | src/gpu/glsl/GrGLSLProgramBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698