Enforce extra constraints for mixed samples at GrCaps level
Change-Id: Icbeafeb25614d66e548027e5777ea1699d1e6f7d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/254116
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index dd2aa36..ee2ba50 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -80,7 +80,19 @@
fDriverBugWorkarounds = options.fDriverBugWorkarounds;
}
+void GrCaps::finishInitialization(const GrContextOptions& options) {
+ if (fMixedSamplesSupport) {
+ // We need multisample disable and dual source blending in order to support mixed samples.
+ fMixedSamplesSupport = this->multisampleDisableSupport() &&
+ this->shaderCaps()->dualSourceBlendingSupport();
+ }
+
+ // Overrides happen last.
+ this->applyOptionsOverrides(options);
+}
+
void GrCaps::applyOptionsOverrides(const GrContextOptions& options) {
+ fShaderCaps->applyOptionsOverrides(options);
this->onApplyOptionsOverrides(options);
if (options.fDisableDriverCorrectnessWorkarounds) {
SkASSERT(!fDriverBlacklistCCPR);
@@ -109,8 +121,10 @@
if (options.fMaxTileSizeOverride && options.fMaxTileSizeOverride < fMaxTextureSize) {
fMaxTileSize = options.fMaxTileSizeOverride;
}
- if (options.fSuppressGeometryShaders) {
- fShaderCaps->fGeometryShaderSupport = false;
+ if (options.fSuppressDualSourceBlending) {
+ // GrShaderCaps::applyOptionsOverrides already handled the rest; here we just need to make
+ // sure mixed samples gets disabled if dual source blending is suppressed.
+ fMixedSamplesSupport = false;
}
if (options.fClearAllTextures) {
fShouldInitializeTextures = true;
diff --git a/src/gpu/GrCaps.h b/src/gpu/GrCaps.h
index 4ab32b9..d8be432 100644
--- a/src/gpu/GrCaps.h
+++ b/src/gpu/GrCaps.h
@@ -458,10 +458,10 @@
#endif
protected:
- /** Subclasses must call this at the end of their constructors in order to apply caps
- overrides requested by the client. Note that overrides will only reduce the caps never
- expand them. */
- void applyOptionsOverrides(const GrContextOptions& options);
+ // Subclasses must call this at the end of their init method in order to do final processing on
+ // the caps (including overrides requested by the client).
+ // NOTE: this method will only reduce the caps, never expand them.
+ void finishInitialization(const GrContextOptions& options);
sk_sp<GrShaderCaps> fShaderCaps;
@@ -532,6 +532,8 @@
GrDriverBugWorkarounds fDriverBugWorkarounds;
private:
+ void applyOptionsOverrides(const GrContextOptions& options);
+
virtual void onApplyOptionsOverrides(const GrContextOptions&) {}
virtual void onDumpJSON(SkJSONWriter*) const {}
virtual bool onSurfaceSupportsWritePixels(const GrSurface*) const = 0;
diff --git a/src/gpu/GrShaderCaps.cpp b/src/gpu/GrShaderCaps.cpp
index ae7144c..60ea381 100644
--- a/src/gpu/GrShaderCaps.cpp
+++ b/src/gpu/GrShaderCaps.cpp
@@ -166,6 +166,11 @@
SkASSERT(!fNoDefaultPrecisionForExternalSamplers);
}
#if GR_TEST_UTILS
- fDualSourceBlendingSupport = fDualSourceBlendingSupport && !options.fSuppressDualSourceBlending;
+ if (options.fSuppressDualSourceBlending) {
+ fDualSourceBlendingSupport = false;
+ }
+ if (options.fSuppressGeometryShaders) {
+ fGeometryShaderSupport = false;
+ }
#endif
}
diff --git a/src/gpu/dawn/GrDawnCaps.cpp b/src/gpu/dawn/GrDawnCaps.cpp
index 6a35af4..a5114a7 100644
--- a/src/gpu/dawn/GrDawnCaps.cpp
+++ b/src/gpu/dawn/GrDawnCaps.cpp
@@ -25,8 +25,7 @@
fShaderCaps->fMaxFragmentSamplers = 6;
fShaderCaps->fShaderDerivativeSupport = true;
- this->applyOptionsOverrides(contextOptions);
- fShaderCaps->applyOptionsOverrides(contextOptions);
+ this->finishInitialization(contextOptions);
}
bool GrDawnCaps::isFormatSRGB(const GrBackendFormat& format) const {
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 19675db..dd39ebe 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -692,8 +692,7 @@
// already been detected.
this->initFormatTable(ctxInfo, gli, formatWorkarounds);
- this->applyOptionsOverrides(contextOptions);
- shaderCaps->applyOptionsOverrides(contextOptions);
+ this->finishInitialization(contextOptions);
// For now these two are equivalent but we could have dst read in shader via some other method.
shaderCaps->fDstReadInShaderSupport = shaderCaps->fFBFetchSupport;
@@ -942,13 +941,11 @@
return true;
}
-void GrGLCaps::initFSAASupport(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo,
- const GrGLInterface* gli) {
- // We need dual source blending and the ability to disable multisample in order to support mixed
- // samples in every corner case.
- if (fMultisampleDisableSupport && this->shaderCaps()->dualSourceBlendingSupport()) {
- fMixedSamplesSupport = ctxInfo.hasExtension("GL_NV_framebuffer_mixed_samples") ||
- ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_mixed_samples");
+void GrGLCaps::initFSAASupport(const GrContextOptions& contextOptions,
+ const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
+ if (ctxInfo.hasExtension("GL_NV_framebuffer_mixed_samples") ||
+ ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_mixed_samples")) {
+ fMixedSamplesSupport = true;
}
if (GR_IS_GR_GL(ctxInfo.standard())) {
diff --git a/src/gpu/mock/GrMockCaps.h b/src/gpu/mock/GrMockCaps.h
index e360efd..e25bc51 100644
--- a/src/gpu/mock/GrMockCaps.h
+++ b/src/gpu/mock/GrMockCaps.h
@@ -36,7 +36,7 @@
fShaderCaps->fDualSourceBlendingSupport = options.fDualSourceBlendingSupport;
fShaderCaps->fSampleMaskSupport = true;
- this->applyOptionsOverrides(contextOptions);
+ this->finishInitialization(contextOptions);
}
bool isFormatSRGB(const GrBackendFormat& format) const override {
diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm
index 45cceba..db8aeab 100644
--- a/src/gpu/mtl/GrMtlCaps.mm
+++ b/src/gpu/mtl/GrMtlCaps.mm
@@ -30,8 +30,7 @@
this->initFormatTable();
this->initStencilFormat(device);
- this->applyOptionsOverrides(contextOptions);
- fShaderCaps->applyOptionsOverrides(contextOptions);
+ this->finishInitialization(contextOptions);
// The following are disabled due to the unfinished Metal backend, not because Metal itself
// doesn't support it.
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 7dac87a..dee007f 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -388,8 +388,7 @@
this->applyDriverCorrectnessWorkarounds(properties);
}
- this->applyOptionsOverrides(contextOptions);
- fShaderCaps->applyOptionsOverrides(contextOptions);
+ this->finishInitialization(contextOptions);
}
void GrVkCaps::applyDriverCorrectnessWorkarounds(const VkPhysicalDeviceProperties& properties) {