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

Unified Diff: src/gpu/gl/GrGLCaps.cpp

Issue 1037123003: Implement support for KHR_blend_equation_advanced (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_zzz2_barriers
Patch Set: Rebase, blend_support_all_equations Created 5 years, 7 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
Index: src/gpu/gl/GrGLCaps.cpp
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 2edf1d0219ac6e3ad4f4f7a1eabb8acfc5955bfa..79ef114d685bf277663031b43e88b1c1b5e1553c 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -269,6 +269,21 @@ bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
fStencilWrapOpsSupport = true;
}
+ if (kIntel_GrGLVendor != ctxInfo.vendor()) {
+ if (ctxInfo.hasExtension("GL_KHR_blend_equation_advanced_coherent") ||
+ ctxInfo.hasExtension("GL_NV_blend_equation_advanced_coherent")) {
+ fBlendEquationSupport = kAdvancedCoherent_BlendEquationSupport;
+ } else if (ctxInfo.hasExtension("GL_KHR_blend_equation_advanced") ||
+ ctxInfo.hasExtension("GL_NV_blend_equation_advanced")) {
+ fBlendEquationSupport = kAdvanced_BlendEquationSupport;
+ } else {
+ fBlendEquationSupport = kBasic_BlendEquationSupport;
+ }
+ } else {
+ // On Intel platforms, KHR_blend_equation_advanced is not conformant.
+ fBlendEquationSupport = kBasic_BlendEquationSupport;
+ }
+
if (kGL_GrGLStandard == standard) {
fMapBufferFlags = kCanMap_MapFlag; // we require VBO support and the desktop VBO
// extension includes glMapBuffer.
@@ -352,7 +367,7 @@ bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
this->initConfigTexturableTable(ctxInfo, gli);
this->initConfigRenderableTable(ctxInfo);
- reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get())->init(ctxInfo, gli);
+ reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get())->init(ctxInfo, gli, *this);
return true;
}
@@ -914,6 +929,7 @@ void GrGLSLCaps::reset() {
fDropsTileOnZeroDivide = false;
fFBFetchSupport = false;
fFBFetchNeedsCustomOutput = false;
+ fAdvancedBlendEqnInteraction = kNotSupported_AdvancedBlendEqnInteraction;
fFBFetchColorName = NULL;
fFBFetchExtensionString = NULL;
}
@@ -927,13 +943,16 @@ GrGLSLCaps& GrGLSLCaps::operator= (const GrGLSLCaps& caps) {
fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide;
fFBFetchSupport = caps.fFBFetchSupport;
fFBFetchNeedsCustomOutput = caps.fFBFetchNeedsCustomOutput;
+ fAdvancedBlendEqnInteraction = caps.fAdvancedBlendEqnInteraction;
fFBFetchColorName = caps.fFBFetchColorName;
fFBFetchExtensionString = caps.fFBFetchExtensionString;
return *this;
}
-bool GrGLSLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
+bool GrGLSLCaps::init(const GrGLContextInfo& ctxInfo,
+ const GrGLInterface* gli,
+ const GrGLCaps& glCaps) {
this->reset();
if (!ctxInfo.isInitialized()) {
return false;
@@ -1010,6 +1029,20 @@ bool GrGLSLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli)
ctxInfo.hasExtension("GL_OES_standard_derivatives");
}
+ if (glCaps.advancedBlendEquationSupport()) {
+ bool coherent =
+ GrDrawTargetCaps::kAdvancedCoherent_BlendEquationSupport == glCaps.blendEquationSupport();
+
+ if (ctxInfo.hasExtension(coherent ? "GL_NV_blend_equation_advanced_coherent"
+ : "GL_NV_blend_equation_advanced")) {
+ fAdvancedBlendEqnInteraction = kAutomatic_AdvancedBlendEqnInteraction;
+ } else {
+ fAdvancedBlendEqnInteraction = kMustEnable_AdvancedBlendEqnInteraction;
+ // TODO: Use the following on any platform where "blend_support_all_equations" is slow.
+ //fAdvancedBlendEqnInteraction = kMustEnableSeparately_AdvancedBlendEqnInteraction;
+ }
+ }
+
this->initShaderPrecisionTable(ctxInfo, gli);
return true;
@@ -1018,10 +1051,25 @@ bool GrGLSLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli)
SkString GrGLSLCaps::dump() const {
SkString r = INHERITED::dump();
+ static const char* kAdvancedBlendEqnInteractionStr[] = {
+ "Not Supported",
+ "Automatic",
+ "Must Enable",
+ "Must Enable Separately",
+ };
+ GR_STATIC_ASSERT(0 == kNotSupported_AdvancedBlendEqnInteraction);
+ GR_STATIC_ASSERT(1 == kAutomatic_AdvancedBlendEqnInteraction);
+ GR_STATIC_ASSERT(2 == kMustEnable_AdvancedBlendEqnInteraction);
+ GR_STATIC_ASSERT(3 == kMustEnableSeparately_AdvancedBlendEqnInteraction);
+ GR_STATIC_ASSERT(SK_ARRAY_COUNT(kAdvancedBlendEqnInteractionStr) ==
+ kLast_AdvancedBlendEqnInteraction + 1);
+
r.appendf("--- GLSL-Specific ---\n");
r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO"));
r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
+ r.appendf("Advanced blend equation interaction: %s\n",
+ kAdvancedBlendEqnInteractionStr[fAdvancedBlendEqnInteraction]);
return r;
}

Powered by Google App Engine
This is Rietveld 408576698