From 50637ed23e962f0db294d6b0ef534f37b144644b Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Tue, 19 Aug 2025 21:44:40 +0200 Subject: [PATCH] drm: revert #203 and half of #202 (#204) either there is a fd going wrong here or certain drivers just plain fails with this. revert for now. but leave the cdrmrenderer using rendernode. --- src/backend/Backend.cpp | 5 ++--- src/backend/drm/DRM.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/backend/Backend.cpp b/src/backend/Backend.cpp index 0fd908c..7d63fe1 100644 --- a/src/backend/Backend.cpp +++ b/src/backend/Backend.cpp @@ -141,9 +141,8 @@ bool Aquamarine::CBackend::start() { // TODO: obviously change this when (if) we add different allocators. for (auto const& b : implementations) { - auto const& f = b->drmRenderNodeFD() >= 0 ? b->drmRenderNodeFD() : b->drmFD(); - if (f >= 0) { - auto fd = reopenDRMNode(f); + if (b->drmFD() >= 0) { + auto fd = reopenDRMNode(b->drmFD()); if (fd < 0) { // this is critical, we cannot create an allocator properly log(AQ_LOG_CRITICAL, "Failed to create an allocator (reopenDRMNode failed)"); diff --git a/src/backend/drm/DRM.cpp b/src/backend/drm/DRM.cpp index 1b90960..ed60959 100644 --- a/src/backend/drm/DRM.cpp +++ b/src/backend/drm/DRM.cpp @@ -249,7 +249,7 @@ SP Aquamarine::CDRMBackend::fromGpu(std::string path, SP drmBackend->grabFormats(); - drmBackend->dumbAllocator = CDRMDumbAllocator::create(drmBackend->backend->reopenDRMNode(gpu->fd), backend); + drmBackend->dumbAllocator = CDRMDumbAllocator::create(gpu->fd, backend); // so that session can handle udev change/remove events for this gpu backend->session->sessionDevices.push_back(gpu); @@ -333,7 +333,7 @@ std::vector> Aquamarine::CDRMBackend::attempt(SP backe newPrimary = drmBackend; } - drmBackend->dumbAllocator = CDRMDumbAllocator::create(drmBackend->backend->reopenDRMNode(gpu->fd), backend); + drmBackend->dumbAllocator = CDRMDumbAllocator::create(gpu->fd, backend); backends.emplace_back(drmBackend); @@ -590,7 +590,7 @@ bool Aquamarine::CDRMBackend::shouldBlit() { bool Aquamarine::CDRMBackend::initMgpu() { SP newAllocator; if (primary || backend->primaryAllocator->type() != AQ_ALLOCATOR_TYPE_GBM) { - newAllocator = CGBMAllocator::create(backend->reopenDRMNode(gpu->renderNodeFd >= 0 ? gpu->renderNodeFd : gpu->fd), backend); + newAllocator = CGBMAllocator::create(backend->reopenDRMNode(gpu->fd), backend); rendererState.allocator = newAllocator; } else { newAllocator = ((CGBMAllocator*)backend->primaryAllocator.get())->self.lock(); @@ -602,7 +602,7 @@ bool Aquamarine::CDRMBackend::initMgpu() { return false; } - rendererState.renderer = CDRMRenderer::attempt(backend.lock(), newAllocator); + rendererState.renderer = CDRMRenderer::attempt(backend.lock(), gpu->renderNodeFd >= 0 ? gpu->renderNodeFd : gpu->fd); if (!rendererState.renderer) { backend->log(AQ_LOG_ERROR, "drm: initMgpu: no renderer"); @@ -975,11 +975,11 @@ void Aquamarine::CDRMBackend::onReady() { // init a drm renderer to gather gl formats. // if we are secondary, initMgpu will have done that if (!primary) { - auto a = CGBMAllocator::create(backend->reopenDRMNode(gpu->renderNodeFd >= 0 ? gpu->renderNodeFd : gpu->fd), backend); + auto a = CGBMAllocator::create(backend->reopenDRMNode(gpu->fd), backend); if (!a) backend->log(AQ_LOG_ERROR, "drm: onReady: no renderer for gl formats"); else { - auto r = CDRMRenderer::attempt(backend.lock(), a); + auto r = CDRMRenderer::attempt(backend.lock(), gpu->renderNodeFd >= 0 ? gpu->renderNodeFd : gpu->fd); if (!r) backend->log(AQ_LOG_ERROR, "drm: onReady: no renderer for gl formats"); else {