From 659af60613400440176a3cd7bde1c994a64a8eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 21 Nov 2024 14:56:42 +0100 Subject: [PATCH] Fix ImDebugger rendering on D3D9 as well (although not very optimally). --- Common/GPU/D3D9/thin3d_d3d9.cpp | 22 ++++++++++++++++++++++ Common/GPU/thin3d.h | 5 +++-- UI/EmuScreen.cpp | 4 ---- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Common/GPU/D3D9/thin3d_d3d9.cpp b/Common/GPU/D3D9/thin3d_d3d9.cpp index 4f0f9eca90..f2ea19800e 100644 --- a/Common/GPU/D3D9/thin3d_d3d9.cpp +++ b/Common/GPU/D3D9/thin3d_d3d9.cpp @@ -574,6 +574,8 @@ public: void DrawIndexed(int vertexCount, int offset) override; void DrawUP(const void *vdata, int vertexCount) override; void DrawIndexedUP(const void *vdata, int vertexCount, const void *idata, int indexCount) override; + void DrawIndexedClippedBatchUP(const void *vdata, int vertexCount, const void *idata, int indexCount, Slice draws) override; + void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) override; uint64_t GetNativeObject(NativeObject obj, void *srcObject) override { @@ -1186,6 +1188,26 @@ void D3D9Context::DrawIndexedUP(const void *vdata, int vertexCount, const void * vdata, curPipeline_->inputLayout->GetStride()); } +void D3D9Context::DrawIndexedClippedBatchUP(const void *vdata, int vertexCount, const void *idata, int indexCount, Slice draws) { + curPipeline_->inputLayout->Apply(device_); + curPipeline_->Apply(device_, stencilRef_, stencilWriteMask_, stencilCompareMask_); + ApplyDynamicState(); + + // Suboptimal! + for (int i = 0; i < draws.size(); i++) { + RECT rc; + rc.left = draws[i].clipx; + rc.top = draws[i].clipy; + rc.right = draws[i].clipx + draws[i].clipw; + rc.bottom = draws[i].clipy + draws[i].cliph; + + device_->SetScissorRect(&rc); + device_->DrawIndexedPrimitiveUP(curPipeline_->prim, 0, vertexCount, D3DPrimCount(curPipeline_->prim, draws[i].indexCount), + (uint16_t *)idata + draws[i].indexOffset, D3DFMT_INDEX16, + vdata, curPipeline_->inputLayout->GetStride()); + } +} + static uint32_t SwapRB(uint32_t c) { return (c & 0xFF00FF00) | ((c >> 16) & 0xFF) | ((c << 16) & 0xFF0000); } diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 786a16e14c..2c72156913 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -837,8 +837,9 @@ public: virtual void Draw(int vertexCount, int offset) = 0; virtual void DrawIndexed(int vertexCount, int offset) = 0; // Always 16-bit indices. virtual void DrawUP(const void *vdata, int vertexCount) = 0; - virtual void DrawIndexedUP(const void *vdata, int vertexCount, const void *idata, int indexCount) = 0; // Supports 32-bit indices, for IMGUI use. - virtual void DrawIndexedClippedBatchUP(const void *vdata, int vertexCount, const void *idata, int indexCount, Slice draws) {} + virtual void DrawIndexedUP(const void *vdata, int vertexCount, const void *idata, int indexCount) = 0; + // Intended for ImGui display lists, easier to do optimally this way. + virtual void DrawIndexedClippedBatchUP(const void *vdata, int vertexCount, const void *idata, int indexCount, Slice draws) = 0; // Frame management (for the purposes of sync and resource management, necessary with modern APIs). Default implementations here. virtual void BeginFrame(DebugFlags debugFlags) = 0; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 2d4035b4fb..bda4fd09d2 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1636,10 +1636,6 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { SetVRAppMode(screenManager()->topScreen() == this ? VRAppMode::VR_GAME_MODE : VRAppMode::VR_DIALOG_MODE); } - if (!(mode & ScreenRenderMode::TOP)) { - darken(); - } - renderImDebugger(); return flags; }