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

Reduce Waddy RAM usage #11

Open
khanghugo opened this issue Sep 17, 2024 · 2 comments
Open

Reduce Waddy RAM usage #11

khanghugo opened this issue Sep 17, 2024 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@khanghugo
Copy link
Owner

khanghugo commented Sep 17, 2024

Right now, it should use 2*n RAM because

  1. Waddy instance has WAD file data and
  2. texture data for rendering

For some reasons, it is 4*n now. Maybe impl Drop?

@khanghugo khanghugo changed the title Reduces Waddy RAM usage Reduce Waddy RAM usage Sep 17, 2024
@khanghugo khanghugo added bug Something isn't working help wanted Extra attention is needed labels Sep 17, 2024
@khanghugo
Copy link
Owner Author

It seems like this is where the issue comes from

let texture_tiles = waddy
.wad()
.entries
.iter()
.enumerate()
.filter_map(|(index, entry)| {
if let FileEntry::MipTex(miptex) = &entry.file_entry {
let wad_image = WadImage::from_wad_image(
ui,
entry.directory_entry.texture_name.get_string(),
miptex.mip_images[0].data.get_bytes(),
miptex.palette.get_bytes(),
(miptex.width, miptex.height),
);
return Some(TextureTile::new(index, wad_image));
// None
}
None
})
.collect::<Vec<TextureTile>>();

egui::TextureHandle does have impl Drop and GPU memory does decrease when the image is dropped. But it still uses too much.

@khanghugo
Copy link
Owner Author

After some investigations, I have missed something fairly simple, the textures are stored as RGBA8 in memory. For a 1000 512x512 WAD file, it requires at least 750MB of RAM to store them. So I guess the behavior should be expected.

Recently, I have tried out iced and have a WIP Waddy. It seems like it uses a lot less RAM. One thing that I have overlooked is VRAM usage and iced version does use less VRAM as well.

A possible rewrite of gchimp-native under iced is considered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant