Skip to content

Commit

Permalink
add NVDEC, NVENC, and VIC
Browse files Browse the repository at this point in the history
  • Loading branch information
theofficialgman committed Apr 30, 2024
1 parent d9f7262 commit f8341e7
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ gpu_info.load = std::stoi(read_line("/sys/devices/gpu.0/load")) / 10;
// gpu_info.temp = nvidiaTemp;
// gpu_info.memoryUsed = nvidiaMemory.used / (1024.f * 1024.f * 1024.f);
gpu_info.CoreClock = std::stoi(read_line("/sys/devices/gpu.0/devfreq/57000000.gpu/cur_freq")) / 1000000 ;
if (file_exists("/sys/kernel/debug/clk/nvdec/clk_rate")) {
if (read_line("/sys/kernel/debug/clk/nvdec/clk_state") == "1") gpu_info.NVDECClock = std::stoi(read_line("/sys/kernel/debug/clk/nvdec/clk_rate")) / 1000000 ; else gpu_info.NVDECClock = 0 ;
}
if (file_exists("/sys/kernel/debug/clk/nvenc/clk_rate")) {
if (read_line("/sys/kernel/debug/clk/nvenc/clk_state") == "1") gpu_info.NVENCClock = std::stoi(read_line("/sys/kernel/debug/clk/nvenc/clk_rate")) / 1000000 ; else gpu_info.NVENCClock = 0 ;
}
if (file_exists("/sys/kernel/debug/clk/vic03/clk_rate")) {
if (read_line("/sys/kernel/debug/clk/vic03/clk_state") == "1") gpu_info.VICClock = std::stoi(read_line("/sys/kernel/debug/clk/vic03/clk_rate")) / 1000000 ; else gpu_info.VICClock = 0 ;
}
}

void getAmdGpuInfo(){
Expand Down
3 changes: 3 additions & 0 deletions src/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ struct gpuInfo{
float memoryTotal;
int MemClock;
int CoreClock;
int NVDECClock;
int NVENCClock;
int VICClock;
float powerUsage;
float apu_cpu_power;
int apu_cpu_temp;
Expand Down
69 changes: 69 additions & 0 deletions src/hud_elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,39 @@ void HudElements::gpu_stats(){
HUDElements.TextColored(HUDElements.colors.text, "mV");
ImGui::PopFont();
}
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_nvdec_clock]){
ImGui::TableNextColumn();
ImGui::TextColored(HUDElements.colors.gpu, "%s", "NVDEC");
ImGui::TableNextColumn();
ImguiNextColumnOrNewRow();
right_aligned_text(text_color, HUDElements.ralign_width, "%i", gpu_info.NVDECClock);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("MHz");
ImGui::PopFont();
}
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_nvenc_clock]){
ImGui::TableNextColumn();
ImGui::TextColored(HUDElements.colors.gpu, "%s", "NVENC");
ImGui::TableNextColumn();
ImguiNextColumnOrNewRow();
right_aligned_text(text_color, HUDElements.ralign_width, "%i", gpu_info.NVENCClock);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("MHz");
ImGui::PopFont();
}
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_vic_clock]){
ImGui::TableNextColumn();
ImGui::TextColored(HUDElements.colors.gpu, "%s", "VIC");
ImGui::TableNextColumn();
ImguiNextColumnOrNewRow();
right_aligned_text(text_color, HUDElements.ralign_width, "%i", gpu_info.VICClock);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Text("MHz");
ImGui::PopFont();
}
}
}

Expand Down Expand Up @@ -1338,6 +1371,42 @@ void HudElements::graphs(){
HUDElements.TextColored(HUDElements.colors.engine, "%s", "GPU Core Clock");
}

if (value == "gpu_nvdec_clock"){
for (auto& it : graph_data){
arr.push_back(float(it.gpu_nvdec_clock));
}
if (int(arr.back()) > HUDElements.gpu_nvdec_max)
HUDElements.gpu_nvdec_max = arr.back();

HUDElements.max = HUDElements.gpu_nvdec_max;
HUDElements.min = 0;
ImGui::TextColored(HUDElements.colors.engine, "%s", "NVDEC Clock");
}

if (value == "gpu_nvenc_clock"){
for (auto& it : graph_data){
arr.push_back(float(it.gpu_nvenc_clock));
}
if (int(arr.back()) > HUDElements.gpu_nvenc_max)
HUDElements.gpu_nvenc_max = arr.back();

HUDElements.max = HUDElements.gpu_nvenc_max;
HUDElements.min = 0;
ImGui::TextColored(HUDElements.colors.engine, "%s", "NVENC Clock");
}

if (value == "gpu_vic_clock"){
for (auto& it : graph_data){
arr.push_back(float(it.gpu_vic_clock));
}
if (int(arr.back()) > HUDElements.gpu_vic_max)
HUDElements.gpu_vic_max = arr.back();

HUDElements.max = HUDElements.gpu_vic_max;
HUDElements.min = 0;
ImGui::TextColored(HUDElements.colors.engine, "%s", "VIC Clock");
}

if (value == "gpu_mem_clock"){
for (auto& it : graph_data){
arr.push_back(float(it.gpu_mem_clock));
Expand Down
4 changes: 2 additions & 2 deletions src/hud_elements.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class HudElements{
std::vector<Function> ordered_functions;
std::vector<float> gamescope_debug_latency {};
std::vector<float> gamescope_debug_app {};
int min, max, gpu_core_max, gpu_mem_max, cpu_temp_max, gpu_temp_max;
int min, max, gpu_core_max, gpu_nvdec_max, gpu_nvenc_max, gpu_vic_max, gpu_mem_max, cpu_temp_max, gpu_temp_max;
const std::vector<std::string> permitted_params = {
"gpu_load", "cpu_load", "gpu_core_clock", "gpu_mem_clock",
"gpu_load", "cpu_load", "gpu_core_clock", "gpu_nvdec_clock", "gpu_nvenc_max", "gpu_vic_max", "gpu_mem_clock",
"vram", "ram", "cpu_temp", "gpu_temp"
};
std::vector<exec_entry> exec_list;
Expand Down
3 changes: 3 additions & 0 deletions src/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ struct logData{
int cpu_temp;
int gpu_temp;
int gpu_core_clock;
int gpu_nvdec_clock;
int gpu_nvenc_clock;
int gpu_vic_clock;
int gpu_mem_clock;
int gpu_power;
float gpu_vram_used;
Expand Down
3 changes: 3 additions & 0 deletions src/overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ void update_hw_info(const struct overlay_params& params, uint32_t vendorID)
currentLogData.gpu_load = gpu_info.load;
currentLogData.gpu_temp = gpu_info.temp;
currentLogData.gpu_core_clock = gpu_info.CoreClock;
currentLogData.gpu_nvdec_clock = gpu_info.NVDECClock;
currentLogData.gpu_nvenc_clock = gpu_info.NVENCClock;
currentLogData.gpu_vic_clock = gpu_info.VICClock;
currentLogData.gpu_mem_clock = gpu_info.MemClock;
currentLogData.gpu_vram_used = gpu_info.memoryUsed;
currentLogData.gpu_power = gpu_info.powerUsage;
Expand Down
3 changes: 3 additions & 0 deletions src/overlay_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ typedef unsigned long KeySym;
OVERLAY_PARAM_BOOL(io_write) \
OVERLAY_PARAM_BOOL(gpu_mem_clock) \
OVERLAY_PARAM_BOOL(gpu_core_clock) \
OVERLAY_PARAM_BOOL(gpu_nvdec_clock) \
OVERLAY_PARAM_BOOL(gpu_nvenc_clock) \
OVERLAY_PARAM_BOOL(gpu_vic_clock) \
OVERLAY_PARAM_BOOL(gpu_power) \
OVERLAY_PARAM_BOOL(arch) \
OVERLAY_PARAM_BOOL(media_player) \
Expand Down

0 comments on commit f8341e7

Please sign in to comment.