power graph

steamdeck-power
flightlessmango 5 months ago
parent f168483c3e
commit 5f237ae882

@ -173,6 +173,8 @@ void amdgpu_get_instant_metrics(struct amdgpu_common_metrics *metrics) {
metrics->apu_cpu_temp_c = 0;
}
metrics->average_soc_power_w = amdgpu_metrics->average_socket_power / 1000.f;
indep_throttle_status = amdgpu_metrics->indep_throttle_status;
}
@ -183,8 +185,10 @@ void amdgpu_get_instant_metrics(struct amdgpu_common_metrics *metrics) {
metrics->is_current_throttled = ((indep_throttle_status >> 16) & 0xFF) != 0;
metrics->is_temp_throttled = ((indep_throttle_status >> 32) & 0xFFFF) != 0;
metrics->is_other_throttled = ((indep_throttle_status >> 56) & 0xFF) != 0;
if (throttling)
if (throttling) {
throttling->indep_throttle_status = indep_throttle_status;
throttling->avg_soc_power = metrics->average_soc_power_w;
}
}
void amdgpu_get_samples_and_copy(struct amdgpu_common_metrics metrics_buffer[METRICS_SAMPLE_COUNT], bool &gpu_load_needs_dividing) {
@ -206,6 +210,7 @@ void amdgpu_get_samples_and_copy(struct amdgpu_common_metrics metrics_buffer[MET
UPDATE_METRIC_AVERAGE(gpu_load_percent);
UPDATE_METRIC_AVERAGE_FLOAT(average_gfx_power_w);
UPDATE_METRIC_AVERAGE_FLOAT(average_cpu_power_w);
UPDATE_METRIC_AVERAGE_FLOAT(average_soc_power_w);
UPDATE_METRIC_AVERAGE(current_gfxclk_mhz);
UPDATE_METRIC_AVERAGE(current_uclk_mhz);

@ -11,6 +11,7 @@
#include <vector>
#include <sys/param.h>
#include <algorithm>
#include <numeric>
#define METRICS_UPDATE_PERIOD_MS 500
#define METRICS_POLLING_PERIOD_MS 25
@ -173,6 +174,7 @@ struct amdgpu_common_metrics {
/* Power usage: averaged across the sampling period */
float average_gfx_power_w;
float average_cpu_power_w;
float average_soc_power_w;
/* Clocks: latest value of the clock */
uint16_t current_gfxclk_mhz;
@ -206,18 +208,39 @@ class Throttling {
public:
std::vector<float> power;
std::vector<float> thermal;
std::vector<float> power_w;
int64_t indep_throttle_status;
bool steamdeck = false;
float avg_soc_power;
float avg_soc_power_graph;
int power_limit;
Throttling()
: power(200, 0.0f),
thermal(200, 0.0f) {}
thermal(200, 0.0f),
power_w(200, 0.0f) {
if (getenv("STEAM_USE_MANGOAPP"))
steamdeck = true;
}
void update(){
if (((indep_throttle_status >> 0) & 0xFF) != 0)
power.push_back(0.1);
else
power.push_back(0);
if (steamdeck) {
if ((indep_throttle_status & (1LL << 4)) != 0)
power.push_back(0.1);
else
power.push_back(0);
power_w.push_back(avg_soc_power);
float sum = std::accumulate(power_w.begin(), power_w.end(), 0.0f);
avg_soc_power_graph = sum / power_w.size();
power_w.erase(power_w.begin());
} else {
if (((indep_throttle_status >> 0) & 0xFF) != 0)
power.push_back(0.1);
else
power.push_back(0);
}
if (((indep_throttle_status >> 32) & 0xFFFF) != 0)
thermal.push_back(0.1);

@ -1327,11 +1327,21 @@ void HudElements::graphs(){
HUDElements.min = 0;
HUDElements.TextColored(HUDElements.colors.engine, "%s", "RAM");
}
if (value == "power"){
if (!throttling)
return;
arr.resize(throttling->power_w.size());
arr = throttling->power_w;
HUDElements.max = 15;
HUDElements.min = 0;
HUDElements.TextColored(HUDElements.colors.engine, "%s %.1fw/%iw", "Power", throttling->avg_soc_power_graph, 15);
}
#endif
ImGui::PopFont();
ImGui::Dummy(ImVec2(0.0f,5.0f));
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
ImguiNextColumnOrNewRow();
if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_histogram]){
ImGui::PlotLines("", arr.data(),
arr.size(), 0,

@ -1108,6 +1108,8 @@ void presets(int preset, struct overlay_params *params, bool inherit) {
add_to_options(params, "hdr", "1");
add_to_options(params, "refresh_rate", "1");
add_to_options(params, "media_player", "0");
add_to_options(params, "gpu_name", "0");
add_to_options(params, "graphs", "power");
break;
}

Loading…
Cancel
Save