diff --git a/src/core/devtools/widget/reg_popup.cpp b/src/core/devtools/widget/reg_popup.cpp index 888552c8e..8e691a76b 100644 --- a/src/core/devtools/widget/reg_popup.cpp +++ b/src/core/devtools/widget/reg_popup.cpp @@ -9,6 +9,7 @@ #include "cmd_list.h" #include "common.h" +#include "imgui/imgui_std.h" using namespace ImGui; using magic_enum::enum_name; @@ -143,29 +144,31 @@ RegPopup::RegPopup() { void RegPopup::SetData(AmdGpu::Liverpool::ColorBuffer color_buffer, u32 batch_id, u32 cb_id) { this->data = color_buffer; - this->title = fmt::format("Batch #{} CB #{}", batch_id, cb_id); + this->title = fmt::format("Batch #{} CB #{}###reg_popup_%d", batch_id, cb_id, id); } void RegPopup::SetData(AmdGpu::Liverpool::DepthBuffer depth_buffer, AmdGpu::Liverpool::DepthControl depth_control, u32 batch_id) { this->data = std::make_tuple(depth_buffer, depth_control); - this->title = fmt::format("Batch #{} Depth", batch_id); + this->title = fmt::format("Batch #{} Depth###reg_popup_%d", batch_id, id); } -void RegPopup::Draw() { - - char name[128]; - snprintf(name, sizeof(name), "%s###reg_popup_%d", title.c_str(), id); - - SetNextWindowSize({250.0f, 300.0f}, ImGuiCond_FirstUseEver); - if (Begin(name, &open, ImGuiWindowFlags_NoSavedSettings)) { +void RegPopup::Draw(bool auto_resize) { + if (Begin(title.c_str(), &open, flags)) { if (const auto* buffer = std::get_if(&data)) { + if (auto_resize) { + SetWindowSize({589.0f, 522.0f}); + KeepWindowInside(); + } DrawColorBuffer(*buffer); } else if (const auto* depth_data = std::get_if(&data)) { + if (auto_resize) { + SetWindowSize({404.0f, 543.0f}); + KeepWindowInside(); + } DrawDepthBuffer(*depth_data); } } End(); } - } // namespace Core::Devtools::Widget diff --git a/src/core/devtools/widget/reg_popup.h b/src/core/devtools/widget/reg_popup.h index 65a5d4c8a..b44ac80d0 100644 --- a/src/core/devtools/widget/reg_popup.h +++ b/src/core/devtools/widget/reg_popup.h @@ -5,6 +5,8 @@ #include +#include + #include "common/types.h" #include "video_core/renderer_vulkan/liverpool_to_vk.h" @@ -12,14 +14,13 @@ namespace Core::Devtools::Widget { class RegPopup { int id; + ImGuiWindowFlags flags{ImGuiWindowFlags_NoSavedSettings}; using DepthBuffer = std::tuple; std::variant data; std::string title{}; - void DrawColorBuffer(const AmdGpu::Liverpool::ColorBuffer& buffer); - static void DrawColorBuffer(const AmdGpu::Liverpool::ColorBuffer& buffer); static void DrawDepthBuffer(const DepthBuffer& depth_data); @@ -34,7 +35,7 @@ public: void SetData(AmdGpu::Liverpool::DepthBuffer depth_buffer, AmdGpu::Liverpool::DepthControl depth_control, u32 batch_id); - void Draw(); + void Draw(bool auto_resize = false); }; } // namespace Core::Devtools::Widget diff --git a/src/core/devtools/widget/reg_view.cpp b/src/core/devtools/widget/reg_view.cpp index 663a05bb7..f11559000 100644 --- a/src/core/devtools/widget/reg_view.cpp +++ b/src/core/devtools/widget/reg_view.cpp @@ -113,6 +113,7 @@ void RegView::DrawRegs() { auto& pop = extra_reg_popup.emplace_back(); pop.SetData(args...); pop.open = true; + pop.Draw(true); } else if (last_selected_cb == cb && default_reg_popup.open) { default_reg_popup.open = false; } else { @@ -120,10 +121,9 @@ void RegView::DrawRegs() { default_reg_popup.SetData(args...); if (!default_reg_popup.open) { default_reg_popup.open = true; - auto popup_pos = - GetCurrentContext()->LastItemData.Rect.Max + ImVec2(5.0f, 0.0f); - SetNextWindowPos(popup_pos, ImGuiCond_Always); - default_reg_popup.Draw(); + const auto pos = GImGui->LastItemData.Rect.Max + ImVec2(5.0f, 0.0f); + SetNextWindowPos(pos, ImGuiCond_Always); + default_reg_popup.Draw(true); } } }; diff --git a/src/imgui/imgui_std.h b/src/imgui/imgui_std.h index ce79da705..0bd77da45 100644 --- a/src/imgui/imgui_std.h +++ b/src/imgui/imgui_std.h @@ -41,7 +41,7 @@ inline void KeepWindowInside(ImVec2 display_size = GetIO().DisplaySize) { SetWindowPos(ImMax(cur_pos, ImVec2(0.0f, 0.0f))); return; } - const auto cur_size = GetWindowSize(); + const auto cur_size = GetCurrentWindowRead()->SizeFull; const auto bottom_right = cur_pos + cur_size; if (bottom_right.x > display_size.x || bottom_right.y > display_size.y) { const auto max_pos = display_size - cur_size;