From 7db0faa54a1c8cec1b7eb6784e6a500f2397c62f Mon Sep 17 00:00:00 2001 From: x64-dev <202863051+x64-dev@users.noreply.github.com> Date: Thu, 3 Sep 2026 21:56:49 +0000 Subject: [PATCH] fix(dx8): Prevent device reset crash on Intel GPUs --- .../Source/WWVegas/WW3D2/dx8wrapper.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp index 77774ddd664..74fab04529b 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp @@ -633,9 +633,37 @@ bool DX8Wrapper::Reset_Device(bool reload_assets) memset(Vertex_Shader_Constants, 0, sizeof(Vector4) * MAX_VERTEX_SHADER_CONSTANTS); memset(Pixel_Shader_Constants, 0, sizeof(Vector4) * MAX_PIXEL_SHADER_CONSTANTS); + // TheSuperHackers @bugfix Tin Tin Hamans - Release all surface references before Reset(). + // D3D8 requires that no non-managed surfaces (render targets, depth buffers) have outstanding + // references when Reset() is called. Failing to do so causes a crash inside the Intel integrated + // graphics driver (igd9trinity32.dll) during DestroyResource inside CSwapChain::Reset. + if (DefaultRenderTarget != nullptr) + { + DefaultRenderTarget->Release(); + DefaultRenderTarget = nullptr; + } + if (DefaultDepthBuffer != nullptr) + { + DefaultDepthBuffer->Release(); + DefaultDepthBuffer = nullptr; + } + if (CurrentRenderTarget != nullptr) + { + CurrentRenderTarget->Release(); + CurrentRenderTarget = nullptr; + } + if (CurrentDepthBuffer != nullptr) + { + CurrentDepthBuffer->Release(); + CurrentDepthBuffer = nullptr; + } + HRESULT hr = _Get_D3D_Device8()->TestCooperativeLevel(); if (hr != D3DERR_DEVICELOST) { + // TheSuperHackers @bugfix xezon 13/06/2025 Front load the system dbghelp.dll to prevent + // the graphics driver from potentially loading the old game dbghelp.dll and then crashing the game process. + DbgHelpGuard dbgHelpGuard; DX8CALL_HRES(Reset(&_PresentParameters), hr) if (hr != D3D_OK) return false; //reset failed.