From 2a02ba365783eb9d2ede4930928bcc2b1d5c7c85 Mon Sep 17 00:00:00 2001 From: VDm Date: Mon, 31 Mar 2025 00:08:41 +0400 Subject: [PATCH] feat(d3d): update CGxDeviceD3d::ISceneBegin --- src/gx/d3d/CGxDeviceD3d.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/gx/d3d/CGxDeviceD3d.cpp b/src/gx/d3d/CGxDeviceD3d.cpp index 3103b77..3af6563 100644 --- a/src/gx/d3d/CGxDeviceD3d.cpp +++ b/src/gx/d3d/CGxDeviceD3d.cpp @@ -1311,17 +1311,28 @@ void CGxDeviceD3d::ICursorDraw() { } void CGxDeviceD3d::ISceneBegin() { + if (!this->m_context) { + auto result = this->m_d3dDevice->TestCooperativeLevel(); + if (result == D3DERR_DEVICENOTRESET) { + this->IReleaseD3dResources(0); + D3DPRESENT_PARAMETERS d3dpp; + this->ISetPresentParms(d3dpp, this->m_format); + result = this->m_d3dDevice->Reset(&d3dpp); + if (result == D3D_OK) { + this->IStateSetD3dDefaults(); + // TODO: CGxDeviceD3d::ICursorClip + // TODO: this->NotifyOnDeviceRestored() + } + } + } + if (this->m_context) { this->ShaderConstantsClear(); if (SUCCEEDED(this->m_d3dDevice->BeginScene())) { this->m_inScene = 1; } - - return; } - - // TODO } void CGxDeviceD3d::ISceneEnd() {