From 02f42b8e0ad082af530a1087225558ff34b207ff Mon Sep 17 00:00:00 2001 From: Vinicius Rangel Date: Tue, 15 Oct 2024 03:12:02 -0300 Subject: [PATCH] devtools: better window names --- src/core/debug_state.cpp | 4 ++++ src/core/debug_state.h | 1 + src/core/devtools/widget/cmd_list.cpp | 4 ++-- src/core/devtools/widget/frame_dump.cpp | 8 ++++---- src/core/devtools/widget/reg_popup.cpp | 15 +++++++++------ src/core/devtools/widget/reg_popup.h | 7 ++++--- src/core/devtools/widget/reg_view.cpp | 21 +++++++++++---------- src/core/devtools/widget/reg_view.h | 3 ++- 8 files changed, 37 insertions(+), 26 deletions(-) diff --git a/src/core/debug_state.cpp b/src/core/debug_state.cpp index 93b00285d..e449d2daa 100644 --- a/src/core/debug_state.cpp +++ b/src/core/debug_state.cpp @@ -102,6 +102,10 @@ void DebugStateImpl::RequestFrameDump(s32 count) { gnm_frame_dump_request_count = count; frame_dump_list.clear(); frame_dump_list.resize(count); + const auto f = gnm_frame_count.load() + 1; + for (size_t i = 0; i < count; ++i) { + frame_dump_list[i].frame_id = f + i; + } waiting_submit_pause = true; } diff --git a/src/core/debug_state.h b/src/core/debug_state.h index 26dfa202e..7a72059d0 100644 --- a/src/core/debug_state.h +++ b/src/core/debug_state.h @@ -61,6 +61,7 @@ struct RegDump { }; struct FrameDump { + u32 frame_id; std::vector queues; std::unordered_map regs; // address -> reg dump }; diff --git a/src/core/devtools/widget/cmd_list.cpp b/src/core/devtools/widget/cmd_list.cpp index 583426bc3..a6c761cb1 100644 --- a/src/core/devtools/widget/cmd_list.cpp +++ b/src/core/devtools/widget/cmd_list.cpp @@ -1310,10 +1310,10 @@ void CmdListViewer::Draw() { auto data = frame_dump->regs.at(batch.command_addr); if (GetIO().KeyShift) { auto& pop = extra_batch_view.emplace_back(); - pop.SetData(data, batch_id); + pop.SetData(data, name, batch_id); pop.open = true; } else { - batch_view.SetData(data, batch_id); + batch_view.SetData(data, name, batch_id); batch_view.open = true; } } diff --git a/src/core/devtools/widget/frame_dump.cpp b/src/core/devtools/widget/frame_dump.cpp index 29b5cb8ee..2725305a2 100644 --- a/src/core/devtools/widget/frame_dump.cpp +++ b/src/core/devtools/widget/frame_dump.cpp @@ -47,9 +47,9 @@ FrameDumpViewer::FrameDumpViewer(const FrameDump& _frame_dump) cmd_list_viewer.reserve(frame_dump->queues.size()); for (const auto& cmd : frame_dump->queues) { - const auto fname = - fmt::format("{}_{}_{:02}_{:02}", id, magic_enum::enum_name(selected_queue_type), - selected_submit_num, selected_queue_num2); + const auto fname = fmt::format("F{} {}_{:02}_{:02}", frame_dump->frame_id, + magic_enum::enum_name(selected_queue_type), + selected_submit_num, selected_queue_num2); cmd_list_viewer.emplace_back(frame_dump.get(), cmd.data, cmd.base_addr, fname); if (cmd.type == QueueType::dcb && cmd.submit_num == 0 && cmd.num2 == 0) { selected_cmd = static_cast(cmd_list_viewer.size() - 1); @@ -65,7 +65,7 @@ void FrameDumpViewer::Draw() { } char name[32]; - snprintf(name, sizeof(name), "Frame #%d dump", id); + snprintf(name, sizeof(name), "Frame #%d dump", frame_dump->frame_id); if (Begin(name, &is_open, ImGuiWindowFlags_NoSavedSettings)) { if (IsWindowAppearing()) { auto window = GetCurrentWindow(); diff --git a/src/core/devtools/widget/reg_popup.cpp b/src/core/devtools/widget/reg_popup.cpp index 8e691a76b..6036cf098 100644 --- a/src/core/devtools/widget/reg_popup.cpp +++ b/src/core/devtools/widget/reg_popup.cpp @@ -142,22 +142,25 @@ RegPopup::RegPopup() { id = unique_id++; } -void RegPopup::SetData(AmdGpu::Liverpool::ColorBuffer color_buffer, u32 batch_id, u32 cb_id) { +void RegPopup::SetData(const std::string& base_title, AmdGpu::Liverpool::ColorBuffer color_buffer, + u32 cb_id) { this->data = color_buffer; - this->title = fmt::format("Batch #{} CB #{}###reg_popup_%d", batch_id, cb_id, id); + this->title = fmt::format("{}/CB #{}", base_title, cb_id); } -void RegPopup::SetData(AmdGpu::Liverpool::DepthBuffer depth_buffer, - AmdGpu::Liverpool::DepthControl depth_control, u32 batch_id) { +void RegPopup::SetData(const std::string& base_title, AmdGpu::Liverpool::DepthBuffer depth_buffer, + AmdGpu::Liverpool::DepthControl depth_control) { this->data = std::make_tuple(depth_buffer, depth_control); - this->title = fmt::format("Batch #{} Depth###reg_popup_%d", batch_id, id); + this->title = fmt::format("{}/Depth", base_title); } void RegPopup::Draw(bool auto_resize) { + char name[128]; + snprintf(name, sizeof(name), "%s###reg_popup_%d", title.c_str(), id); if (Begin(title.c_str(), &open, flags)) { if (const auto* buffer = std::get_if(&data)) { if (auto_resize) { - SetWindowSize({589.0f, 522.0f}); + SetWindowSize({365.0f, 520.0f}); KeepWindowInside(); } DrawColorBuffer(*buffer); diff --git a/src/core/devtools/widget/reg_popup.h b/src/core/devtools/widget/reg_popup.h index b44ac80d0..f92983306 100644 --- a/src/core/devtools/widget/reg_popup.h +++ b/src/core/devtools/widget/reg_popup.h @@ -30,10 +30,11 @@ public: RegPopup(); - void SetData(AmdGpu::Liverpool::ColorBuffer color_buffer, u32 batch_id, u32 cb_id); + void SetData(const std::string& base_title, AmdGpu::Liverpool::ColorBuffer color_buffer, + u32 cb_id); - void SetData(AmdGpu::Liverpool::DepthBuffer depth_buffer, - AmdGpu::Liverpool::DepthControl depth_control, u32 batch_id); + void SetData(const std::string& base_title, AmdGpu::Liverpool::DepthBuffer depth_buffer, + AmdGpu::Liverpool::DepthControl depth_control); void Draw(bool auto_resize = false); }; diff --git a/src/core/devtools/widget/reg_view.cpp b/src/core/devtools/widget/reg_view.cpp index f11559000..1c67cb366 100644 --- a/src/core/devtools/widget/reg_view.cpp +++ b/src/core/devtools/widget/reg_view.cpp @@ -111,14 +111,14 @@ void RegView::DrawRegs() { const auto open_new_popup = [&](int cb, auto... args) { if (GetIO().KeyShift) { auto& pop = extra_reg_popup.emplace_back(); - pop.SetData(args...); + pop.SetData(title, args...); pop.open = true; pop.Draw(true); } else if (last_selected_cb == cb && default_reg_popup.open) { default_reg_popup.open = false; } else { last_selected_cb = cb; - default_reg_popup.SetData(args...); + default_reg_popup.SetData(title, args...); if (!default_reg_popup.open) { default_reg_popup.open = true; const auto pos = GImGui->LastItemData.Rect.Max + ImVec2(5.0f, 0.0f); @@ -143,7 +143,7 @@ void RegView::DrawRegs() { } else { const char* text = last_selected_cb == cb && default_reg_popup.open ? "x" : "->"; if (SmallButton(text)) { - open_new_popup(cb, buffer, batch_id, cb); + open_new_popup(cb, buffer, cb); } } @@ -160,7 +160,7 @@ void RegView::DrawRegs() { constexpr auto depth_id = 0xF3; const char* text = last_selected_cb == depth_id && default_reg_popup.open ? "x" : "->"; if (SmallButton(text)) { - open_new_popup(depth_id, regs.depth_buffer, regs.depth_control, batch_id); + open_new_popup(depth_id, regs.depth_buffer, regs.depth_control); } } @@ -173,7 +173,7 @@ RegView::RegView() { id = unique_id++; char name[128]; - snprintf(name, sizeof(name), "BatchView###reg_dump_%d", id); + snprintf(name, sizeof(name), "###reg_dump_%d", id); SetNextWindowPos({400.0f, 200.0f}); SetNextWindowSize({450.0f, 500.0f}); ImGuiID root_dock_id; @@ -203,9 +203,10 @@ RegView::RegView() { DockBuilderFinish(root_dock_id); } -void RegView::SetData(DebugStateType::RegDump data, u32 batch_id) { +void RegView::SetData(DebugStateType::RegDump data, const std::string& base_title, u32 batch_id) { this->data = std::move(data); this->batch_id = batch_id; + this->title = fmt::format("{}/Batch {}", base_title, batch_id); // clear cache selected_shader = -1; shader_decomp.clear(); @@ -214,9 +215,9 @@ void RegView::SetData(DebugStateType::RegDump data, u32 batch_id) { } void RegView::Draw() { - char name[128]; - snprintf(name, sizeof(name), "BatchView %u###reg_dump_%d", batch_id, id); + snprintf(name, sizeof(name), "%s###reg_dump_%d", title.c_str(), id); + if (Begin(name, &open, ImGuiWindowFlags_MenuBar)) { const char* names[] = {"vs", "ps", "gs", "es", "hs", "ls"}; @@ -270,7 +271,7 @@ void RegView::Draw() { if (Begin(name, &show_user_data)) { auto shader = get_shader(); if (!shader) { - Text("Select a stage"); + Text("Stage not selected"); } else { shader->hex_view.DrawContents(shader->user_data.data(), shader->user_data.size()); } @@ -283,7 +284,7 @@ void RegView::Draw() { if (Begin(name, &show_disassembly)) { auto shader = get_shader(); if (!shader) { - Text("Select a stage"); + Text("Stage not selected"); } else { shader->dis_view.Render("Disassembly", GetContentRegionAvail()); } diff --git a/src/core/devtools/widget/reg_view.h b/src/core/devtools/widget/reg_view.h index 67ab1e04f..c90ed5536 100644 --- a/src/core/devtools/widget/reg_view.h +++ b/src/core/devtools/widget/reg_view.h @@ -18,6 +18,7 @@ struct ShaderCache { class RegView { int id; + std::string title; DebugStateType::RegDump data; u32 batch_id{~0u}; @@ -42,7 +43,7 @@ public: RegView(); - void SetData(DebugStateType::RegDump data, u32 batch_id); + void SetData(DebugStateType::RegDump data, const std::string& base_title, u32 batch_id); void Draw(); };