From e59e3a9271969f9b9e999044ba2578e028233aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 27 Nov 2024 01:37:03 +0100 Subject: [PATCH] Add basic window for the output display --- GPU/Common/FramebufferManagerCommon.cpp | 9 ++++----- UI/ImDebugger/ImDebugger.cpp | 5 +++++ UI/ImDebugger/ImDebugger.h | 2 ++ UI/ImDebugger/ImGe.cpp | 22 +++++++++++++++++++++- UI/ImDebugger/ImGe.h | 1 + 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 499be8fa6334..c06e73b7c694 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -3667,13 +3667,12 @@ static void ApplyKillzoneFramebufferSplit(FramebufferHeuristicParams *params, in void FramebufferManagerCommon::DrawImGuiDebug(int &selected) const { ImGui::BeginTable("framebuffers", 4); - ImGui::TableSetupColumn("Tag"); - ImGui::TableSetupColumn("Color Addr"); - ImGui::TableSetupColumn("Depth Addr"); - ImGui::TableSetupColumn("Size"); + ImGui::TableSetupColumn("Tag", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("Color Addr", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("Depth Addr", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("Size", ImGuiTableColumnFlags_WidthFixed); ImGui::TableHeadersRow(); - ImGui::TableSetColumnIndex(0); for (int i = 0; i < (int)vfbs_.size(); i++) { ImGui::TableNextRow(); diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index 8f43629a9092..6742423dee66 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -692,6 +692,7 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu ImGui::EndMenu(); } if (ImGui::BeginMenu("Ge (GPU)")) { + ImGui::MenuItem("Display Output", nullptr, &cfg_.displayOpen); ImGui::MenuItem("Framebuffers", nullptr, &cfg_.framebuffersOpen); // More to come here... ImGui::EndMenu(); @@ -763,6 +764,10 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu DrawFramebuffersWindow(cfg_, gpuDebug->GetFramebufferManagerCommon()); } + if (cfg_.displayOpen) { + DrawDisplayWindow(cfg_, gpuDebug->GetFramebufferManagerCommon()); + } + if (cfg_.structViewerOpen) { structViewer_.Draw(mipsDebug, &cfg_.structViewerOpen); } diff --git a/UI/ImDebugger/ImDebugger.h b/UI/ImDebugger/ImDebugger.h index 88db3754d03a..ee2ed91cccb0 100644 --- a/UI/ImDebugger/ImDebugger.h +++ b/UI/ImDebugger/ImDebugger.h @@ -83,6 +83,8 @@ struct ImConfig { int selectedFramebuffer = -1; int selectedBreakpoint = -1; int selectedMemCheck = -1; + + bool displayLatched = false; }; enum ImUiCmd { diff --git a/UI/ImDebugger/ImGe.cpp b/UI/ImDebugger/ImGe.cpp index b0fa43f19810..3b096b650c34 100644 --- a/UI/ImDebugger/ImGe.cpp +++ b/UI/ImDebugger/ImGe.cpp @@ -1,3 +1,5 @@ +#include "ext/imgui/imgui.h" +#include "ext/imgui/imgui_impl_thin3d.h" #include "UI/ImDebugger/ImGe.h" #include "UI/ImDebugger/ImDebugger.h" #include "GPU/Common/FramebufferManagerCommon.h" @@ -15,11 +17,29 @@ void DrawFramebuffersWindow(ImConfig &cfg, FramebufferManagerCommon *framebuffer ImGui::End(); } -void DrawDisplayWindow(ImConfig &cfg) { +void DrawDisplayWindow(ImConfig &cfg, FramebufferManagerCommon *framebufferManager) { if (!ImGui::Begin("Display", &cfg.framebuffersOpen)) { ImGui::End(); return; } + ImGui::Checkbox("Display latched", &cfg.displayLatched); + + PSPPointer topaddr; + u32 linesize; + u32 pixelFormat; + + __DisplayGetFramebuf(&topaddr, &linesize, &pixelFormat, cfg.displayLatched); + + VirtualFramebuffer *fb = framebufferManager->GetVFBAt(topaddr.ptr); + if (fb && fb->fbo) { + ImTextureID texId = ImGui_ImplThin3d_AddFBAsTextureTemp(fb->fbo, Draw::FB_COLOR_BIT, ImGuiPipeline::TexturedOpaque); + ImGui::Image(texId, ImVec2(fb->width, fb->height)); + ImGui::Text("%s - %08x", fb->fbo->Tag(), topaddr.ptr); + } else { + // TODO: Sometimes we should display RAM here. + ImGui::Text("Framebuffer not available to display"); + } + ImGui::End(); } diff --git a/UI/ImDebugger/ImGe.h b/UI/ImDebugger/ImGe.h index 958465ba17c4..08868b7f0ac5 100644 --- a/UI/ImDebugger/ImGe.h +++ b/UI/ImDebugger/ImGe.h @@ -7,6 +7,7 @@ struct ImConfig; class FramebufferManagerCommon; void DrawFramebuffersWindow(ImConfig &cfg, FramebufferManagerCommon *framebufferManager); +void DrawDisplayWindow(ImConfig &cfg, FramebufferManagerCommon *framebufferManager); class ImGeDebugger { public: