Skip to content

Commit 5f0eba2

Browse files
committed
v0.0.2: add export to json, details window, add ability to set app path and version
1 parent e79d338 commit 5f0eba2

9 files changed

Lines changed: 235 additions & 7 deletions

src/include/amd_gpu_profilemanager_application.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace OST::AMD::GPU::ProfileManager {
2727
public:
2828
Application() = default;
2929
Application(const APPLICATION& app);
30-
Application(const std::wstring& filename, const std::wstring& title);
30+
Application(const std::wstring& filename, const std::wstring& title, const std::wstring& path, const std::wstring& version);
3131
bool LoadCustomization(const APPLICATION& app);
3232

3333
[[nodiscard]] const std::wstring GetDesignator() const { return m_designator; }

src/src/amd_gpu_profilemanager_application.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace OST::AMD::GPU::ProfileManager {
1919
LoadCustomization(app);
2020
}
2121

22-
Application::Application(const std::wstring& filename, const std::wstring& title) : m_filename(filename), m_title(title)
22+
Application::Application(const std::wstring& filename, const std::wstring& title, const std::wstring& path, const std::wstring& version) : m_filename(filename), m_title(title), m_path(path), m_version(version)
2323
{
2424
m_designator = GetFileName() + L"|" + GetPath() + L"|" + GetTitle() + L"|" + GetVersion();
2525
}

src/src/amd_gpu_profilemanager_db.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ namespace OST::AMD::GPU::ProfileManager {
123123
{"profiles", db.m_profiles}
124124
};
125125

126-
nlohmann::json apps_json = nlohmann::json::object();
126+
nlohmann::json apps_json = nlohmann::json::array();
127127
for (const auto& [key, val] : db.m_applications) {
128-
apps_json[Utils::ToUtf8(key)] = *val;
128+
apps_json.push_back(*val);
129129
}
130130
j["applications"] = apps_json;
131131
}

src_app/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
if(WIN32)
55
add_executable(ost_amd_gpu_profilemanager_gui WIN32)
66
else()
7-
add_executable(ost_amd_gpu_profilemanager_gui)
7+
add_executable(ost_amd_gpu_profilemanager_gui
8+
window_details.cpp
9+
app_info.h)
810
endif()
911

1012
target_sources(ost_amd_gpu_profilemanager_gui PRIVATE
1113
"main.cpp"
14+
"window_details.cpp"
1215
"window_main.cpp"
1316
)
1417

src_app/app_info.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2025, Open System Telemetry contributors
2+
// SPDX-License-Identifier: MIT
3+
4+
#pragma once
5+
6+
//
7+
// Includes
8+
//
9+
10+
// stdlib
11+
#include <memory>
12+
#include <string>
13+
14+
// gpu profile manager
15+
#include "amd_gpu_profilemanager_application.h"
16+
17+
18+
19+
//
20+
// Class
21+
//
22+
namespace OST::AMD::GPU::ProfileManager {
23+
struct AppDisplayInfo {
24+
std::shared_ptr<OST::AMD::GPU::ProfileManager::Application> app;
25+
std::string m_designator;
26+
bool fsr_enabled;
27+
};
28+
}

src_app/window_details.cpp

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// Copyright 2025, Open System Telemetry contributors
2+
// SPDX-License-Identifier: MIT
3+
4+
//
5+
// Includes
6+
//
7+
8+
// stdlib
9+
#include <algorithm>
10+
#include <string>
11+
#include <locale>
12+
13+
// ImGUI
14+
#include <imgui.h>
15+
16+
// GPU Profile Manager
17+
#include "amd_gpu_profilemanager_utils.h"
18+
#include "window_details.h"
19+
20+
21+
//
22+
// Implementation
23+
//
24+
25+
namespace OST::AMD::GPU::ProfileManager {
26+
WindowDetails::WindowDetails(std::shared_ptr<OST::AMD::GPU::ProfileManager::Application> app) {
27+
m_adl_app = std::move(app);
28+
}
29+
30+
WindowDetails::~WindowDetails() {}
31+
32+
33+
34+
//
35+
// UI
36+
//
37+
38+
bool WindowDetails::UiUpdate() {
39+
bool show{true};
40+
41+
const auto* viewport = ImGui::GetMainViewport();
42+
ImGui::SetNextWindowSize({viewport->Size.x*0.8f,viewport->Size.y*0.8f});
43+
ImGui::SetNextWindowPos({viewport->Size.x*0.1f,viewport->Size.y*0.1f});
44+
ImGui::OpenPopup("Details");
45+
if (ImGui::BeginPopupModal("Details", &show, ImGuiWindowFlags_AlwaysAutoResize)) {
46+
if (ImGui::CollapsingHeader("Overview", ImGuiTreeNodeFlags_DefaultOpen)) {
47+
if(ImGui::BeginTable("Overview", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg )) {
48+
ImGui::TableNextRow();
49+
ImGui::TableNextColumn();
50+
ImGui::TextUnformatted("Title");
51+
ImGui::TableNextColumn();
52+
ImGui::TextUnformatted(Utils::ToUtf8(m_adl_app->GetTitle()).c_str());
53+
54+
55+
ImGui::TableNextColumn();
56+
ImGui::TextUnformatted("File name");
57+
ImGui::TableNextColumn();
58+
ImGui::TextUnformatted(Utils::ToUtf8(m_adl_app->GetFileName()).c_str());
59+
60+
ImGui::TableNextRow();
61+
ImGui::TableNextColumn();
62+
ImGui::Text("File path");
63+
ImGui::TableNextColumn();
64+
ImGui::TextUnformatted(Utils::ToUtf8(m_adl_app->GetPath()).c_str());
65+
66+
67+
ImGui::TableNextRow();
68+
ImGui::TableNextColumn();
69+
ImGui::TextUnformatted("Version");
70+
ImGui::TableNextColumn();
71+
ImGui::TextUnformatted(Utils::ToUtf8(m_adl_app->GetVersion()).c_str());
72+
73+
ImGui::EndTable();
74+
}
75+
}
76+
77+
ImGui::NewLine();
78+
79+
if (ImGui::CollapsingHeader("Uses", ImGuiTreeNodeFlags_DefaultOpen)) {
80+
if(ImGui::BeginTable("Uses", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg )) {
81+
ImGui::TableSetupColumn("Driver component");
82+
ImGui::TableSetupColumn("Profile");
83+
ImGui::TableHeadersRow();
84+
85+
const auto& uses = m_adl_app->GetUses();
86+
for (size_t idx = 0; idx < uses.size(); idx++) {
87+
ImGui::TableNextRow();
88+
ImGui::TableNextColumn();
89+
ImGui::Text("%ls", uses[idx].GetDriver().c_str());
90+
ImGui::TableNextColumn();
91+
ImGui::Text("%ls", uses[idx].GetName().c_str());
92+
}
93+
94+
ImGui::EndTable();
95+
}
96+
}
97+
ImGui::EndPopup();
98+
}
99+
100+
return show;
101+
}
102+
}

src_app/window_details.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2025, Open System Telemetry contributors
2+
// SPDX-License-Identifier: MIT
3+
4+
#pragma once
5+
6+
//
7+
// Includes
8+
//
9+
10+
// stdlib
11+
#include <map>
12+
#include <memory>
13+
#include <vector>
14+
15+
// ADL
16+
#include <adl_sdk_extra.h>
17+
18+
// Uni.GUI
19+
#include "ui_element.h"
20+
21+
// GPU Profile Manager
22+
#include "amd_gpu_profilemanager_db.h"
23+
#include "amd_gpu_profilemanager_application.h"
24+
25+
26+
27+
//
28+
// Public
29+
//
30+
31+
namespace OST::AMD::GPU::ProfileManager {
32+
class WindowDetails: public Uni::GUI::UiElement {
33+
public:
34+
explicit WindowDetails(std::shared_ptr<OST::AMD::GPU::ProfileManager::Application> app);
35+
~WindowDetails() override;
36+
37+
// ADL
38+
private:
39+
std::shared_ptr<OST::AMD::GPU::ProfileManager::Application> m_adl_app;
40+
41+
// UI
42+
public:
43+
bool UiUpdate() override;
44+
};
45+
}

src_app/window_main.cpp

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
#include <map>
1212
#include <locale>
1313

14+
#include <fstream>
15+
16+
// SDL
17+
#include <SDL3/SDL_dialog.h>
18+
1419
// ImGUI
1520
#include <imgui.h>
1621
#include <misc/cpp/imgui_stdlib.h>
@@ -19,6 +24,11 @@
1924
#include "window_main.h" // Primary header for this implementation file
2025
#include "amd_gpu_profilemanager_db.h"
2126
#include "amd_gpu_profilemanager_utils.h"
27+
#include "amd_gpu_profilemanager_application.h"
28+
#include "amd_gpu_profilemanager_profile.h"
29+
#include "amd_gpu_profilemanager_property.h"
30+
#include "amd_gpu_profilemanager_use.h"
31+
#include <nlohmann/json.hpp>
2232

2333

2434

@@ -57,6 +67,7 @@ namespace OST::AMD::GPU::ProfileManager {
5767

5868

5969

70+
6071
//
6172
// DB
6273
//
@@ -92,6 +103,21 @@ namespace OST::AMD::GPU::ProfileManager {
92103
m_db_cache_dirty = false;
93104
}
94105

106+
void WindowMain::dbSaveCallback(void* userdata, const char* const* files, int filte) {
107+
if (!files[0]) {
108+
return;
109+
}
110+
auto* cls = reinterpret_cast<WindowMain*>(userdata);
111+
auto filepath = std::filesystem::path(files[0]);
112+
filepath.replace_extension("json");
113+
cls->m_db[cls->m_current_db_source]->SaveJson(filepath);
114+
}
115+
116+
void WindowMain::dbSave() {
117+
SDL_Window* sdl_window = (SDL_Window*)ImGui::GetMainViewport()->PlatformHandle;
118+
SDL_DialogFileFilter filters[1] = { { "JSON", "json" } };
119+
SDL_ShowSaveFileDialog(WindowMain::dbSaveCallback, this, sdl_window, filters, 1, nullptr);
120+
}
95121

96122

97123
//
@@ -112,6 +138,13 @@ namespace OST::AMD::GPU::ProfileManager {
112138
}
113139

114140
ImGui::End();
141+
142+
if (m_ui_details) {
143+
if (!m_ui_details->UiUpdate()) {
144+
m_ui_details.reset();
145+
}
146+
}
147+
115148
return true;
116149
}
117150

@@ -123,6 +156,10 @@ namespace OST::AMD::GPU::ProfileManager {
123156
dbRefresh();
124157
}
125158

159+
if (ImGui::Button("Export")) {
160+
dbSave();
161+
}
162+
126163
ImGui::Separator();
127164

128165
if (ImGui::RadioButton("System", m_current_db_source == ADL_AP_DATABASE__SYSTEM)) {
@@ -266,7 +303,11 @@ namespace OST::AMD::GPU::ProfileManager {
266303
ImGui::EndDisabled();
267304

268305
ImGui::SameLine();
306+
if (ImGui::Button("Details")) {
307+
m_ui_details = std::make_unique<WindowDetails>(app.app);
308+
}
269309

310+
ImGui::SameLine();
270311
ImGui::BeginDisabled(cur_source != ADL_AP_DATABASE__USER);
271312
if (ImGui::Button("Remove")) {
272313
app.app->Remove(m_adl_context);
@@ -295,15 +336,21 @@ namespace OST::AMD::GPU::ProfileManager {
295336
{
296337
static char filename[128] = "";
297338
static char title[128] = "";
339+
static char path[128] = "";
340+
static char version[128] = "";
298341

299342
ImGui::InputText("Filename", filename, IM_ARRAYSIZE(filename));
300343
ImGui::InputText("Title", title, IM_ARRAYSIZE(title));
344+
ImGui::InputText("Path", path, IM_ARRAYSIZE(path));
345+
ImGui::InputText("Version", version, IM_ARRAYSIZE(version));
301346

302347
if (ImGui::Button("OK", ImVec2(120, 0))) {
303348
std::wstring w_filename = Utils::ToUtf16(filename);
304349
std::wstring w_title = Utils::ToUtf16(title);
350+
std::wstring w_path = Utils::ToUtf16(path);
351+
std::wstring w_version = Utils::ToUtf16(version);
305352

306-
Application app(w_filename, w_title);
353+
Application app(w_filename, w_title, w_path, w_version);
307354
app.AssignProfile(m_adl_context, L"FSROVR", L"FsrOvrWhitelistProfile");
308355

309356
m_db_cache_dirty = true;

src_app/window_main.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// GPU Profile Manager
2222
#include "amd_gpu_profilemanager_db.h"
23-
23+
#include "window_details.h"
2424

2525

2626
//
@@ -49,6 +49,8 @@ namespace OST::AMD::GPU::ProfileManager {
4949
// DB
5050
private:
5151
void dbRefresh();
52+
void dbSave();
53+
static void dbSaveCallback(void* userdata, const char* const* files, int filte);
5254
private:
5355
std::map<ADL_AP_DATABASE, std::unique_ptr<OST::AMD::GPU::ProfileManager::DB>> m_db;
5456
std::map<ADL_AP_DATABASE, std::vector<AppDisplayInfo>> m_db_cache;
@@ -63,5 +65,6 @@ namespace OST::AMD::GPU::ProfileManager {
6365
void uiUpdateModalCreateNewProfile();
6466
private:
6567
char m_search_buffer[256]{};
68+
std::unique_ptr<WindowDetails> m_ui_details;
6669
};
6770
}

0 commit comments

Comments
 (0)