From 8ffb514dc8484b902139dd897d478ce8bd33ae33 Mon Sep 17 00:00:00 2001 From: Etaash Mathamsetty Date: Sun, 8 Dec 2024 12:16:01 -0500 Subject: [PATCH] without x11 compile fixes --- src/gl/gl_hud.cpp | 3 ++- src/gpu.cpp | 21 +++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/gl/gl_hud.cpp b/src/gl/gl_hud.cpp index 2d03698314..3f811a1b66 100644 --- a/src/gl/gl_hud.cpp +++ b/src/gl/gl_hud.cpp @@ -148,9 +148,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