fix(font-atlas): the atlas destroys its image

FontAtlas::Initialize creates an ImageVulkan and nothing ever called its
Destroy(): every atlas left its 1024x1024 image, memory and view behind.
The atlas now owns the image for its lifetime and is no longer copyable.
ImageVulkan's handles start as VK_NULL_HANDLE and Destroy() resets them,
so an atlas that was never initialised, or an image destroyed by hand
before the atlas goes, is a no-op in the destructor.

The owner waits for the GPU before the atlas goes and, in sets mode,
destroys the descriptor heap that holds the image's view before the atlas.
This commit is contained in:
Jorijn van der Graaf 2026-10-18 01:12:21 +02:00
commit b16f1e99d5
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
2 changed files with 18 additions and 3 deletions

View file

@ -96,6 +96,18 @@ export namespace Crafter {
bool dirty = false;
DirtyRect dirtyRect;
#ifndef CRAFTER_GRAPHICS_WINDOW_DOM
FontAtlas() = default;
FontAtlas(const FontAtlas&) = delete;
FontAtlas& operator=(const FontAtlas&) = delete;
// The image goes with the atlas. The owner waits for the GPU first
// and, in sets mode, destroys the heap holding the image's view before
// the atlas.
~FontAtlas() {
if (image.image != VK_NULL_HANDLE) image.Destroy();
}
#endif
void Initialize(GraphicsCommandBuffer cmd);
// Returns the row-major byte pointer the CPU writes pixels into.