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

Displaying a layered character portrait greatly spikes VRAM usage #2525

Open
Galo223344 opened this issue Feb 6, 2025 · 0 comments
Open
Labels
Approved This can be added, but is not on any roadmap yet

Comments

@Galo223344
Copy link

Galo223344 commented Feb 6, 2025

Layered portraits load all it's variants into memory causing a huge spike in vram when one is displayed

Describe the bug
To display a layered portrait, Dialogic uses a scene that contains all the layers as children. The issue is that when this scene is loaded, every child is loaded into memory, even if it’s not used. Since textures are stored uncompressed in VRAM (by default), showing a default idle character causes VRAM usage to spike by about 500 MB (all the elements in our portraits are 1800x2500 for easy layering). This means that having two of these layered characters on screen uses roughly a gigabyte of VRAM just for portraits, which is unacceptable. This also causes a huge lag spike for people running on low end devices, especially people using integrated graphics which have notoriously low video memory, this might be related to #2354

To Reproduce
Steps to reproduce the behavior:

  1. Create a layered character with different options.
  2. Display one of the options.
  3. In the Godot editor while the game is running go to Debugger > Video Ram.
  4. Observe that all the options are loaded into memory, bloating it.

Expected behavior
If the neutral emotion is displayed only the elements needed to display that neutral emotion should be loaded into memory

Screenshots
Screenshot from the Video Ram section inside Godot, only her neutral expression is used but the rest are loaded anyways

Image

System (please complete the following information):

  • OS: Windows
  • Godot Version: 4.3 Stable
  • Dialogic Version: 2.0 Alpha 15

Solutions

Workaround

Enabling vram compression for the assets does reduce the vram usage and mitigates the slow down when a character is displayed on screen but it also reduces the quality of the images which is not acceptable.

Possible fixes

Due to the whole "loading a scene also loads all it's children and textures" being behavior that comes with Godot this issue might not be easy to tackle, one solution I have in mind would be to store the layer information inside the dialogic character and then have Dialogic add the children for the screen of the portrait as different emotions/options are requested while freeing the old ones (instead of just hiding them, which still keeps them in memory)

@Jowan-Spooner Jowan-Spooner added the Approved This can be added, but is not on any roadmap yet label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved This can be added, but is not on any roadmap yet
Development

No branches or pull requests

2 participants