From 9f59ed786856df8a28430e4084491c7e9fa6234f Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Sat, 21 Feb 2026 21:27:59 +0100 Subject: multigpu: fix multi gpu checking (#13277) * multigpu: fix multi gpu checking drmFD() from allocators is not always equal, because we reopen them inside AQ for refcounting, meaning they get duplicated and become their own fds, so checking if fd1 == fd2 ends up wrong. introduce sameGpu in MiscFunctions that checks the actual drmDevice meaning we can now even check if a rendernode is the same gpu as a display node if we want. * multigpu: move sameGpu to DRM namespace move sameGpu out of MiscFunctions to DRM namespace. --- src/helpers/Drm.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/helpers/Drm.cpp (limited to 'src/helpers/Drm.cpp') 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 +#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; +} -- cgit v1.2.3