mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-15 09:05:58 +01:00
Improve GPU debug reports
Instead of using weird "hacks" to get GPU information, Just get whatever libdrm reports. This is by no means perfect and omits specific GPU details such as the model.
This commit is contained in:
parent
cae937c51b
commit
3bc7601c56
2 changed files with 38 additions and 15 deletions
|
@ -14,6 +14,9 @@
|
|||
#include <sys/poll.h>
|
||||
#include <filesystem>
|
||||
#include <ranges>
|
||||
#include <fcntl.h>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
@ -920,14 +923,24 @@ std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request)
|
|||
|
||||
result += "\n\n";
|
||||
|
||||
#if defined(__DragonFly__) || defined(__FreeBSD__)
|
||||
const std::string GPUINFO = execAndGet("pciconf -lv | fgrep -A4 vga");
|
||||
#elif defined(__arm__) || defined(__aarch64__)
|
||||
const std::string GPUINFO = execAndGet("cat /proc/device-tree/soc*/gpu*/compatible");
|
||||
#else
|
||||
const std::string GPUINFO = execAndGet("lspci -vnn | grep VGA");
|
||||
#endif
|
||||
result += "GPU information: \n" + GPUINFO;
|
||||
int fd = open("/dev/dri/card0", O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
throw std::runtime_error("Failed to open /dev/dri/card0");
|
||||
}
|
||||
drmVersion* version = drmGetVersion(fd);
|
||||
if (!version) {
|
||||
close(fd);
|
||||
throw std::runtime_error("Failed to get DRM version");
|
||||
}
|
||||
const std::string name = version->name ? version->name : "Unknown";
|
||||
const std::string description = version->desc ? version->desc : "Unknown";
|
||||
std::string GPUINFO = "GPU information:\n";
|
||||
GPUINFO += "GPU Type: " + name + "\n";
|
||||
GPUINFO += "Driver Description: " + description + "\n";
|
||||
|
||||
result += GPUINFO;
|
||||
|
||||
|
||||
if (GPUINFO.contains("NVIDIA") && std::filesystem::exists("/proc/driver/nvidia/version"))
|
||||
result += execAndGet("cat /proc/driver/nvidia/version | grep NVRM");
|
||||
result += "\n\n";
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include <fcntl.h>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#ifdef HAS_EXECINFO
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
@ -609,13 +611,21 @@ void logSystemInfo() {
|
|||
|
||||
Debug::log(NONE, "\n");
|
||||
|
||||
#if defined(__DragonFly__) || defined(__FreeBSD__)
|
||||
const std::string GPUINFO = execAndGet("pciconf -lv | fgrep -A4 vga");
|
||||
#elif defined(__arm__) || defined(__aarch64__)
|
||||
const std::string GPUINFO = execAndGet("cat /proc/device-tree/soc*/gpu*/compatible");
|
||||
#else
|
||||
const std::string GPUINFO = execAndGet("lspci -vnn | grep VGA");
|
||||
#endif
|
||||
int fd = open("/dev/dri/card0", O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
throw std::runtime_error("Failed to open /dev/dri/card0");
|
||||
}
|
||||
drmVersion* version = drmGetVersion(fd);
|
||||
if (!version) {
|
||||
close(fd);
|
||||
throw std::runtime_error("Failed to get DRM version");
|
||||
}
|
||||
const std::string name = version->name ? version->name : "Unknown";
|
||||
const std::string description = version->desc ? version->desc : "Unknown";
|
||||
std::string GPUINFO;
|
||||
GPUINFO += "GPU Type: " + name + "\n";
|
||||
GPUINFO += "Driver Description: " + description + "\n";
|
||||
|
||||
Debug::log(LOG, "GPU information:\n{}\n", GPUINFO);
|
||||
|
||||
if (GPUINFO.contains("NVIDIA")) {
|
||||
|
|
Loading…
Reference in a new issue