From 3c9361509b3dba949ad019763f3d197bc4887331 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 2 Dec 2018 20:55:57 -0500 Subject: [PATCH] direct3d: Release and NULL out vertex buffers on reset. Otherwise they are irretrievably lost on window resize, etc, which makes rendering freeze and other disasters. Fixes Bugzilla #4358. --- src/render/direct3d/SDL_render_d3d.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 04cfcef1f..7f7ba1858 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1566,6 +1566,15 @@ D3D_Reset(SDL_Renderer * renderer) } } + /* Release all vertex buffers */ + int i; + for (i = 0; i < SDL_arraysize(data->vertexBuffers); ++i) { + if (data->vertexBuffers[i]) { + IDirect3DVertexBuffer9_Release(data->vertexBuffers[i]); + } + data->vertexBuffers[i] = NULL; + } + result = IDirect3DDevice9_Reset(data->device, &data->pparams); if (FAILED(result)) { if (result == D3DERR_DEVICELOST) {