Upload the menu's font atlas through the runtime's upload batch, checked, instead of Dear ImGui's own upload.

ImGui_ImplVulkan_CreateFontsTexture checked no result: with the video memory full, the atlas a window size change
makes again got no memory, its copy still went out, and the GPU wrote to address 0 (issue #165, device lost after
Alt+Tab). It also submitted and waited on the game's queue itself, and when ImGui_ImplVulkan_NewFrame ran it (whenever
the back end held no atlas) that took no queue lock, beside the game's own submissions; the crashes in AMD's driver
inside the menu's drawing (issue #230) fit that. ui/menu_art.cpp menu_font_upload now uploads the atlas as the menu's
art is uploaded: VMA picks the memory (device-local, else what is left), the copy goes in the runtime's upload batch
under the queue lock, every step is checked, and the previous atlas is freed only once the new one is on the GPU and
the queue is idle. The menu no longer calls ImGui_ImplVulkan_NewFrame, whose only work was that upload. The back end's
VkResults are checked and logged (menu_vk_check), a texture whose descriptor set was not allocated is not drawn with,
and the descriptor pool holds 32 sets, room for two atlases while one replaces the other.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-09 13:10:47 -05:00
parent 7a60f4e2a0
commit 9c10827018
3 changed files with 94 additions and 24 deletions

View File

@@ -25,7 +25,12 @@ extern "C" void menu_art_start(void); // decodes the textures on a worker, on
// The texture for the menu's draw lists and its size in pixels; 0 while it is not there (still decoding, or absent).
// Window thread: the first call for an art uploads it.
extern "C" int menu_art(MenuArt id, ImTextureID *tex, float *w, float *h);
extern "C" void menu_art_release(void); // before ImGui's Vulkan back end shuts down
extern "C" void menu_art_release(void); // before ImGui's Vulkan back end shuts down; the font atlas goes too
// The font atlas's pixels (w x h, RGBA) as a texture for the draw lists in *tex; 0 when it could not be made, the previous
// atlas then kept. The previous one is freed once the queue has finished with it.
extern "C" int menu_font_upload(const unsigned char *rgba, int w, int h, ImTextureID *tex);
// Results other than VK_SUCCESS that Dear ImGui's Vulkan back end reported so far (ui/menu.cpp menu_vk_check).
extern "C" int menu_vk_errors(void);
// Draws an art stretched over [a, b] with a tint; 0 (nothing drawn) while it is not there.
extern "C" int menu_art_draw(ImDrawList *dl, MenuArt id, ImVec2 a, ImVec2 b, ImU32 tint);
// Draws an art as nine pieces: corners `corner` pixels on screen from the outer `frac` of the texture, edges stretched,