Skip to content

Commit

Permalink
Add basic window for the output display
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Nov 27, 2024
1 parent 6763c13 commit e59e3a9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
9 changes: 4 additions & 5 deletions GPU/Common/FramebufferManagerCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions UI/ImDebugger/ImDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions UI/ImDebugger/ImDebugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ struct ImConfig {
int selectedFramebuffer = -1;
int selectedBreakpoint = -1;
int selectedMemCheck = -1;

bool displayLatched = false;
};

enum ImUiCmd {
Expand Down
22 changes: 21 additions & 1 deletion UI/ImDebugger/ImGe.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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<u8> 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();
}
1 change: 1 addition & 0 deletions UI/ImDebugger/ImGe.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ struct ImConfig;
class FramebufferManagerCommon;

void DrawFramebuffersWindow(ImConfig &cfg, FramebufferManagerCommon *framebufferManager);
void DrawDisplayWindow(ImConfig &cfg, FramebufferManagerCommon *framebufferManager);

class ImGeDebugger {
public:
Expand Down

0 comments on commit e59e3a9

Please sign in to comment.