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

Unified Diff: src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp

Issue 1266773003: Implement support for dual source blending in ES (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/builders/GrGLFragmentShaderBuilder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
index 621243f53bbb6c81c498e688a9c3fa71a55294bd..a7a35e3676f41c4eaf1657864c4238a1a7a8d0a3 100644
--- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
@@ -16,7 +16,7 @@
const char* GrGLFragmentShaderBuilder::kDstTextureColorName = "_dstColor";
static const char* declared_color_output_name() { return "fsColorOut"; }
-static const char* dual_source_output_name() { return "dualSourceOut"; }
+static const char* declared_secondary_color_output_name() { return "fsSecondaryColorOut"; }
static const char* specific_layout_qualifier_name(GrBlendEquation equation) {
SkASSERT(GrBlendEquationIsAdvanced(equation));
@@ -240,8 +240,19 @@ void GrGLFragmentShaderBuilder::enableCustomOutput() {
void GrGLFragmentShaderBuilder::enableSecondaryOutput() {
SkASSERT(!fHasSecondaryOutput);
fHasSecondaryOutput = true;
- fOutputs.push_back().set(kVec4f_GrSLType, GrGLShaderVar::kOut_TypeModifier,
- dual_source_output_name());
+ if (kGLES_GrGLStandard == fProgramBuilder->gpu()->ctxInfo().standard()) {
+ this->addFeature(1 << kBlendFuncExtended_GLSLPrivateFeature, "GL_EXT_blend_func_extended");
+ }
+
+ // If the primary output is declared, we must declare also the secondary output
+ // and vice versa, since it is not allowed to use a built-in gl_FragColor and a custom
+ // output. The condition also co-incides with the condition in whici GLES SL 2.0
+ // requires the built-in gl_SecondaryFragColorEXT, where as 3.0 requires a custom output.
+ const GrGLSLCaps& caps = *fProgramBuilder->gpu()->glCaps().glslCaps();
+ if (caps.mustDeclareFragmentShaderOutput()) {
+ fOutputs.push_back().set(kVec4f_GrSLType, GrGLShaderVar::kOut_TypeModifier,
+ declared_secondary_color_output_name());
+ }
}
const char* GrGLFragmentShaderBuilder::getPrimaryColorOutputName() const {
@@ -249,7 +260,9 @@ const char* GrGLFragmentShaderBuilder::getPrimaryColorOutputName() const {
}
const char* GrGLFragmentShaderBuilder::getSecondaryColorOutputName() const {
- return dual_source_output_name();
+ const GrGLSLCaps& caps = *fProgramBuilder->gpu()->glCaps().glslCaps();
+ return caps.mustDeclareFragmentShaderOutput() ? declared_secondary_color_output_name()
+ : "gl_SecondaryFragColorEXT";
}
bool GrGLFragmentShaderBuilder::compileAndAttachShaders(GrGLuint programId,
@@ -270,11 +283,13 @@ bool GrGLFragmentShaderBuilder::compileAndAttachShaders(GrGLuint programId,
}
void GrGLFragmentShaderBuilder::bindFragmentShaderLocations(GrGLuint programID) {
- if (fHasCustomColorOutput && fProgramBuilder->gpu()->glCaps().bindFragDataLocationSupport()) {
+ const GrGLCaps& caps = fProgramBuilder->gpu()->glCaps();
+ if (fHasCustomColorOutput && caps.bindFragDataLocationSupport()) {
GL_CALL(BindFragDataLocation(programID, 0, declared_color_output_name()));
}
- if (fHasSecondaryOutput) {
- GL_CALL(BindFragDataLocationIndexed(programID, 0, 1, dual_source_output_name()));
+ if (fHasSecondaryOutput && caps.glslCaps()->mustDeclareFragmentShaderOutput()) {
+ GL_CALL(BindFragDataLocationIndexed(programID, 0, 1,
+ declared_secondary_color_output_name()));
}
}
« no previous file with comments | « src/gpu/gl/builders/GrGLFragmentShaderBuilder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698