--- a/RSDKv5/RSDK/Graphics/SDL2/SDL2RenderDevice.cpp
+++ b/RSDKv5/RSDK/Graphics/SDL2/SDL2RenderDevice.cpp
@@ -413,11 +413,16 @@
// ignore the last 6 verts, they're scaled to the 1024x512 textures already!
int32 vertCount = (RETRO_REV02 ? 60 : 24) - 6;
+ // The renderer's logical size is now the window size (see InitGraphicsAPI), so the
+ // output quad has to be de-normalized against the window instead of pixWidth/SCREEN_YSIZE.
+ float outputW = viewSize.x > 0 ? viewSize.x : (float)videoSettings.pixWidth;
+ float outputH = viewSize.y > 0 ? viewSize.y : (float)SCREEN_YSIZE;
+
// Regular in-game screen de-normalization stuff
for (int32 v = 0; v < vertCount; ++v) {
RenderVertex *vertex = &vertBuffer[v];
- vertex->pos.x = NORMALIZE(vertex->pos.x, -1.0, 1.0) * videoSettings.pixWidth;
- vertex->pos.y = (1.0 - NORMALIZE(vertex->pos.y, -1.0, 1.0)) * SCREEN_YSIZE;
+ vertex->pos.x = NORMALIZE(vertex->pos.x, -1.0, 1.0) * outputW;
+ vertex->pos.y = (1.0 - NORMALIZE(vertex->pos.y, -1.0, 1.0)) * outputH;
if (vertex->tex.x)
vertex->tex.x = screens[0].size.x * (1.0 / textureSize.x);
@@ -429,8 +434,8 @@
// Fullscreen Image/Video de-normalization stuff
for (int32 v = 0; v < 6; ++v) {
RenderVertex *vertex = &vertBuffer[vertCount + v];
- vertex->pos.x = NORMALIZE(vertex->pos.x, -1.0, 1.0) * videoSettings.pixWidth;
- vertex->pos.y = (1.0 - NORMALIZE(vertex->pos.y, -1.0, 1.0)) * SCREEN_YSIZE;
+ vertex->pos.x = NORMALIZE(vertex->pos.x, -1.0, 1.0) * outputW;
+ vertex->pos.y = (1.0 - NORMALIZE(vertex->pos.y, -1.0, 1.0)) * outputH;
// Set the texture to fill the entire screen with all 1024x512 pixels
if (vertex->tex.x)
@@ -509,7 +514,22 @@
pixelSize.x = screens[0].size.x;
pixelSize.y = screens[0].size.y;
- SDL_RenderSetLogicalSize(renderer, videoSettings.pixWidth, SCREEN_YSIZE);
+ // Use the window size as the renderer's logical size rather than pixWidth x SCREEN_YSIZE.
+ //
+ // libTAS overrides SDL_RenderSetLogicalSize() and, instead of forwarding it to SDL, resizes
+ // the game window to whatever logical size it is given ("don't let the game have a logical
+ // size that differs from screen size"). With the old call that snapped the window back to
+ // 424x240 while the SDL renderer's viewport was still the size we had just asked for, and
+ // libTAS then read back a full-size frame into a 424x240 capture buffer -> instant crash as
+ // soon as a window larger than 424x240 was requested.
+ //
+ // Keeping logical size == window size makes that override a no-op, and the output quad is
+ // scaled to the window in InitVertexBuffer() instead.
+ if (viewSize.x > 0 && viewSize.y > 0)
+ SDL_RenderSetLogicalSize(renderer, (int32)viewSize.x, (int32)viewSize.y);
+ else
+ SDL_RenderSetLogicalSize(renderer, videoSettings.pixWidth, SCREEN_YSIZE);
+
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
#if !RETRO_USE_ORIGINAL_CODE