From e9f22657c3bafce924c48c3ee912d4bf51243993 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Mon, 12 Apr 2021 11:18:32 -0400 Subject: [PATCH] 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 Commit-Queue: Jim Van Verth Auto-Submit: Brian Salomon Reviewed-by: Jim Van Verth --- src/gpu/GrCaps.cpp | 5 ----- src/gpu/GrCaps.h | 6 ++---- src/gpu/GrShaderCaps.cpp | 4 ++++ src/gpu/GrShaderCaps.h | 5 +++++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp index 02a1220a4b..a450c7afdd 100644 --- a/src/gpu/GrCaps.cpp +++ b/src/gpu/GrCaps.cpp @@ -56,11 +56,6 @@ GrCaps::GrCaps(const GrContextOptions& options) { fReadPixelsRowBytesSupport = false; fShouldCollapseSrcOverToSrcWhenAble = false; fMustSyncGpuDuringAbandon = true; -#if GR_TEST_UTILS - fReducedShaderMode = options.fReducedShaderVariations; -#else - fReducedShaderMode = false; -#endif fDriverDisableMSAAClipAtlas = false; fDisableTessellationPathRenderer = false; diff --git a/src/gpu/GrCaps.h b/src/gpu/GrCaps.h index 4b09edb706..a12dc99e55 100644 --- a/src/gpu/GrCaps.h +++ b/src/gpu/GrCaps.h @@ -160,9 +160,8 @@ public: return fMustSyncGpuDuringAbandon; } - // 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; } + // Shortcut for shaderCaps()->reducedShaderMode(). + bool reducedShaderMode() const { return this->shaderCaps()->reducedShaderMode(); } /** * Indicates whether GPU->CPU memory mapping for GPU resources such as vertex buffers and @@ -527,7 +526,6 @@ protected: bool fReadPixelsRowBytesSupport : 1; bool fShouldCollapseSrcOverToSrcWhenAble : 1; bool fMustSyncGpuDuringAbandon : 1; - bool fReducedShaderMode : 1; // Driver workaround bool fDriverDisableMSAAClipAtlas : 1; diff --git a/src/gpu/GrShaderCaps.cpp b/src/gpu/GrShaderCaps.cpp index d3bc02c73c..33d6e147d2 100644 --- a/src/gpu/GrShaderCaps.cpp +++ b/src/gpu/GrShaderCaps.cpp @@ -54,6 +54,7 @@ GrShaderCaps::GrShaderCaps(const GrContextOptions& options) { fFloatIs32Bits = true; fHalfIs32Bits = false; fHasLowFragmentPrecision = false; + fReducedShaderMode = false; fColorSpaceMathNeedsFloat = false; fBuiltinFMASupport = false; fBuiltinDeterminantSupport = false; @@ -189,5 +190,8 @@ void GrShaderCaps::applyOptionsOverrides(const GrContextOptions& options) { fMaxTessellationSegments = std::min(options.fMaxTessellationSegmentsOverride, fMaxTessellationSegments); } + if (options.fReducedShaderVariations) { + fReducedShaderMode = true; + } #endif } diff --git a/src/gpu/GrShaderCaps.h b/src/gpu/GrShaderCaps.h index 485522c84e..2ca11c8b55 100644 --- a/src/gpu/GrShaderCaps.h +++ b/src/gpu/GrShaderCaps.h @@ -84,6 +84,10 @@ public: 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. bool builtinFMASupport() const { return fBuiltinFMASupport; } @@ -282,6 +286,7 @@ private: bool fFloatIs32Bits : 1; bool fHalfIs32Bits : 1; bool fHasLowFragmentPrecision : 1; + bool fReducedShaderMode : 1; // Used by SkSL to know when to generate polyfills. bool fBuiltinFMASupport : 1;