From cae5fd8ba66788295432ed9a5f3be6ee5d732580 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Sat, 18 Mar 2023 11:26:33 -0700 Subject: [PATCH] [Impeller] Don't mip filter TextureFilterInput snapshots when there's no mipmap (flutter/engine#40425) [Impeller] Don't mip filter TextureFilterInput snapshots when there's no mipmap --- .../contents/filters/inputs/texture_filter_input.cc | 10 +++++++++- engine/src/flutter/impeller/renderer/snapshot.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/impeller/entity/contents/filters/inputs/texture_filter_input.cc b/engine/src/flutter/impeller/entity/contents/filters/inputs/texture_filter_input.cc index 09a393bc51..b64a78a349 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/inputs/texture_filter_input.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/inputs/texture_filter_input.cc @@ -6,6 +6,8 @@ #include +#include "impeller/renderer/formats.h" + namespace impeller { TextureFilterInput::TextureFilterInput(std::shared_ptr texture, @@ -21,7 +23,13 @@ FilterInput::Variant TextureFilterInput::GetInput() const { std::optional TextureFilterInput::GetSnapshot( const ContentContext& renderer, const Entity& entity) const { - return Snapshot{.texture = texture_, .transform = GetTransform(entity)}; + auto snapshot = + Snapshot{.texture = texture_, .transform = GetTransform(entity)}; + if (texture_->GetMipCount() > 1) { + snapshot.sampler_descriptor.label = "TextureFilterInput Trilinear Sampler"; + snapshot.sampler_descriptor.mip_filter = MipFilter::kLinear; + } + return snapshot; } std::optional TextureFilterInput::GetCoverage( diff --git a/engine/src/flutter/impeller/renderer/snapshot.h b/engine/src/flutter/impeller/renderer/snapshot.h index 41ad407144..4820447359 100644 --- a/engine/src/flutter/impeller/renderer/snapshot.h +++ b/engine/src/flutter/impeller/renderer/snapshot.h @@ -30,7 +30,7 @@ struct Snapshot { SamplerDescriptor("Default Snapshot Sampler", MinMagFilter::kLinear, MinMagFilter::kLinear, - MipFilter::kLinear); + MipFilter::kNone); Scalar opacity = 1.0f;