aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-10-21 12:53:15 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-21 12:53:16 -0700
commitb4384b9bba6f3473a3f024150bfe307cdd1753c7 (patch)
tree926c3c54cd33156d0e577514f6b9f88297c6812b
parent39393e3ac309d4bedbc18bae98d3ebcb762501dd (diff)
Bug fix for es 3.00 fb fetch
patch for es 300 shader fb fetch BUG=skia: Review URL: https://codereview.chromium.org/665893008
-rw-r--r--src/gpu/gl/GrGLCaps.cpp1
-rw-r--r--src/gpu/gl/GrGLCaps.h3
-rw-r--r--src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp23
-rw-r--r--src/gpu/gl/builders/GrGLFragmentShaderBuilder.h1
4 files changed, 21 insertions, 7 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index b4cfad354a..ee87a39089 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -7,6 +7,7 @@
#include "GrGLCaps.h"
+
#include "GrGLContext.h"
#include "SkTSearch.h"
#include "SkTSort.h"
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index eb56798fda..f84019335c 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -168,7 +168,7 @@ public:
/**
* Some helper functions for encapsulating various extensions to read FB Buffer on openglES
*
- * TODO On desktop opengl 4.2+ we can achieve something similar to this effect
+ * TODO(joshualitt) On desktop opengl 4.2+ we can achieve something similar to this effect
*/
bool fbFetchSupport() const { return fFBFetchSupport; }
@@ -367,6 +367,7 @@ private:
bool fIsCoreProfile : 1;
bool fFullClearIsFree : 1;
bool fDropsTileOnZeroDivide : 1;
+ // TODO(joshualitt) encapsulate the FB Fetch logic in a feature object
bool fFBFetchSupport : 1;
const char* fFBFetchColorName;
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
index 5d5741ef9b..76558d8875 100644
--- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
@@ -75,6 +75,7 @@ GrGLFragmentShaderBuilder::GrGLFragmentShaderBuilder(GrGLProgramBuilder* program
, fHasSecondaryOutput(false)
, fSetupFragPosition(false)
, fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFragPosKey)
+ , fCustomColorOutputIndex(-1)
, fHasReadDstColor(false)
, fHasReadFragmentPosition(false) {
}
@@ -172,7 +173,15 @@ const char* GrGLFragmentShaderBuilder::dstColor() {
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::emitCodeToReadDstTexture() {
}
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() {
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
index fdf685cc09..1637d25612 100644
--- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
+++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
@@ -149,6 +149,7 @@ private:
bool fHasSecondaryOutput;
bool fSetupFragPosition;
bool fTopLeftFragPosRead;
+ int fCustomColorOutputIndex;
// some state to verify shaders and effects are consistent, this is reset between effects by
// the program creator