From 3a31a450287212307e4796494e9c6642b3824310 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 10 Nov 2021 05:24:31 -0800 Subject: [PATCH] End the scene before resetting the D3D device, since we'll start with BeginScene after that. If we don't do this, we'll end up with unbalanced Begin/End scene pairs which causes D3DERR_INVALIDCALL in the present. Fixes https://github.com/libsdl-org/SDL/issues/4933 --- src/render/direct3d/SDL_render_d3d.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 06c174094..fb5fc6289 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1425,6 +1425,12 @@ D3D_Reset(SDL_Renderer * renderer) SDL_Texture *texture; int i; + /* Cancel any scene that we've started */ + if (!data->beginScene) { + IDirect3DDevice9_EndScene(data->device); + data->beginScene = SDL_TRUE; + } + /* Release the default render target before reset */ if (data->defaultRenderTarget) { IDirect3DSurface9_Release(data->defaultRenderTarget);