33// found in the LICENSE file.
44
55#include " impeller/renderer/backend/gles/sampler_gles.h"
6+ #include < iostream>
67
78#include " impeller/renderer/backend/gles/formats_gles.h"
89#include " impeller/renderer/backend/gles/proc_table_gles.h"
@@ -19,15 +20,19 @@ bool SamplerGLES::IsValid() const {
1920 return true ;
2021}
2122
22- static GLint ToParam (MinMagFilter minmag_filter, MipFilter mip_filter) {
23- switch (mip_filter) {
24- case MipFilter::kNone :
25- switch (minmag_filter) {
26- case MinMagFilter::kNearest :
27- return GL_NEAREST;
28- case MinMagFilter::kLinear :
29- return GL_LINEAR;
30- }
23+ static GLint ToParam (MinMagFilter minmag_filter,
24+ std::optional<MipFilter> mip_filter = std::nullopt ) {
25+ if (!mip_filter.has_value ()) {
26+ switch (minmag_filter) {
27+ case MinMagFilter::kNearest :
28+ return GL_NEAREST;
29+ case MinMagFilter::kLinear :
30+ return GL_LINEAR;
31+ }
32+ FML_UNREACHABLE ();
33+ }
34+
35+ switch (mip_filter.value ()) {
3136 case MipFilter::kNearest :
3237 switch (minmag_filter) {
3338 case MinMagFilter::kNearest :
@@ -69,12 +74,17 @@ bool SamplerGLES::ConfigureBoundTexture(const TextureGLES& texture,
6974 if (!target.has_value ()) {
7075 return false ;
7176 }
72-
7377 const auto & desc = GetDescriptor ();
78+
79+ std::optional<MipFilter> mip_filter = std::nullopt ;
80+ if (texture.GetTextureDescriptor ().mip_count > 1 ) {
81+ mip_filter = desc.mip_filter ;
82+ }
83+
7484 gl.TexParameteri (target.value (), GL_TEXTURE_MIN_FILTER,
75- ToParam (desc.min_filter , desc. mip_filter ));
85+ ToParam (desc.min_filter , mip_filter));
7686 gl.TexParameteri (target.value (), GL_TEXTURE_MAG_FILTER,
77- ToParam (desc.mag_filter , MipFilter:: kNone ));
87+ ToParam (desc.mag_filter ));
7888 gl.TexParameteri (target.value (), GL_TEXTURE_WRAP_S,
7989 ToAddressMode (desc.width_address_mode ));
8090 gl.TexParameteri (target.value (), GL_TEXTURE_WRAP_T,
0 commit comments