Make reducedShaderMode a shader cap

Allows GrProcessors to change behavior based on cap.

Bug: skia:11844
Change-Id: I4378c47c50a9bf33fa7461c6b9c522413e932bcd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395717
Commit-Queue: Brian Salomon <bsalomon@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
Brian Salomon 2021-04-12 11:18:32 -04:00 committed by Skia Commit-Bot
parent d02615698e
commit e9f22657c3
4 changed files with 11 additions and 9 deletions

View File

@ -56,11 +56,6 @@ GrCaps::GrCaps(const GrContextOptions& options) {
fReadPixelsRowBytesSupport = false; fReadPixelsRowBytesSupport = false;
fShouldCollapseSrcOverToSrcWhenAble = false; fShouldCollapseSrcOverToSrcWhenAble = false;
fMustSyncGpuDuringAbandon = true; fMustSyncGpuDuringAbandon = true;
#if GR_TEST_UTILS
fReducedShaderMode = options.fReducedShaderVariations;
#else
fReducedShaderMode = false;
#endif
fDriverDisableMSAAClipAtlas = false; fDriverDisableMSAAClipAtlas = false;
fDisableTessellationPathRenderer = false; fDisableTessellationPathRenderer = false;

View File

@ -160,9 +160,8 @@ public:
return fMustSyncGpuDuringAbandon; return fMustSyncGpuDuringAbandon;
} }
// Use a reduced set of rendering algorithms or less optimal effects in order to // Shortcut for shaderCaps()->reducedShaderMode().
// reduce the number of unique shaders generated. bool reducedShaderMode() const { return this->shaderCaps()->reducedShaderMode(); }
bool reducedShaderMode() const { return fReducedShaderMode; }
/** /**
* Indicates whether GPU->CPU memory mapping for GPU resources such as vertex buffers and * Indicates whether GPU->CPU memory mapping for GPU resources such as vertex buffers and
@ -527,7 +526,6 @@ protected:
bool fReadPixelsRowBytesSupport : 1; bool fReadPixelsRowBytesSupport : 1;
bool fShouldCollapseSrcOverToSrcWhenAble : 1; bool fShouldCollapseSrcOverToSrcWhenAble : 1;
bool fMustSyncGpuDuringAbandon : 1; bool fMustSyncGpuDuringAbandon : 1;
bool fReducedShaderMode : 1;
// Driver workaround // Driver workaround
bool fDriverDisableMSAAClipAtlas : 1; bool fDriverDisableMSAAClipAtlas : 1;

View File

@ -54,6 +54,7 @@ GrShaderCaps::GrShaderCaps(const GrContextOptions& options) {
fFloatIs32Bits = true; fFloatIs32Bits = true;
fHalfIs32Bits = false; fHalfIs32Bits = false;
fHasLowFragmentPrecision = false; fHasLowFragmentPrecision = false;
fReducedShaderMode = false;
fColorSpaceMathNeedsFloat = false; fColorSpaceMathNeedsFloat = false;
fBuiltinFMASupport = false; fBuiltinFMASupport = false;
fBuiltinDeterminantSupport = false; fBuiltinDeterminantSupport = false;
@ -189,5 +190,8 @@ void GrShaderCaps::applyOptionsOverrides(const GrContextOptions& options) {
fMaxTessellationSegments = std::min(options.fMaxTessellationSegmentsOverride, fMaxTessellationSegments = std::min(options.fMaxTessellationSegmentsOverride,
fMaxTessellationSegments); fMaxTessellationSegments);
} }
if (options.fReducedShaderVariations) {
fReducedShaderMode = true;
}
#endif #endif
} }

View File

@ -84,6 +84,10 @@ public:
bool hasLowFragmentPrecision() const { return fHasLowFragmentPrecision; } bool hasLowFragmentPrecision() const { return fHasLowFragmentPrecision; }
// Use a reduced set of rendering algorithms or less optimal effects in order to
// reduce the number of unique shaders generated.
bool reducedShaderMode() const { return fReducedShaderMode; }
// SkSL only. // SkSL only.
bool builtinFMASupport() const { return fBuiltinFMASupport; } bool builtinFMASupport() const { return fBuiltinFMASupport; }
@ -282,6 +286,7 @@ private:
bool fFloatIs32Bits : 1; bool fFloatIs32Bits : 1;
bool fHalfIs32Bits : 1; bool fHalfIs32Bits : 1;
bool fHasLowFragmentPrecision : 1; bool fHasLowFragmentPrecision : 1;
bool fReducedShaderMode : 1;
// Used by SkSL to know when to generate polyfills. // Used by SkSL to know when to generate polyfills.
bool fBuiltinFMASupport : 1; bool fBuiltinFMASupport : 1;