Revert "Always apply mipmap sharpening on GPU"

This reverts commit 1aedd5dc11.

Reason for revert: breaking units tests left and right

Original change's description:
> Always apply mipmap sharpening on GPU
>
> Bug: skia:13078
>
> Change-Id: If459a96eba09fb10e967bc364435f79b83fdc1ec
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/522099
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

Bug: skia:13078
Change-Id: If24ed4782c922347132bf9fc0dac7e8a266540ba
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/524296
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2022-03-24 13:54:02 +00:00 committed by SkCQ
parent 4ccb0ddcc4
commit 8bb0f47c61
8 changed files with 21 additions and 17 deletions

View File

@ -5,9 +5,6 @@ This file includes a list of high level updates for each milestone release.
Milestone 102
-------------
* Add glGetFloatv and glSamplerParameterf to GrGLInterface.
* GrContextOptions::fSharpenMipmappedTextures is ignored. MIP LOD is now always
biased on the GPU backend. The CPU backend implementation is modified to match
this behavior.
* * *

View File

@ -170,7 +170,9 @@ struct SK_API GrContextOptions {
bool fAvoidStencilBuffers = false;
/**
* Unused. The behavior that this controlled is now enabled unconditionally.
* If true, texture fetches from mip-mapped textures will be biased to read larger MIP levels.
* This has the effect of sharpening those textures, at the cost of some aliasing, and possible
* performance impact.
*/
bool fSharpenMipmappedTextures = false;

View File

@ -558,7 +558,8 @@ std::unique_ptr<GrD3DPipelineState> GrD3DPipelineStateBuilder::finalize() {
this->finalizeShaders();
SkSL::Program::Settings settings;
settings.fSharpenTextures = true;
settings.fSharpenTextures =
this->gpu()->getContext()->priv().options().fSharpenMipmappedTextures;
settings.fRTFlipOffset = fUniformHandler.getRTFlipOffset();
settings.fRTFlipBinding = 0;
settings.fRTFlipSet = 0;

View File

@ -230,7 +230,8 @@ sk_sp<GrGLProgram> GrGLProgramBuilder::finalize(const GrGLPrecompiledProgram* pr
auto errorHandler = this->gpu()->getContext()->priv().getShaderErrorHandler();
const GrGeometryProcessor& geomProc = this->geometryProcessor();
SkSL::Program::Settings settings;
settings.fSharpenTextures = true;
settings.fSharpenTextures =
this->gpu()->getContext()->priv().options().fSharpenMipmappedTextures;
settings.fFragColorIsInOut = this->fragColorIsInOut();
SkSL::Program::Inputs inputs;
@ -529,7 +530,7 @@ bool GrGLProgramBuilder::PrecompileProgram(GrDirectContext* dContext,
auto errorHandler = dContext->priv().getShaderErrorHandler();
SkSL::Program::Settings settings;
settings.fSharpenTextures = true;
settings.fSharpenTextures = dContext->priv().options().fSharpenMipmappedTextures;
GrPersistentCacheUtils::ShaderMetadata meta;
meta.fSettings = &settings;

View File

@ -543,7 +543,7 @@ GrMtlPipelineState* GrMtlPipelineStateBuilder::finalize(
this->finalizeShaders();
SkSL::Program::Settings settings;
settings.fSharpenTextures = true;
settings.fSharpenTextures = fGpu->getContext()->priv().options().fSharpenMipmappedTextures;
SkASSERT(!this->fragColorIsInOut());
SkReadBuffer reader;
@ -739,7 +739,7 @@ bool GrMtlPipelineStateBuilder::PrecompileShaders(GrMtlGpu* gpu, const SkData& c
auto errorHandler = gpu->getContext()->priv().getShaderErrorHandler();
SkSL::Program::Settings settings;
settings.fSharpenTextures = true;
settings.fSharpenTextures = gpu->getContext()->priv().options().fSharpenMipmappedTextures;
GrPersistentCacheUtils::ShaderMetadata meta;
meta.fSettings = &settings;

View File

@ -685,10 +685,12 @@ SkFilterMode downgrade_to_filter(const SkSamplingOptions& sampling) {
return filter;
}
bool can_disable_mipmap(const SkMatrix& viewM, const SkMatrix& localM) {
bool can_disable_mipmap(const SkMatrix& viewM,
const SkMatrix& localM,
bool sharpenMipmappedTextures) {
SkMatrix matrix;
matrix.setConcat(viewM, localM);
// We bias mipmap lookups by -0.5. That means our final LOD is >= 0 until
// With sharp mips, we bias lookups by -0.5. That means our final LOD is >= 0 until
// the computed LOD is >= 0.5. At what scale factor does a texture get an LOD of
// 0.5?
//
@ -697,7 +699,8 @@ bool can_disable_mipmap(const SkMatrix& viewM, const SkMatrix& localM) {
// 2^0.5 = 1/s
// 1/2^0.5 = s
// 2^0.5/2 = s
return matrix.getMinScale() >= SK_ScalarRoot2Over2;
SkScalar mipScale = sharpenMipmappedTextures ? SK_ScalarRoot2Over2 : SK_Scalar1;
return matrix.getMinScale() >= mipScale;
}
} // anonymous namespace
@ -780,7 +783,8 @@ void Device::drawImageQuad(const SkImage* image,
const SkMatrix& ctm(matrixProvider.localToDevice());
SkSamplingOptions sampling = origSampling;
if (sampling.mipmap != SkMipmapMode::kNone && can_disable_mipmap(ctm, srcToDst)) {
bool sharpenMM = fContext->priv().options().fSharpenMipmappedTextures;
if (sampling.mipmap != SkMipmapMode::kNone && can_disable_mipmap(ctm, srcToDst, sharpenMM)) {
sampling = SkSamplingOptions(sampling.filter);
}
auto clip = this->clip();

View File

@ -189,7 +189,8 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(const GrProgramDesc& desc,
SkSL::Program::Settings settings;
settings.fRTFlipBinding = this->gpu()->vkCaps().getFragmentUniformBinding();
settings.fRTFlipSet = this->gpu()->vkCaps().getFragmentUniformSet();
settings.fSharpenTextures = true;
settings.fSharpenTextures =
this->gpu()->getContext()->priv().options().fSharpenMipmappedTextures;
settings.fRTFlipOffset = fUniformHandler.getRTFlipOffset();
settings.fUsePushConstants = usePushConstants;
if (fFS.fForceHighPrecision) {

View File

@ -73,10 +73,8 @@ static void check_compressed_mipmaps(GrRecordingContext* rContext, sk_sp<SkImage
SkCanvas* canvas = surf->getCanvas();
// Given that we bias LOD selection with MIP maps, hitting a level exactly using
// SkMipmap::kLinear is difficult so we use kNearest.
const SkSamplingOptions sampling(SkFilterMode::kLinear,
SkMipmapMode::kNearest);
SkMipmapMode::kLinear);
SkPaint p;
p.setBlendMode(SkBlendMode::kSrc);