Skip to content

Commit

Permalink
without x11 compile fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Etaash-mathamsetty committed Dec 8, 2024
1 parent 40d08c7 commit 74330f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/gl/gl_hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 9 additions & 12 deletions src/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 74330f1

Please sign in to comment.