Make sure the palette is no longer in use before freeing it in the Vulkan renderer

Fixes https://github.com/libsdl-org/SDL/issues/16283
This commit is contained in:
Sam Lantinga
2026-09-10 12:18:40 -07:00
parent e05eb27f2c
commit 04b2fb8046

View File

@@ -2638,10 +2638,17 @@ static void VULKAN_DestroyPalette(SDL_Renderer *renderer, SDL_TexturePalette *pa
VULKAN_RenderData *data = (VULKAN_RenderData *)renderer->internal;
VULKAN_PaletteData *palettedata = (VULKAN_PaletteData *)palette->internal;
if (palettedata) {
VULKAN_DestroyImage(data, &palettedata->image);
SDL_free(palettedata);
if (!palettedata) {
return;
}
/* Because VULKAN_DestroyPalette might be called while the data is in-flight, we need to issue the batch first
Unfortunately, this means that deleting a lot of palettes mid-frame will have poor performance. */
VULKAN_IssueBatch(data);
VULKAN_WaitForGPU(data);
VULKAN_DestroyImage(data, &palettedata->image);
SDL_free(palettedata);
}
static bool VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)