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

Clear the texture atlas of unloaded textures to reduce VRAM usage. #2675

Open
djmrFunnyMan opened this issue Aug 16, 2024 · 3 comments
Open
Labels
A-vanilla-issue Area: Vanilla issue F-good-first-issue Flag: Good first issue for new contributors T-enhancement Type: Enhancement

Comments

@djmrFunnyMan
Copy link

Bug Description

This is a vanilla bug which was marked as won't fix (MC-263119)
I described it in a duplicate issue MC-274736 which is where I will be getting the reproduction steps from.

Basically even after removing a rsp, minecraft will keep the textures in the atlas and won't shrink the dimensions of the atlas either. This will cause excessive and unnecessary VRAM usage if you're frequently loading and unloading texture packs (particularly high res ones)

Reproduction Steps

  • Save the atlas by pressing F3 + S
  • Load this texture pack (generate it from this txt on vanilla tweaks website first selected packs)
  • Unload this pack (go back to vanilla textures)
  • Save the atlas again and view it

You will notice the following:

  • Non vanilla textures are still present in the atlas
  • Various vanilla textures have been duplicated
  • The atlas is keeps its expanded dimensions

Before:
minecraft_textures_atlas_blocks png_0_before
After:
minecraft_textures_atlas_blocks png_0_after

Log File

Not relevant

Crash Report

Not relevant

@djmrFunnyMan djmrFunnyMan added the S-needs-triage Status: Needs triage label Aug 16, 2024
@jellysquid3 jellysquid3 added T-enhancement Type: Enhancement F-good-first-issue Flag: Good first issue for new contributors A-vanilla-issue Area: Vanilla issue and removed S-needs-triage Status: Needs triage labels Aug 16, 2024
@PepperCode1
Copy link
Contributor

After looking at the code of TextureAtlas, it seems like this issue is actually a driver bug or optimization, which is why the Mojira report was marked as won't fix. The code always calls glTexImage2D on all mip levels of the atlas texture before populating it with sprites, but since all parameters except the width and height stay the same, the driver may have an optimization to not reallocate the texture if it is already allocated with dimensions that are greater than or equal to the given dimensions.

@djmrFunnyMan
Copy link
Author

Well even if this is the case (which it might not be) it would only prevent you from shrinking the atlas dimensions, not from clearing the excess textures.

@PepperCode1
Copy link
Contributor

The excess textures don't affect performance or memory usage so it doesn't matter if they are cleared or not. The dimensions definitely affect memory usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-vanilla-issue Area: Vanilla issue F-good-first-issue Flag: Good first issue for new contributors T-enhancement Type: Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants