Godot Version
4.3
Question
Please correct me if I am wrong.
From what I understand, when you load a texture into vram, it will be put into a contiguous space.
If certain textures got unloaded, the space that was occupied before will now be empty. However, this leaves gaps between other textures that do not get unloaded.
As the game runs further, the player could be going into new areas or meet new objects which require loading the respective textures into vram. During loading the textures, the system will try to fit the textures into contiguous spaces.
But as the player play the game further and further, having more loading and unloading would lead to more fragmentation if the game is the type that loads and unloads on the fly.
Because of this, here are my questions:
-
How does the engine manage which position on vram to put the texture on? For example, suppose we have a 1 GB VRAM and we just started the game and we are about to load our very first texture, we allocate a 10 MB texture, will the engine put this in the first byte of VRAM up to the 10Mth byte or does it have its own process knowing which range of bytes on vram are empty and it will put textures that it thinks is the best position?
-
In our Godot code, we simply load and unload the textures, but can we do anything about fragmentation if it occurs? For example, if I have a loading screen in the game that deallocate all textures and re-allocate only the textures that will definitely be used back, will this solve fragmentation?
-
In Godot, what would be a proper way to manage this?