Replace fWillReadFragmentPosition with a bitfield
Replaces fWillReadFragmentPosition on GrProcessor with a
"RequiredFeatures" bitfield. This will allow us to add additional
built-in features. Completely removes information about reading the
fragment position from GrPipeline and GrProcOptInfo.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1734163002
Review URL: https://codereview.chromium.org/1734163002
diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
index 44db57e..bd01084 100644
--- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
@@ -74,10 +74,16 @@
, fHasCustomColorOutput(false)
, fCustomColorOutputIndex(-1)
, fHasSecondaryOutput(false)
- , fHasInitializedSampleMask(false)
- , fHasReadDstColor(false)
- , fHasReadFragmentPosition(false) {
+ , fHasInitializedSampleMask(false) {
fSubstageIndices.push_back(0);
+#ifdef SK_DEBUG
+ fUsedProcessorFeatures = GrProcessor::kNone_RequiredFeatures;
+ fHasReadDstColor = false;
+#endif
+}
+
+bool GrGLSLFragmentShaderBuilder::hasFragmentPosition() const {
+ return 0 != fProgramBuilder->header().fFragPosKey;
}
bool GrGLSLFragmentShaderBuilder::enableFeature(GLSLFeature feature) {
@@ -123,7 +129,8 @@
}
const char* GrGLSLFragmentShaderBuilder::fragmentPosition() {
- fHasReadFragmentPosition = true;
+ SkASSERT(this->hasFragmentPosition());
+ SkDEBUGCODE(fUsedProcessorFeatures |= GrProcessor::kFragmentPosition_RequiredFeature;)
const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
// We only declare "gl_FragCoord" when we're in the case where we want to use layout qualifiers
@@ -212,7 +219,7 @@
}
const char* GrGLSLFragmentShaderBuilder::dstColor() {
- fHasReadDstColor = true;
+ SkDEBUGCODE(fHasReadDstColor = true;)
const char* override = fProgramBuilder->primitiveProcessor().getDestColorOverride();
if (override != nullptr) {