Add computation of requestedFeatures to GrProgramInfo and use it
This is a deferred TODO/code review request. In general, this improves the encapsulation of program information w/in GrProgramInfo. Additionally, it is desirable to stop using the Desc/Key to access this information.
Bug: skia:9455
Change-Id: I854ff3225a49657d3a523e88e4bfa549128ee486
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/247336
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp
index c416e23..af81577 100644
--- a/src/gpu/GrProgramDesc.cpp
+++ b/src/gpu/GrProgramDesc.cpp
@@ -212,16 +212,12 @@
return false;
}
- // TODO: use programInfo.requestedFeatures here
- GrProcessor::CustomFeatures processorFeatures = programInfo.primProc().requestedFeatures();
-
for (int i = 0; i < programInfo.pipeline().numFragmentProcessors(); ++i) {
const GrFragmentProcessor& fp = programInfo.pipeline().getFragmentProcessor(i);
if (!gen_frag_proc_and_meta_keys(programInfo.primProc(), fp, gpu, shaderCaps, &b)) {
desc->key().reset();
return false;
}
- processorFeatures |= fp.requestedFeatures();
}
const GrXferProcessor& xp = programInfo.pipeline().getXferProcessor();
@@ -236,9 +232,8 @@
desc->key().reset();
return false;
}
- processorFeatures |= xp.requestedFeatures();
- if (processorFeatures & GrProcessor::CustomFeatures::kSampleLocations) {
+ if (programInfo.requestedFeatures() & GrProcessor::CustomFeatures::kSampleLocations) {
SkASSERT(programInfo.pipeline().isHWAntialiasState());
b.add32(renderTarget->renderTargetPriv().getSamplePatternKey());
}
@@ -262,9 +257,10 @@
// If we knew the shader won't depend on origin, we could skip this (and use the same program
// for both origins). Instrumenting all fragment processors would be difficult and error prone.
header->fSurfaceOriginKey =
- GrGLSLFragmentShaderBuilder::KeyForSurfaceOrigin(programInfo.origin());
- header->fProcessorFeatures = (uint8_t)processorFeatures;
- SkASSERT(header->processorFeatures() == processorFeatures); // Ensure enough bits.
+ GrGLSLFragmentShaderBuilder::KeyForSurfaceOrigin(programInfo.origin());
+ header->fProcessorFeatures = (uint8_t)programInfo.requestedFeatures();
+ // Ensure enough bits.
+ SkASSERT(header->fProcessorFeatures == (int) programInfo.requestedFeatures());
header->fSnapVerticesToPixelCenters = programInfo.pipeline().snapVerticesToPixelCenters();
header->fHasPointSize = hasPointSize ? 1 : 0;
return true;