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

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

Issue 2288033003: Turned on SkSL->GLSL compiler (Closed)
Patch Set: changed <iostream> to <ostream> Created 4 years, 2 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/GrGLSLFragmentShaderBuilder.h ('k') | src/gpu/glsl/GrGLSLShaderBuilder.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 "GrRenderTargetPriv.h" 10 #include "GrRenderTargetPriv.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 this->addLayoutQualifier(specific_layout_qualifier_name(equation), kOut_ InterfaceQualifier); 284 this->addLayoutQualifier(specific_layout_qualifier_name(equation), kOut_ InterfaceQualifier);
285 } else { 285 } else {
286 this->addLayoutQualifier("blend_support_all_equations", kOut_InterfaceQu alifier); 286 this->addLayoutQualifier("blend_support_all_equations", kOut_InterfaceQu alifier);
287 } 287 }
288 } 288 }
289 289
290 void GrGLSLFragmentShaderBuilder::enableCustomOutput() { 290 void GrGLSLFragmentShaderBuilder::enableCustomOutput() {
291 if (!fHasCustomColorOutput) { 291 if (!fHasCustomColorOutput) {
292 fHasCustomColorOutput = true; 292 fHasCustomColorOutput = true;
293 fCustomColorOutputIndex = fOutputs.count(); 293 fCustomColorOutputIndex = fOutputs.count();
294 fOutputs.push_back().set(kVec4f_GrSLType, 294 fOutputs.push_back().set(kVec4f_GrSLType,
295 GrGLSLShaderVar::kOut_TypeModifier, 295 GrGLSLShaderVar::kOut_TypeModifier,
296 DeclaredColorOutputName()); 296 DeclaredColorOutputName());
297 fProgramBuilder->finalizeFragmentOutputColor(fOutputs.back()); 297 fProgramBuilder->finalizeFragmentOutputColor(fOutputs.back());
298 } 298 }
299 } 299 }
300 300
301 void GrGLSLFragmentShaderBuilder::enableSecondaryOutput() { 301 void GrGLSLFragmentShaderBuilder::enableSecondaryOutput() {
302 SkASSERT(!fHasSecondaryOutput); 302 SkASSERT(!fHasSecondaryOutput);
303 fHasSecondaryOutput = true; 303 fHasSecondaryOutput = true;
304 const GrGLSLCaps& caps = *fProgramBuilder->glslCaps(); 304 const GrGLSLCaps& caps = *fProgramBuilder->glslCaps();
305 if (const char* extension = caps.secondaryOutputExtensionString()) { 305 if (const char* extension = caps.secondaryOutputExtensionString()) {
306 this->addFeature(1 << kBlendFuncExtended_GLSLPrivateFeature, extension); 306 this->addFeature(1 << kBlendFuncExtended_GLSLPrivateFeature, extension);
307 } 307 }
308 308
309 // If the primary output is declared, we must declare also the secondary out put 309 // If the primary output is declared, we must declare also the secondary out put
310 // and vice versa, since it is not allowed to use a built-in gl_FragColor an d a custom 310 // and vice versa, since it is not allowed to use a built-in gl_FragColor an d a custom
311 // output. The condition also co-incides with the condition in whici GLES SL 2.0 311 // output. The condition also co-incides with the condition in whici GLES SL 2.0
312 // requires the built-in gl_SecondaryFragColorEXT, where as 3.0 requires a c ustom output. 312 // requires the built-in gl_SecondaryFragColorEXT, where as 3.0 requires a c ustom output.
313 if (caps.mustDeclareFragmentShaderOutput()) { 313 if (caps.mustDeclareFragmentShaderOutput()) {
314 fOutputs.push_back().set(kVec4f_GrSLType, GrGLSLShaderVar::kOut_TypeModi fier, 314 fOutputs.push_back().set(kVec4f_GrSLType, GrGLSLShaderVar::kOut_TypeModi fier,
315 DeclaredSecondaryColorOutputName()); 315 DeclaredSecondaryColorOutputName());
316 fProgramBuilder->finalizeFragmentSecondaryColor(fOutputs.back()); 316 fProgramBuilder->finalizeFragmentSecondaryColor(fOutputs.back());
317 } 317 }
318 } 318 }
319 319
320 const char* GrGLSLFragmentShaderBuilder::getPrimaryColorOutputName() const { 320 const char* GrGLSLFragmentShaderBuilder::getPrimaryColorOutputName() const {
321 return fHasCustomColorOutput ? DeclaredColorOutputName() : "gl_FragColor"; 321 return fHasCustomColorOutput ? DeclaredColorOutputName() : "sk_FragColor";
322 } 322 }
323 323
324 void GrGLSLFragmentBuilder::declAppendf(const char* fmt, ...) { 324 void GrGLSLFragmentBuilder::declAppendf(const char* fmt, ...) {
325 va_list argp; 325 va_list argp;
326 va_start(argp, fmt); 326 va_start(argp, fmt);
327 inputs().appendVAList(fmt, argp); 327 inputs().appendVAList(fmt, argp);
328 va_end(argp); 328 va_end(argp);
329 } 329 }
330 330
331 const char* GrGLSLFragmentShaderBuilder::getSecondaryColorOutputName() const { 331 const char* GrGLSLFragmentShaderBuilder::getSecondaryColorOutputName() const {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2] ); 388 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2] );
389 } 389 }
390 390
391 void GrGLSLFragmentShaderBuilder::onAfterChildProcEmitCode() { 391 void GrGLSLFragmentShaderBuilder::onAfterChildProcEmitCode() {
392 SkASSERT(fSubstageIndices.count() >= 2); 392 SkASSERT(fSubstageIndices.count() >= 2);
393 fSubstageIndices.pop_back(); 393 fSubstageIndices.pop_back();
394 fSubstageIndices.back()++; 394 fSubstageIndices.back()++;
395 int removeAt = fMangleString.findLastOf('_'); 395 int removeAt = fMangleString.findLastOf('_');
396 fMangleString.remove(removeAt, fMangleString.size() - removeAt); 396 fMangleString.remove(removeAt, fMangleString.size() - removeAt);
397 } 397 }
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentShaderBuilder.h ('k') | src/gpu/glsl/GrGLSLShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698