Fix ImDebugger rendering on D3D9 as well (although not very optimally).

This commit is contained in:
Henrik Rydgård 2024-11-21 14:56:42 +01:00
parent 617bef73ee
commit 659af60613
3 changed files with 25 additions and 6 deletions

View File

@ -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<ClippedDraw> 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<ClippedDraw> 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);
}

View File

@ -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<ClippedDraw> 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<ClippedDraw> 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;

View File

@ -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;
}