summaryrefslogtreecommitdiff
path: root/src/helpers/Drm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/helpers/Drm.cpp')
-rw-r--r--src/helpers/Drm.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/helpers/Drm.cpp b/src/helpers/Drm.cpp
new file mode 100644
index 00000000..207b5e3d
--- /dev/null
+++ b/src/helpers/Drm.cpp
@@ -0,0 +1,20 @@
+#include <xf86drm.h>
+#include "Drm.hpp"
+
+bool DRM::sameGpu(int fd1, int fd2) {
+ drmDevice* devA = nullptr;
+ drmDevice* devB = nullptr;
+
+ if (drmGetDevice2(fd1, 0, &devA) != 0)
+ return false;
+ if (drmGetDevice2(fd2, 0, &devB) != 0) {
+ drmFreeDevice(&devA);
+ return false;
+ }
+
+ bool same = drmDevicesEqual(devA, devB);
+
+ drmFreeDevice(&devA);
+ drmFreeDevice(&devB);
+ return same;
+}