Open lordmauve opened 4 years ago
From #2, large NPOT textures are never deallocated. If we can track which textures have not been recently referenced (eg. a generational approach) then we can simply remove these textures from cache.
NB since #24 this issue becomes a lot easier:
To actually repack we would need to visit users of each texture region and update them with the new region. An alternative would be to maintain a texture containing the "table of contents" for an atlas, and users of a texture region simply have indexes into this. Repacking textures can thus be done by rewriting the TOC. We could then track users of a texture region by refcounting alone.
Rather than a texture, we can pass the allocations to the vertex shader in a UBO.
When building texture atlases, sprite data is uploaded from system memory.
Sprites that are unused after a long time are not currently deleted. It would be possible to "garbage collect" sprites - perhaps periodically or as a function that users can call. To release texture memory this could rebuild the atlas with sprites to keep.
However, at this point, the sprite data is on the GPU already. A new texture can be built by drawing the old sprites into their new locations - essentially by drawing them as sprites into a new texture.