fix for FB fetch on nexus 10 ES3.0
BUG=skia:3304
Review URL: https://codereview.chromium.org/807143006
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index b729820..376bfd4 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -50,6 +50,7 @@
fFullClearIsFree = false;
fDropsTileOnZeroDivide = false;
fFBFetchSupport = false;
+ fFBFetchNeedsCustomOutput = false;
fFBFetchColorName = NULL;
fFBFetchExtensionString = NULL;
@@ -93,6 +94,7 @@
fFullClearIsFree = caps.fFullClearIsFree;
fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide;
fFBFetchSupport = caps.fFBFetchSupport;
+ fFBFetchNeedsCustomOutput = caps.fFBFetchNeedsCustomOutput;
fFBFetchColorName = caps.fFBFetchColorName;
fFBFetchExtensionString = caps.fFBFetchExtensionString;
@@ -250,16 +252,19 @@
if (kGLES_GrGLStandard == standard) {
if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) {
+ fFBFetchNeedsCustomOutput = (version >= GR_GL_VER(3, 0));
fFBFetchSupport = true;
fFBFetchColorName = "gl_LastFragData[0]";
fFBFetchExtensionString = "GL_EXT_shader_framebuffer_fetch";
} else if (ctxInfo.hasExtension("GL_NV_shader_framebuffer_fetch")) {
+ // Actually, we haven't seen an ES3.0 device with this extension yet, so we don't know
+ fFBFetchNeedsCustomOutput = false;
fFBFetchSupport = true;
fFBFetchColorName = "gl_LastFragData[0]";
fFBFetchExtensionString = "GL_NV_shader_framebuffer_fetch";
} else if (ctxInfo.hasExtension("GL_ARM_shader_framebuffer_fetch")) {
// The arm extension also requires an additional flag which we will set onResetContext
- // This is all temporary.
+ fFBFetchNeedsCustomOutput = false;
fFBFetchSupport = true;
fFBFetchColorName = "gl_LastFragColorARM";
fFBFetchExtensionString = "GL_ARM_shader_framebuffer_fetch";
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 7ccb1d9..77baf38 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -172,6 +172,8 @@
*/
bool fbFetchSupport() const { return fFBFetchSupport; }
+ bool fbFetchNeedsCustomOutput() const { return fFBFetchNeedsCustomOutput; }
+
const char* fbFetchColorName() const { return fFBFetchColorName; }
const char* fbFetchExtensionString() const { return fFBFetchExtensionString; }
@@ -372,8 +374,8 @@
bool fIsCoreProfile : 1;
bool fFullClearIsFree : 1;
bool fDropsTileOnZeroDivide : 1;
- // TODO(joshualitt) encapsulate the FB Fetch logic in a feature object
bool fFBFetchSupport : 1;
+ bool fFBFetchNeedsCustomOutput : 1;
const char* fFBFetchColorName;
const char* fFBFetchExtensionString;
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
index b59df57..46433f0 100644
--- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
@@ -171,9 +171,9 @@
this->addFeature(1 << (GrGLFragmentShaderBuilder::kLastGLSLPrivateFeature + 1),
gpu->glCaps().fbFetchExtensionString());
- // On ES 3.0 we have to declare this, and use the custom color output name
+ // Some versions of this extension string require declaring custom color output on ES 3.0+
const char* fbFetchColorName = gpu->glCaps().fbFetchColorName();
- if (gpu->glslGeneration() >= k330_GrGLSLGeneration) {
+ if (gpu->glCaps().fbFetchNeedsCustomOutput()) {
this->enableCustomOutput();
fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOut_TypeModifier);
fbFetchColorName = declared_color_output_name();