Fix gpu_fan for AMD

It was incorrectly checking deviceID instead of vendorID.
We also use hwmon for fan reading just in case.
winesync
flightlessmango 7 months ago
parent 2c32046770
commit f351515265

@ -81,6 +81,7 @@ static void ctrl_thread(){
const struct mangoapp_ctrl_msgid1_v1 *mangoapp_ctrl_v1 = (const struct mangoapp_ctrl_msgid1_v1*) raw_msg;
memset(raw_msg, 0, sizeof(raw_msg));
msgrcv(msgid, (void *) raw_msg, sizeof(raw_msg), 2, 0);
printf("got msg\n");
switch (mangoapp_ctrl_v1->log_session) {
case 0:
// Keep as-is
@ -126,7 +127,23 @@ static void ctrl_thread(){
break;
}
}
printf("before debug check\n");
if (mangoapp_ctrl_v1->debug){
struct mangoapp_ctrl_msgid1_v1 ctrl_msg;
ctrl_msg.hdr.ctrl_msg_type = 1;
ctrl_msg.hdr.msg_type = 3;
char resp[10240] = "";
for (auto& option : HUDElements.options){
strcat(resp, option.first.c_str());
strcat(resp, "\n");
}
strcat(ctrl_msg.debug_response, resp);
printf("sending msg\n");
int ret = msgsnd(msgid, &raw_msg, sizeof(raw_msg), IPC_NOWAIT);
printf("ret: %i\n", ret);
}
mangoapp_cv.notify_one();
printf("back to top\n");
}
}
@ -151,7 +168,7 @@ static void msg_read_thread(){
HUDElements.gamescope_debug_app.push_back(0);
HUDElements.gamescope_debug_latency.push_back(0);
}
int key = ftok("mangoapp", 65);
int key = ftok("/tmp/mangoapp", 65);
msgid = msgget(key, 0666 | IPC_CREAT);
// uint32_t previous_pid = 0;
const struct mangoapp_msg_header *hdr = (const struct mangoapp_msg_header*) raw_msg;
@ -316,6 +333,8 @@ int main(int, char**)
vendorID = 0x10de;
}
}
HUDElements.vendorID = vendorID;
init_gpu_stats(vendorID, 0, params);
init_system_info();
sw_stats.engine = EngineTypes::GAMESCOPE;

@ -143,6 +143,8 @@ void imgui_create(void *ctx, const gl_wsi plat)
vendorID = 0x10de;
}
HUDElements.vendorID = vendorID;
uint32_t device_id = 0;
if (plat == gl_wsi::GL_WSI_GLX)
glx_mesa_queryInteger(GLX_RENDERER_DEVICE_ID_MESA, &device_id);

@ -94,7 +94,6 @@ void getAmdGpuInfo(){
gpu_info.load = value;
}
if (amdgpu.memory_clock) {
rewind(amdgpu.memory_clock);
fflush(amdgpu.memory_clock);
@ -112,16 +111,16 @@ void getAmdGpuInfo(){
gpu_info.powerUsage = value / 1000000;
}
if (amdgpu.fan) {
rewind(amdgpu.fan);
fflush(amdgpu.fan);
if (fscanf(amdgpu.fan, "%" PRId64, &value) != 1)
value = 0;
gpu_info.fan_speed = value;
}
}
if (amdgpu.fan) {
rewind(amdgpu.fan);
fflush(amdgpu.fan);
if (fscanf(amdgpu.fan, "%" PRId64, &value) != 1)
value = 0;
gpu_info.fan_speed = value;
}
if (amdgpu.vram_total) {
rewind(amdgpu.vram_total);
fflush(amdgpu.vram_total);

@ -24,6 +24,7 @@
#include "implot.h"
#endif
#include "amdgpu.h"
#include "fps_metrics.h"
#define CHAR_CELSIUS "\xe2\x84\x83"
#define CHAR_FAHRENHEIT "\xe2\x84\x89"
@ -236,19 +237,19 @@ void HudElements::gpu_stats(){
ImGui::PopFont();
}
if (deviceID == 7815 || deviceID == 29772){
if (HUDElements.vendorID == 0x1002 || HUDElements.vendorID == 0x10de){
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_fan] && cpuStats.cpu_type != "APU"){
ImguiNextColumnOrNewRow();
right_aligned_text(text_color, HUDElements.ralign_width, "%i", gpu_info.fan_speed);
ImGui::SameLine(0, 1.0f);
// if Nvidia GPU
if (deviceID == 7815) {
if (HUDElements.vendorID == 0x10de) {
HUDElements.TextColored(HUDElements.colors.text, "%%");
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::SameLine(0, 1.0f);
HUDElements.TextColored(HUDElements.colors.text, "FAN");
// if AMD GPU
} else if (deviceID == 29772) {
} else if (HUDElements.vendorID == 0x1002) {
ImGui::PushFont(HUDElements.sw_stats->font1);
HUDElements.TextColored(HUDElements.colors.text, "RPM");
}
@ -1358,6 +1359,34 @@ void HudElements::exec_name(){
}
}
void HudElements::fps_metrics(){
for (auto& metric : fpsmetrics->metrics){
ImguiNextColumnFirstItem();
HUDElements.TextColored(HUDElements.colors.engine, "%s", metric.display_name.c_str());
ImguiNextColumnOrNewRow();
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%.0f", metric.value);
ImGui::SameLine(0, 1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
HUDElements.TextColored(HUDElements.colors.text, "FPS");
ImGui::PopFont();
ImguiNextColumnOrNewRow();
}
// HUDElements.TextColored(HUDElements.colors.engine, "%s", "AVG");
// ImguiNextColumnOrNewRow();
// right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%.0f", HUDElements.fps_avg);
// ImGui::SameLine(0, 1.0f);
// ImGui::PushFont(HUDElements.sw_stats->font1);
// HUDElements.TextColored(HUDElements.colors.text, "FPS");
// ImGui::PopFont();
// ImguiNextColumnOrNewRow();
// right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%.1f", 1000 / HUDElements.fps_avg);
// ImGui::SameLine(0, 1.0f);
// ImGui::PushFont(HUDElements.sw_stats->font1);
// HUDElements.TextColored(HUDElements.colors.text, "ms");
// ImGui::PopFont();
}
void HudElements::sort_elements(const std::pair<std::string, std::string>& option) {
const auto& param = option.first;
const auto& value = option.second;
@ -1399,7 +1428,8 @@ void HudElements::sort_elements(const std::pair<std::string, std::string>& optio
{"throttling_status", {throttling_status}},
{"exec_name", {exec_name}},
{"duration", {duration}},
{"graphs", {graphs}}
{"graphs", {graphs}},
{"fps_metrics", {fps_metrics}}
};
auto check_param = display_params.find(param);
@ -1471,6 +1501,8 @@ void HudElements::legacy_elements(){
ordered_functions.push_back({throttling_status, "throttling_status", value});
if (params->enabled[OVERLAY_PARAM_ENABLED_fps])
ordered_functions.push_back({fps, "fps", value});
if (!params->fps_metrics.empty())
ordered_functions.push_back({fps_metrics, "fps_metrics", value});
if (params->enabled[OVERLAY_PARAM_ENABLED_fps_only])
ordered_functions.push_back({fps_only, "fps_only", value});
if (params->enabled[OVERLAY_PARAM_ENABLED_engine_version])

@ -43,6 +43,7 @@ class HudElements{
};
std::vector<exec_entry> exec_list;
std::chrono::steady_clock::time_point overlay_start = std::chrono::steady_clock::now();
uint32_t vendorID;
void sort_elements(const std::pair<std::string, std::string>& option);
void legacy_elements();

@ -1528,6 +1528,7 @@ static VkResult overlay_CreateSwapchainKHR(
swapchain_data->sw_stats.engineVersion = device_data->instance->engineVersion;
swapchain_data->sw_stats.engine = device_data->instance->engine;
HUDElements.vendorID = prop.vendorID;
std::stringstream ss;
// ss << prop.deviceName;
if (prop.vendorID == 0x10de) {

Loading…
Cancel
Save