diff --git a/src/gl/gl_hud.cpp b/src/gl/gl_hud.cpp index 2d03698314..eaf434abd6 100644 --- a/src/gl/gl_hud.cpp +++ b/src/gl/gl_hud.cpp @@ -22,8 +22,9 @@ #define GLX_RENDERER_VENDOR_ID_MESA 0x8183 #define GLX_RENDERER_DEVICE_ID_MESA 0x8184 +#ifdef HAVE_X11 bool glx_mesa_queryInteger(int attrib, unsigned int *value); - +#endif namespace MangoHud { namespace GL { struct GLVec @@ -148,9 +149,10 @@ void imgui_create(void *ctx, const gl_wsi plat) HUDElements.vendorID = vendorID; uint32_t device_id = 0; +#ifdef HAVE_X11 if (plat == gl_wsi::GL_WSI_GLX) glx_mesa_queryInteger(GLX_RENDERER_DEVICE_ID_MESA, &device_id); - +#endif SPDLOG_DEBUG("GL device id: {:04X}", device_id); sw_stats.gpuName = gpu = remove_parentheses(deviceName); SPDLOG_DEBUG("gpu: {}", gpu); diff --git a/src/gpu.cpp b/src/gpu.cpp index 1ad569e99f..ce1a63c6ea 100644 --- a/src/gpu.cpp +++ b/src/gpu.cpp @@ -123,7 +123,6 @@ std::string GPUS::get_pci_device_address(const std::string& drm_card_path) { void GPUS::find_active_gpu() { pid_t pid = getpid(); std::string fdinfo_dir = "/proc/" + std::to_string(pid) + "/fdinfo/"; - bool active_gpu_found = false; for (const auto& entry : fs::directory_iterator(fdinfo_dir)) { if (entry.is_regular_file()) { @@ -166,19 +165,17 @@ void GPUS::find_active_gpu() { // NVIDIA GPUs will not show up in fdinfo so we use NVML instead to find the active GPU // This will not work for older NVIDIA GPUs #ifdef HAVE_NVML - if (!active_gpu_found) { - for (const auto& gpu : available_gpus) { - // NVIDIA vendor ID is 0x10de - if (gpu->vendor_id == 0x10de && gpu->nvidia->nvml_available) { - for (auto& pid : gpu->nvidia_pids()) { - if (pid == getpid()) { - gpu->is_active = true; - SPDLOG_DEBUG("Active GPU Found: node_name: {}, pci_dev: {}", gpu->name, gpu->pci_dev); - return; - } + for (const auto& gpu : available_gpus) { + // NVIDIA vendor ID is 0x10de + if (gpu->vendor_id == 0x10de && gpu->nvidia->nvml_available) { + for (auto& pid : gpu->nvidia_pids()) { + if (pid == getpid()) { + gpu->is_active = true; + SPDLOG_DEBUG("Active GPU Found: node_name: {}, pci_dev: {}", gpu->name, gpu->pci_dev); + return; } - } + } } #endif