devtools: better window names

This commit is contained in:
Vinicius Rangel 2024-10-15 03:12:02 -03:00
parent ca0ca4913f
commit 02f42b8e0a
No known key found for this signature in database
GPG Key ID: A5B154D904B761D9
8 changed files with 37 additions and 26 deletions

View File

@ -102,6 +102,10 @@ void DebugStateImpl::RequestFrameDump(s32 count) {
gnm_frame_dump_request_count = count; gnm_frame_dump_request_count = count;
frame_dump_list.clear(); frame_dump_list.clear();
frame_dump_list.resize(count); 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; waiting_submit_pause = true;
} }

View File

@ -61,6 +61,7 @@ struct RegDump {
}; };
struct FrameDump { struct FrameDump {
u32 frame_id;
std::vector<QueueDump> queues; std::vector<QueueDump> queues;
std::unordered_map<uintptr_t, RegDump> regs; // address -> reg dump std::unordered_map<uintptr_t, RegDump> regs; // address -> reg dump
}; };

View File

@ -1310,10 +1310,10 @@ void CmdListViewer::Draw() {
auto data = frame_dump->regs.at(batch.command_addr); auto data = frame_dump->regs.at(batch.command_addr);
if (GetIO().KeyShift) { if (GetIO().KeyShift) {
auto& pop = extra_batch_view.emplace_back(); auto& pop = extra_batch_view.emplace_back();
pop.SetData(data, batch_id); pop.SetData(data, name, batch_id);
pop.open = true; pop.open = true;
} else { } else {
batch_view.SetData(data, batch_id); batch_view.SetData(data, name, batch_id);
batch_view.open = true; batch_view.open = true;
} }
} }

View File

@ -47,9 +47,9 @@ FrameDumpViewer::FrameDumpViewer(const FrameDump& _frame_dump)
cmd_list_viewer.reserve(frame_dump->queues.size()); cmd_list_viewer.reserve(frame_dump->queues.size());
for (const auto& cmd : frame_dump->queues) { for (const auto& cmd : frame_dump->queues) {
const auto fname = const auto fname = fmt::format("F{} {}_{:02}_{:02}", frame_dump->frame_id,
fmt::format("{}_{}_{:02}_{:02}", id, magic_enum::enum_name(selected_queue_type), magic_enum::enum_name(selected_queue_type),
selected_submit_num, selected_queue_num2); selected_submit_num, selected_queue_num2);
cmd_list_viewer.emplace_back(frame_dump.get(), cmd.data, cmd.base_addr, fname); 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) { if (cmd.type == QueueType::dcb && cmd.submit_num == 0 && cmd.num2 == 0) {
selected_cmd = static_cast<s32>(cmd_list_viewer.size() - 1); selected_cmd = static_cast<s32>(cmd_list_viewer.size() - 1);
@ -65,7 +65,7 @@ void FrameDumpViewer::Draw() {
} }
char name[32]; 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 (Begin(name, &is_open, ImGuiWindowFlags_NoSavedSettings)) {
if (IsWindowAppearing()) { if (IsWindowAppearing()) {
auto window = GetCurrentWindow(); auto window = GetCurrentWindow();

View File

@ -142,22 +142,25 @@ RegPopup::RegPopup() {
id = unique_id++; 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->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, void RegPopup::SetData(const std::string& base_title, AmdGpu::Liverpool::DepthBuffer depth_buffer,
AmdGpu::Liverpool::DepthControl depth_control, u32 batch_id) { AmdGpu::Liverpool::DepthControl depth_control) {
this->data = std::make_tuple(depth_buffer, 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) { 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 (Begin(title.c_str(), &open, flags)) {
if (const auto* buffer = std::get_if<AmdGpu::Liverpool::ColorBuffer>(&data)) { if (const auto* buffer = std::get_if<AmdGpu::Liverpool::ColorBuffer>(&data)) {
if (auto_resize) { if (auto_resize) {
SetWindowSize({589.0f, 522.0f}); SetWindowSize({365.0f, 520.0f});
KeepWindowInside(); KeepWindowInside();
} }
DrawColorBuffer(*buffer); DrawColorBuffer(*buffer);

View File

@ -30,10 +30,11 @@ public:
RegPopup(); 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, void SetData(const std::string& base_title, AmdGpu::Liverpool::DepthBuffer depth_buffer,
AmdGpu::Liverpool::DepthControl depth_control, u32 batch_id); AmdGpu::Liverpool::DepthControl depth_control);
void Draw(bool auto_resize = false); void Draw(bool auto_resize = false);
}; };

View File

@ -111,14 +111,14 @@ void RegView::DrawRegs() {
const auto open_new_popup = [&](int cb, auto... args) { const auto open_new_popup = [&](int cb, auto... args) {
if (GetIO().KeyShift) { if (GetIO().KeyShift) {
auto& pop = extra_reg_popup.emplace_back(); auto& pop = extra_reg_popup.emplace_back();
pop.SetData(args...); pop.SetData(title, args...);
pop.open = true; pop.open = true;
pop.Draw(true); pop.Draw(true);
} else if (last_selected_cb == cb && default_reg_popup.open) { } else if (last_selected_cb == cb && default_reg_popup.open) {
default_reg_popup.open = false; default_reg_popup.open = false;
} else { } else {
last_selected_cb = cb; last_selected_cb = cb;
default_reg_popup.SetData(args...); default_reg_popup.SetData(title, args...);
if (!default_reg_popup.open) { if (!default_reg_popup.open) {
default_reg_popup.open = true; default_reg_popup.open = true;
const auto pos = GImGui->LastItemData.Rect.Max + ImVec2(5.0f, 0.0f); const auto pos = GImGui->LastItemData.Rect.Max + ImVec2(5.0f, 0.0f);
@ -143,7 +143,7 @@ void RegView::DrawRegs() {
} else { } else {
const char* text = last_selected_cb == cb && default_reg_popup.open ? "x" : "->"; const char* text = last_selected_cb == cb && default_reg_popup.open ? "x" : "->";
if (SmallButton(text)) { 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; constexpr auto depth_id = 0xF3;
const char* text = last_selected_cb == depth_id && default_reg_popup.open ? "x" : "->"; const char* text = last_selected_cb == depth_id && default_reg_popup.open ? "x" : "->";
if (SmallButton(text)) { 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++; id = unique_id++;
char name[128]; 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}); SetNextWindowPos({400.0f, 200.0f});
SetNextWindowSize({450.0f, 500.0f}); SetNextWindowSize({450.0f, 500.0f});
ImGuiID root_dock_id; ImGuiID root_dock_id;
@ -203,9 +203,10 @@ RegView::RegView() {
DockBuilderFinish(root_dock_id); 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->data = std::move(data);
this->batch_id = batch_id; this->batch_id = batch_id;
this->title = fmt::format("{}/Batch {}", base_title, batch_id);
// clear cache // clear cache
selected_shader = -1; selected_shader = -1;
shader_decomp.clear(); shader_decomp.clear();
@ -214,9 +215,9 @@ void RegView::SetData(DebugStateType::RegDump data, u32 batch_id) {
} }
void RegView::Draw() { void RegView::Draw() {
char name[128]; 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)) { if (Begin(name, &open, ImGuiWindowFlags_MenuBar)) {
const char* names[] = {"vs", "ps", "gs", "es", "hs", "ls"}; const char* names[] = {"vs", "ps", "gs", "es", "hs", "ls"};
@ -270,7 +271,7 @@ void RegView::Draw() {
if (Begin(name, &show_user_data)) { if (Begin(name, &show_user_data)) {
auto shader = get_shader(); auto shader = get_shader();
if (!shader) { if (!shader) {
Text("Select a stage"); Text("Stage not selected");
} else { } else {
shader->hex_view.DrawContents(shader->user_data.data(), shader->user_data.size()); shader->hex_view.DrawContents(shader->user_data.data(), shader->user_data.size());
} }
@ -283,7 +284,7 @@ void RegView::Draw() {
if (Begin(name, &show_disassembly)) { if (Begin(name, &show_disassembly)) {
auto shader = get_shader(); auto shader = get_shader();
if (!shader) { if (!shader) {
Text("Select a stage"); Text("Stage not selected");
} else { } else {
shader->dis_view.Render("Disassembly", GetContentRegionAvail()); shader->dis_view.Render("Disassembly", GetContentRegionAvail());
} }

View File

@ -18,6 +18,7 @@ struct ShaderCache {
class RegView { class RegView {
int id; int id;
std::string title;
DebugStateType::RegDump data; DebugStateType::RegDump data;
u32 batch_id{~0u}; u32 batch_id{~0u};
@ -42,7 +43,7 @@ public:
RegView(); RegView();
void SetData(DebugStateType::RegDump data, u32 batch_id); void SetData(DebugStateType::RegDump data, const std::string& base_title, u32 batch_id);
void Draw(); void Draw();
}; };