Always blit to the swapchain in GPU_RenderPresent

Fixes #10744
This commit is contained in:
cosmonaut 2024-09-07 08:43:02 -07:00
parent fa892d15b7
commit 1a13acac09
2 changed files with 14 additions and 26 deletions

View File

@ -1,4 +1,4 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>

View File

@ -965,8 +965,6 @@ static bool GPU_RenderPresent(SDL_Renderer *renderer)
} }
SDL_GPUTextureFormat swapchain_fmt = SDL_GetGPUSwapchainTextureFormat(data->device, renderer->window); SDL_GPUTextureFormat swapchain_fmt = SDL_GetGPUSwapchainTextureFormat(data->device, renderer->window);
if (swapchain_w != data->backbuffer.width || swapchain_h != data->backbuffer.height || swapchain_fmt != data->backbuffer.format) {
SDL_GPUBlitRegion src; SDL_GPUBlitRegion src;
SDL_zero(src); SDL_zero(src);
src.texture = data->backbuffer.texture; src.texture = data->backbuffer.texture;
@ -980,20 +978,10 @@ static bool GPU_RenderPresent(SDL_Renderer *renderer)
dst.h = swapchain_h; dst.h = swapchain_h;
SDL_BlitGPUTexture(data->state.command_buffer, &src, &dst, SDL_FLIP_NONE, SDL_GPU_FILTER_LINEAR, true); SDL_BlitGPUTexture(data->state.command_buffer, &src, &dst, SDL_FLIP_NONE, SDL_GPU_FILTER_LINEAR, true);
if (swapchain_w != data->backbuffer.width || swapchain_h != data->backbuffer.height || swapchain_fmt != data->backbuffer.format) {
SDL_ReleaseGPUTexture(data->device, data->backbuffer.texture); SDL_ReleaseGPUTexture(data->device, data->backbuffer.texture);
CreateBackbuffer(data, swapchain_w, swapchain_h, swapchain_fmt); CreateBackbuffer(data, swapchain_w, swapchain_h, swapchain_fmt);
} else {
SDL_GPUTextureLocation src;
SDL_zero(src);
src.texture = data->backbuffer.texture;
SDL_GPUTextureLocation dst;
SDL_zero(dst);
dst.texture = swapchain;
SDL_GPUCopyPass *pass = SDL_BeginGPUCopyPass(data->state.command_buffer);
SDL_CopyGPUTextureToTexture(pass, &src, &dst, swapchain_w, swapchain_h, 1, true);
SDL_EndGPUCopyPass(pass);
} }
// *** FIXME *** // *** FIXME ***