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>
This commit is contained in:
parent
098f9a6785
commit
1aedd5dc11
@ -5,6 +5,9 @@ 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.
|
||||
|
||||
* * *
|
||||
|
||||
|
@ -170,9 +170,7 @@ struct SK_API GrContextOptions {
|
||||
bool fAvoidStencilBuffers = false;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Unused. The behavior that this controlled is now enabled unconditionally.
|
||||
*/
|
||||
bool fSharpenMipmappedTextures = false;
|
||||
|
||||
|
@ -558,8 +558,7 @@ std::unique_ptr<GrD3DPipelineState> GrD3DPipelineStateBuilder::finalize() {
|
||||
this->finalizeShaders();
|
||||
|
||||
SkSL::Program::Settings settings;
|
||||
settings.fSharpenTextures =
|
||||
this->gpu()->getContext()->priv().options().fSharpenMipmappedTextures;
|
||||
settings.fSharpenTextures = true;
|
||||
settings.fRTFlipOffset = fUniformHandler.getRTFlipOffset();
|
||||
settings.fRTFlipBinding = 0;
|
||||
settings.fRTFlipSet = 0;
|
||||
|
@ -230,8 +230,7 @@ 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 =
|
||||
this->gpu()->getContext()->priv().options().fSharpenMipmappedTextures;
|
||||
settings.fSharpenTextures = true;
|
||||
settings.fFragColorIsInOut = this->fragColorIsInOut();
|
||||
|
||||
SkSL::Program::Inputs inputs;
|
||||
@ -530,7 +529,7 @@ bool GrGLProgramBuilder::PrecompileProgram(GrDirectContext* dContext,
|
||||
auto errorHandler = dContext->priv().getShaderErrorHandler();
|
||||
|
||||
SkSL::Program::Settings settings;
|
||||
settings.fSharpenTextures = dContext->priv().options().fSharpenMipmappedTextures;
|
||||
settings.fSharpenTextures = true;
|
||||
GrPersistentCacheUtils::ShaderMetadata meta;
|
||||
meta.fSettings = &settings;
|
||||
|
||||
|
@ -543,7 +543,7 @@ GrMtlPipelineState* GrMtlPipelineStateBuilder::finalize(
|
||||
this->finalizeShaders();
|
||||
|
||||
SkSL::Program::Settings settings;
|
||||
settings.fSharpenTextures = fGpu->getContext()->priv().options().fSharpenMipmappedTextures;
|
||||
settings.fSharpenTextures = true;
|
||||
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 = gpu->getContext()->priv().options().fSharpenMipmappedTextures;
|
||||
settings.fSharpenTextures = true;
|
||||
GrPersistentCacheUtils::ShaderMetadata meta;
|
||||
meta.fSettings = &settings;
|
||||
|
||||
|
@ -685,12 +685,10 @@ SkFilterMode downgrade_to_filter(const SkSamplingOptions& sampling) {
|
||||
return filter;
|
||||
}
|
||||
|
||||
bool can_disable_mipmap(const SkMatrix& viewM,
|
||||
const SkMatrix& localM,
|
||||
bool sharpenMipmappedTextures) {
|
||||
bool can_disable_mipmap(const SkMatrix& viewM, const SkMatrix& localM) {
|
||||
SkMatrix matrix;
|
||||
matrix.setConcat(viewM, localM);
|
||||
// With sharp mips, we bias lookups by -0.5. That means our final LOD is >= 0 until
|
||||
// We bias mipmap 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?
|
||||
//
|
||||
@ -699,8 +697,7 @@ bool can_disable_mipmap(const SkMatrix& viewM,
|
||||
// 2^0.5 = 1/s
|
||||
// 1/2^0.5 = s
|
||||
// 2^0.5/2 = s
|
||||
SkScalar mipScale = sharpenMipmappedTextures ? SK_ScalarRoot2Over2 : SK_Scalar1;
|
||||
return matrix.getMinScale() >= mipScale;
|
||||
return matrix.getMinScale() >= SK_ScalarRoot2Over2;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
@ -783,8 +780,7 @@ void Device::drawImageQuad(const SkImage* image,
|
||||
const SkMatrix& ctm(matrixProvider.localToDevice());
|
||||
|
||||
SkSamplingOptions sampling = origSampling;
|
||||
bool sharpenMM = fContext->priv().options().fSharpenMipmappedTextures;
|
||||
if (sampling.mipmap != SkMipmapMode::kNone && can_disable_mipmap(ctm, srcToDst, sharpenMM)) {
|
||||
if (sampling.mipmap != SkMipmapMode::kNone && can_disable_mipmap(ctm, srcToDst)) {
|
||||
sampling = SkSamplingOptions(sampling.filter);
|
||||
}
|
||||
auto clip = this->clip();
|
||||
|
@ -189,8 +189,7 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(const GrProgramDesc& desc,
|
||||
SkSL::Program::Settings settings;
|
||||
settings.fRTFlipBinding = this->gpu()->vkCaps().getFragmentUniformBinding();
|
||||
settings.fRTFlipSet = this->gpu()->vkCaps().getFragmentUniformSet();
|
||||
settings.fSharpenTextures =
|
||||
this->gpu()->getContext()->priv().options().fSharpenMipmappedTextures;
|
||||
settings.fSharpenTextures = true;
|
||||
settings.fRTFlipOffset = fUniformHandler.getRTFlipOffset();
|
||||
settings.fUsePushConstants = usePushConstants;
|
||||
if (fFS.fForceHighPrecision) {
|
||||
|
@ -73,8 +73,10 @@ 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::kLinear);
|
||||
SkMipmapMode::kNearest);
|
||||
SkPaint p;
|
||||
p.setBlendMode(SkBlendMode::kSrc);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user