Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Impeller] change default sampler descriptor to use nearest mip level and remove kNone #40460

Conversation

jonahwilliams
Copy link
Member

By default we create mipmaps for every decoded image. Choosing the nearest mip level is the only reasonable default.

Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the more accurate default. If there is only one mip level, then the nearest mip index should be zero. I can't think of any other case where we'd need to have mip levels but always sample from zero. Makes me wonder why @bdero preferred trilinear filtering here https://github.com/flutter/engine/pull/40425/files though. So he may have additional context.

@chinmaygarde
Copy link
Member

Ok, we should remove MipFilter::kNone altogether. It is not supported in Vulkan either.

@jonahwilliams jonahwilliams changed the title [Impeller] change default sampler descriptor to use nearest mip level [Impeller] change default sampler descriptor to use nearest mip level and remove kNone Mar 20, 2023
@@ -74,7 +67,7 @@ bool SamplerGLES::ConfigureBoundTexture(const TextureGLES& texture,
gl.TexParameteri(target.value(), GL_TEXTURE_MIN_FILTER,
ToParam(desc.min_filter, desc.mip_filter));
gl.TexParameteri(target.value(), GL_TEXTURE_MAG_FILTER,
ToParam(desc.mag_filter, MipFilter::kNone));
ToParam(desc.mag_filter, MipFilter::kNearest));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chinmaygarde what is this supposed to be? This line seems sus before

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was patched by @bdero in 4becf4942e8. Looking closer.

Copy link
Member

@bdero bdero Mar 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why I changed this when landing the blit pass... This might be debugging leftovers. I'd try changing it back and seeing if Play/RendererTest.CanGenerateMipmaps/OpenGLES is broken once this is addressed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just reread this and realized kNone is actually correct here because of #40460 (comment)

@@ -21,13 +21,6 @@ bool SamplerGLES::IsValid() const {

static GLint ToParam(MinMagFilter minmag_filter, MipFilter mip_filter) {
switch (mip_filter) {
case MipFilter::kNone:
Copy link
Member

@bdero bdero Mar 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think sampling with GL_[NEAREST|LINEAR]_MIPMAP_[NEAREST|LINEAR] will fail in GLES if the mip count is 1, and either GL_NEAREST or GL_LINEAR needs to be set when this is the case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please verify that this doesn't break the GLES playgrounds if landing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can retain this behavior for now without the enum variant. Make the mip_filter optional and treat nullopt as if it were none.

Copy link
Member

@bdero bdero Mar 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to be addressed for the min filter. Right now, if a texture has a mip count of 1 (as all subpass and filter-created textures do), it will get a min filter that includes mipmap sampling. This will fail and sample with all zeros on some drivers:
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh yeah, got it

Copy link
Member

@bdero bdero Mar 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The capture above is Play/DisplayListTest.CanDrawBackdropFilter/OpenGLES, which was rendering nothing a couple of days ago on both M1 Mac and the Windows Nvidia driver prior to this fix: https://github.com/flutter/engine/pull/40425/files

Copy link
Member

@bdero bdero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 21, 2023
@auto-submit auto-submit bot merged commit ba6e762 into flutter:main Mar 21, 2023
36 checks passed
jonahwilliams added a commit that referenced this pull request Mar 21, 2023
auto-submit bot pushed a commit that referenced this pull request Mar 21, 2023
…ip level and remove kNone (#40460)" (#40481)

Revert "[Impeller] change default sampler descriptor to use nearest mip level and remove kNone"
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App
Projects
None yet
3 participants