Restore support for multisample locations
Bug: skia:
Change-Id: I971455867e54d431cc1094fca041f773f78748ee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/196218
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp
index f39b666..26b06f9 100644
--- a/src/gpu/GrProgramDesc.cpp
+++ b/src/gpu/GrProgramDesc.cpp
@@ -180,12 +180,10 @@
fp.numCoordTransforms()), b);
}
-bool GrProgramDesc::Build(GrProgramDesc* desc,
- GrPixelConfig config,
- const GrPrimitiveProcessor& primProc,
- bool hasPointSize,
- const GrPipeline& pipeline,
- GrGpu* gpu) {
+bool GrProgramDesc::Build(
+ GrProgramDesc* desc, const GrRenderTarget* renderTarget,
+ const GrPrimitiveProcessor& primProc, bool hasPointSize, const GrPipeline& pipeline,
+ GrGpu* gpu) {
// The descriptor is used as a cache key. Thus when a field of the
// descriptor will not affect program generation (because of the attribute
// bindings in use or other descriptor field settings) it should be set
@@ -206,6 +204,7 @@
desc->key().reset();
return false;
}
+ GrProcessor::CustomFeatures processorFeatures = primProc.requestedFeatures();
for (int i = 0; i < pipeline.numFragmentProcessors(); ++i) {
const GrFragmentProcessor& fp = pipeline.getFragmentProcessor(i);
@@ -213,6 +212,7 @@
desc->key().reset();
return false;
}
+ processorFeatures |= fp.requestedFeatures();
}
const GrXferProcessor& xp = pipeline.getXferProcessor();
@@ -227,6 +227,12 @@
desc->key().reset();
return false;
}
+ processorFeatures |= xp.requestedFeatures();
+
+ if (processorFeatures & GrProcessor::CustomFeatures::kSampleLocations) {
+ SkASSERT(pipeline.isHWAntialiasState());
+ b.add32(renderTarget->renderTargetPriv().getSamplePatternKey(pipeline));
+ }
// --------DO NOT MOVE HEADER ABOVE THIS LINE--------------------------------------------------
// Because header is a pointer into the dynamic array, we can't push any new data into the key
@@ -235,8 +241,7 @@
// make sure any padding in the header is zeroed.
memset(header, 0, kHeaderSize);
- header->fOutputSwizzle = shaderCaps.configOutputSwizzle(config).asKey();
- header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters();
+ header->fOutputSwizzle = shaderCaps.configOutputSwizzle(renderTarget->config()).asKey();
header->fColorFragmentProcessorCnt = pipeline.numColorFragmentProcessors();
header->fCoverageFragmentProcessorCnt = pipeline.numCoverageFragmentProcessors();
// Fail if the client requested more processors than the key can fit.
@@ -244,6 +249,9 @@
header->fCoverageFragmentProcessorCnt != pipeline.numCoverageFragmentProcessors()) {
return false;
}
+ header->fProcessorFeatures = (uint8_t)processorFeatures;
+ SkASSERT(header->processorFeatures() == processorFeatures); // Ensure enough bits.
+ header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters();
header->fHasPointSize = hasPointSize ? 1 : 0;
return true;
}