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 // Fall through
case SDL_RENDER_DEVICE_RESET: case SDL_RENDER_DEVICE_RESET:
case SDL_RENDER_TARGETS_RESET:
if (event.type != SDL_WINDOWEVENT) { if (event.type != SDL_WINDOWEVENT) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
@@ -2182,6 +2181,12 @@ void Session::exec()
updateOptimalWindowDisplayMode(); 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), // If the stream exceeds the display refresh rate (plus some slack),
// forcefully disable V-sync to allow the stream to render faster // 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 // Request an IDR frame to complete the reset
LiRequestIdrFrame(); LiRequestIdrFrame();

View File

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

View File

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

View File

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

View File

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

View File

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