From 09e5939502581b4d7ca9ded7ba7ebd528cb90822 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Sun, 25 Jul 2021 00:45:53 +0200 Subject: [PATCH] [d3d9] Reject 2 BeginScene + EndScene without Begin --- src/d3d9/d3d9_device.cpp | 14 ++++++++++++++ src/d3d9/d3d9_device.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 02a3a15c..793e0cb8 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -1360,13 +1360,27 @@ namespace dxvk { // Some games don't even call them. HRESULT STDMETHODCALLTYPE D3D9DeviceEx::BeginScene() { + D3D9DeviceLock lock = LockDevice(); + + if (unlikely(m_flags.test(D3D9DeviceFlag::InScene))) + return D3DERR_INVALIDCALL; + + m_flags.set(D3D9DeviceFlag::InScene); + return D3D_OK; } HRESULT STDMETHODCALLTYPE D3D9DeviceEx::EndScene() { + D3D9DeviceLock lock = LockDevice(); + + if (unlikely(!m_flags.test(D3D9DeviceFlag::InScene))) + return D3DERR_INVALIDCALL; + FlushImplicit(true); + m_flags.clr(D3D9DeviceFlag::InScene); + return D3D_OK; } diff --git a/src/d3d9/d3d9_device.h b/src/d3d9/d3d9_device.h index d4ae629c..3d5a741e 100644 --- a/src/d3d9/d3d9_device.h +++ b/src/d3d9/d3d9_device.h @@ -71,6 +71,8 @@ namespace dxvk { ValidSampleMask, DirtyDepthBounds, DirtyPointScale, + + InScene, }; using D3D9DeviceFlags = Flags;