fix for FB fetch on nexus 10 ES3.0

BUG=skia:3304

Review URL: https://codereview.chromium.org/807143006
This commit is contained in:
joshualitt 2015-01-13 13:13:59 -08:00 committed by Commit bot
parent bb928a0c0a
commit 3c1096fc07
3 changed files with 11 additions and 4 deletions

View File

@ -50,6 +50,7 @@ void GrGLCaps::reset() {
fFullClearIsFree = false;
fDropsTileOnZeroDivide = false;
fFBFetchSupport = false;
fFBFetchNeedsCustomOutput = false;
fFBFetchColorName = NULL;
fFBFetchExtensionString = NULL;
@ -93,6 +94,7 @@ GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) {
fFullClearIsFree = caps.fFullClearIsFree;
fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide;
fFBFetchSupport = caps.fFBFetchSupport;
fFBFetchNeedsCustomOutput = caps.fFBFetchNeedsCustomOutput;
fFBFetchColorName = caps.fFBFetchColorName;
fFBFetchExtensionString = caps.fFBFetchExtensionString;
@ -250,16 +252,19 @@ bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
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";

View File

@ -172,6 +172,8 @@ public:
*/
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 @@ private:
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;

View File

@ -171,9 +171,9 @@ const char* GrGLFragmentShaderBuilder::dstColor() {
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();