Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jonahwilliams
Copy link
Contributor

On iOS devices that support this (apple8+), this dramatically reduces memory usage.

Wonderous after swiping through all wonders at ToT:

image

Wonderous after swiping through all wonders with patch:

image

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@jonahwilliams jonahwilliams changed the title [impeller] use lossy texture compression on iOS [impeller] use lossy texture compression on iOS for decode images and MSAA resolve textures Mar 22, 2023
texture_descriptor.format = pixel_format.value();
texture_descriptor.size = {image_info.width(), image_info.height()};
texture_descriptor.mip_count = texture_descriptor.size.MipCount();
texture_descriptor.compression_type = impeller::CompressionType::kLossy;
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be really unhappy for photos, especially if they're wide gamut.

Some people might not care but we probably need a flag of some sort to control whether you get this or not, at the very least for images.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The images I've checked look identical with this flag on/off. Do you have any particular ones in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

@gaaclarke probably has some from the wide gamut work

Copy link
Member

Choose a reason for hiding this comment

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

Flutter gallery has some photographs that are in the adobergb colorspace you can test with those. Also it's worth verifying that it doesn't mess up the gamut, there is an integration test in //flutter/dev/integration_tests/wide_gamut_test/.

Usually where these compression problems come into play in games isn't complex images but really simple images like pixel art. Unity defaults to compressed textures but you have to turn them off frequently if you are using simple images.

Copy link
Contributor

Choose a reason for hiding this comment

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

As a stopgap, maybe this should only apply to images that come from a lossless image decoder (e.g. PNG, BMP, lossless WEBP, raw rgba).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're not aware of any circumstances where this causes any loss in fidelity

@chinmaygarde chinmaygarde changed the title [impeller] use lossy texture compression on iOS for decode images and MSAA resolve textures [Impeller] use lossy texture compression on iOS for decode images and MSAA resolve textures. Mar 22, 2023
Copy link
Contributor

@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.

IMO, we should have this on by default and assess opportunities where we need configurability.

We already massage the image usage to make sure we opt into lossless compression. While lossless compression is great for bandwidth savings, there are usually (at least with Metal) no memory savings because Metal cannot guarantee any savings without compression and so must allocate an arena big enough for the entire uncompressed texture. In most cases, this is this bigger arena is wasted. We can observe this by comparing the results of lossy vs lossless compression to see cases where they are identical.

Compression doesn't necessarily mean a reduction in gamut so I wouldn't expect wide-gamut images to be uniquely affected by this but we should definitely eyeball the existing test.

I like this change also because this is yet another guard against accidentally messing up the flags that kick us out of lossless compression and cause us to take a bandwidth hit. I care way more about memory bandwidth for our use case that memory (power usage, heat, etc..).

We can file a followup issue to catalog cases where this compression is causing significant deviation from developer intent. My sense is that this is the right thing to do for intermediate and final render targets. But I have no evidence that points to cases where we shouldn't enable this globally.

@chinmaygarde
Copy link
Contributor

Are we going to land this before the release train?

@jonahwilliams
Copy link
Contributor Author

I'm OK with landing this now

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller needs tests

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants