mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-15 11:25:59 +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 <sys/poll.h>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <xf86drm.h>
|
||||||
|
#include <xf86drmMode.h>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -920,14 +923,24 @@ std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request)
|
||||||
|
|
||||||
result += "\n\n";
|
result += "\n\n";
|
||||||
|
|
||||||
#if defined(__DragonFly__) || defined(__FreeBSD__)
|
int fd = open("/dev/dri/card0", O_RDONLY | O_CLOEXEC);
|
||||||
const std::string GPUINFO = execAndGet("pciconf -lv | fgrep -A4 vga");
|
if (fd < 0) {
|
||||||
#elif defined(__arm__) || defined(__aarch64__)
|
throw std::runtime_error("Failed to open /dev/dri/card0");
|
||||||
const std::string GPUINFO = execAndGet("cat /proc/device-tree/soc*/gpu*/compatible");
|
}
|
||||||
#else
|
drmVersion* version = drmGetVersion(fd);
|
||||||
const std::string GPUINFO = execAndGet("lspci -vnn | grep VGA");
|
if (!version) {
|
||||||
#endif
|
close(fd);
|
||||||
result += "GPU information: \n" + GPUINFO;
|
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"))
|
if (GPUINFO.contains("NVIDIA") && std::filesystem::exists("/proc/driver/nvidia/version"))
|
||||||
result += execAndGet("cat /proc/driver/nvidia/version | grep NVRM");
|
result += execAndGet("cat /proc/driver/nvidia/version | grep NVRM");
|
||||||
result += "\n\n";
|
result += "\n\n";
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <xf86drm.h>
|
||||||
|
#include <xf86drmMode.h>
|
||||||
#ifdef HAS_EXECINFO
|
#ifdef HAS_EXECINFO
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -609,13 +611,21 @@ void logSystemInfo() {
|
||||||
|
|
||||||
Debug::log(NONE, "\n");
|
Debug::log(NONE, "\n");
|
||||||
|
|
||||||
#if defined(__DragonFly__) || defined(__FreeBSD__)
|
int fd = open("/dev/dri/card0", O_RDONLY | O_CLOEXEC);
|
||||||
const std::string GPUINFO = execAndGet("pciconf -lv | fgrep -A4 vga");
|
if (fd < 0) {
|
||||||
#elif defined(__arm__) || defined(__aarch64__)
|
throw std::runtime_error("Failed to open /dev/dri/card0");
|
||||||
const std::string GPUINFO = execAndGet("cat /proc/device-tree/soc*/gpu*/compatible");
|
}
|
||||||
#else
|
drmVersion* version = drmGetVersion(fd);
|
||||||
const std::string GPUINFO = execAndGet("lspci -vnn | grep VGA");
|
if (!version) {
|
||||||
#endif
|
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);
|
Debug::log(LOG, "GPU information:\n{}\n", GPUINFO);
|
||||||
|
|
||||||
if (GPUINFO.contains("NVIDIA")) {
|
if (GPUINFO.contains("NVIDIA")) {
|
||||||
|
|
Loading…
Reference in a new issue