Bug fix for es 3.00 fb fetch
patch for es 300 shader fb fetch
BUG=skia:
Review URL: https://codereview.chromium.org/665893008
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
index 5d5741e..76558d8 100644
--- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
@@ -75,6 +75,7 @@
, fHasSecondaryOutput(false)
, fSetupFragPosition(false)
, fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFragPosKey)
+ , fCustomColorOutputIndex(-1)
, fHasReadDstColor(false)
, fHasReadFragmentPosition(false) {
}
@@ -172,7 +173,15 @@
if (gpu->glCaps().fbFetchSupport()) {
this->addFeature(1 << (GrGLFragmentShaderBuilder::kLastGLSLPrivateFeature + 1),
gpu->glCaps().fbFetchExtensionString());
- return gpu->glCaps().fbFetchColorName();
+
+ // On ES 3.0 we have to declare this, and use the custom color output name
+ const char* fbFetchColorName = gpu->glCaps().fbFetchColorName();
+ if (gpu->glslGeneration() >= k330_GrGLSLGeneration) {
+ this->enableCustomOutput();
+ fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOut_TypeModifier);
+ fbFetchColorName = declared_color_output_name();
+ }
+ return fbFetchColorName;
} else if (fProgramBuilder->fUniformHandles.fDstCopySamplerUni.isValid()) {
return kDstCopyColorName;
} else {
@@ -223,11 +232,13 @@
}
void GrGLFragmentShaderBuilder::enableCustomOutput() {
- SkASSERT(!fHasCustomColorOutput);
- fHasCustomColorOutput = true;
- fOutputs.push_back().set(kVec4f_GrSLType,
- GrGLShaderVar::kOut_TypeModifier,
- declared_color_output_name());
+ if (!fHasCustomColorOutput) {
+ fHasCustomColorOutput = true;
+ fCustomColorOutputIndex = fOutputs.count();
+ fOutputs.push_back().set(kVec4f_GrSLType,
+ GrGLShaderVar::kOut_TypeModifier,
+ declared_color_output_name());
+ }
}
void GrGLFragmentShaderBuilder::enableSecondaryOutput() {