Do not reset the renderer on SDL_RENDER_TARGETS_RESET

We only need to do this on a SDL_RENDER_DEVICE_RESET where we lose the whole device.

This also reverts a56efe5 since this change is not needed when handling the reset events properly.
This commit is contained in:
Cameron Gutman
2026-01-31 13:00:23 -06:00
parent a2122e17c6
commit 5020fc6f48
6 changed files with 15 additions and 17 deletions

View File

@@ -2156,7 +2156,6 @@ void Session::exec()
// Fall through
case SDL_RENDER_DEVICE_RESET:
case SDL_RENDER_TARGETS_RESET:
if (event.type != SDL_WINDOWEVENT) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
@@ -2182,6 +2181,12 @@ void Session::exec()
updateOptimalWindowDisplayMode();
}
// Now that the old decoder is dead, flush any events it may
// have queued to reset itself (if this reset was the result
// of device loss or an internal error).
SDL_PumpEvents();
SDL_FlushEvent(SDL_RENDER_DEVICE_RESET);
{
// If the stream exceeds the display refresh rate (plus some slack),
// forcefully disable V-sync to allow the stream to render faster
@@ -2219,13 +2224,6 @@ void Session::exec()
}
}
// Flush any events queued by the renderer to reset itself. These are
// usually from the old renderer, but they can also be queued by the
// new renderer in certain cases (like SDL3's direct3d9 renderer).
SDL_PumpEvents();
SDL_FlushEvent(SDL_RENDER_DEVICE_RESET);
SDL_FlushEvent(SDL_RENDER_TARGETS_RESET);
// Request an IDR frame to complete the reset
LiRequestIdrFrame();

View File

@@ -803,7 +803,7 @@ void D3D11VARenderer::renderFrame(AVFrame* frame)
// The card may have been removed or crashed. Reset the decoder.
SDL_Event event;
event.type = SDL_RENDER_TARGETS_RESET;
event.type = SDL_RENDER_DEVICE_RESET;
SDL_PushEvent(&event);
return;
}

View File

@@ -943,7 +943,7 @@ void DXVA2Renderer::renderFrame(AVFrame *frame)
"Clear() failed: %x",
hr);
SDL_Event event;
event.type = SDL_RENDER_TARGETS_RESET;
event.type = SDL_RENDER_DEVICE_RESET;
SDL_PushEvent(&event);
return;
}
@@ -954,7 +954,7 @@ void DXVA2Renderer::renderFrame(AVFrame *frame)
"BeginScene() failed: %x",
hr);
SDL_Event event;
event.type = SDL_RENDER_TARGETS_RESET;
event.type = SDL_RENDER_DEVICE_RESET;
SDL_PushEvent(&event);
return;
}
@@ -980,7 +980,7 @@ void DXVA2Renderer::renderFrame(AVFrame *frame)
"StretchRect() failed: %x",
hr);
SDL_Event event;
event.type = SDL_RENDER_TARGETS_RESET;
event.type = SDL_RENDER_DEVICE_RESET;
SDL_PushEvent(&event);
return;
}
@@ -997,7 +997,7 @@ void DXVA2Renderer::renderFrame(AVFrame *frame)
"EndScene() failed: %x",
hr);
SDL_Event event;
event.type = SDL_RENDER_TARGETS_RESET;
event.type = SDL_RENDER_DEVICE_RESET;
SDL_PushEvent(&event);
return;
}
@@ -1015,7 +1015,7 @@ void DXVA2Renderer::renderFrame(AVFrame *frame)
"PresentEx() failed: %x",
hr);
SDL_Event event;
event.type = SDL_RENDER_TARGETS_RESET;
event.type = SDL_RENDER_DEVICE_RESET;
SDL_PushEvent(&event);
return;
}

View File

@@ -777,7 +777,7 @@ void EGLRenderer::renderFrame(AVFrame* frame)
// XWayland. Other strategies like calling glGetError() don't seem
// to be able to detect this situation for some reason.
SDL_Event event;
event.type = SDL_RENDER_TARGETS_RESET;
event.type = SDL_RENDER_DEVICE_RESET;
SDL_PushEvent(&event);
return;

View File

@@ -871,7 +871,7 @@ void PlVkRenderer::renderFrame(AVFrame *frame)
// Recreate the renderer
SDL_Event event;
event.type = SDL_RENDER_TARGETS_RESET;
event.type = SDL_RENDER_DEVICE_RESET;
SDL_PushEvent(&event);
goto UnmapExit;
}

View File

@@ -204,7 +204,7 @@ public:
// Trigger the main thread to recreate the decoder
SDL_Event event;
event.type = SDL_RENDER_TARGETS_RESET;
event.type = SDL_RENDER_DEVICE_RESET;
SDL_PushEvent(&event);
return;
}