Send SDL_EVENT_WINDOW_EXPOSED when the GPU renderer swap chain is resized

In this case the current frame being rendered doesn't match the swapchain size and the application should re-render the frame.

Fixes https://github.com/libsdl-org/SDL/issues/15550
This commit is contained in:
Sam Lantinga 2026-05-29 14:33:44 -07:00
parent e04bfb4c6e
commit 2b0df96f25

View file

@ -22,6 +22,7 @@
#ifdef SDL_VIDEO_RENDER_GPU
#include "../../events/SDL_windowevents_c.h"
#include "../../video/SDL_pixels_c.h"
#include "../SDL_d3dmath.h"
#include "../SDL_sysrender.h"
@ -1517,6 +1518,9 @@ static bool GPU_RenderPresent(SDL_Renderer *renderer)
if (swapchain_texture_width != data->backbuffer.width || swapchain_texture_height != data->backbuffer.height) {
CreateBackbuffer(data, swapchain_texture_width, swapchain_texture_height, SDL_GetGPUSwapchainTextureFormat(data->device, renderer->window));
// Notify the application that it needs to redraw this frame
SDL_SendWindowEvent(renderer->window, SDL_EVENT_WINDOW_EXPOSED, 0, 0);
}
} else {
SDL_SubmitGPUCommandBuffer(data->state.command_buffer);