diff --git a/src/allocator/GBM.cpp b/src/allocator/GBM.cpp index a78a243..6bc01fb 100644 --- a/src/allocator/GBM.cpp +++ b/src/allocator/GBM.cpp @@ -62,8 +62,11 @@ Aquamarine::CGBMBuffer::CGBMBuffer(const SAllocatorBufferParams& params, Hypruti attrs.format = params.format; size = attrs.size; - const bool CURSOR = params.cursor && params.scanout; - const bool MULTIGPU = params.multigpu && params.scanout; + const bool CURSOR = params.cursor && params.scanout; + const bool MULTIGPU = params.multigpu && params.scanout; + + TRACE(allocator->backend->log(AQ_LOG_TRACE, + std::format("GBM: Allocating a buffer: size {}, format {}, cursor: {}, multigpu: {}", attrs.size, fourccToName(attrs.format), CURSOR, MULTIGPU))); const auto FORMATS = CURSOR ? swapchain->backendImpl->getCursorFormats() : swapchain->backendImpl->getRenderFormats(); @@ -95,8 +98,10 @@ Aquamarine::CGBMBuffer::CGBMBuffer(const SAllocatorBufferParams& params, Hypruti } // FIXME: Nvidia cannot render to linear buffers. What do? - if (MULTIGPU) + if (MULTIGPU) { + allocator->backend->log(AQ_LOG_DEBUG, "GBM: Buffer is marked as multigpu, forcing linear"); explicitModifiers = {DRM_FORMAT_MOD_LINEAR}; + } if (explicitModifiers.empty()) { // fall back to using a linear buffer. diff --git a/src/backend/drm/DRM.cpp b/src/backend/drm/DRM.cpp index 07eea64..95e6494 100644 --- a/src/backend/drm/DRM.cpp +++ b/src/backend/drm/DRM.cpp @@ -1358,6 +1358,8 @@ bool Aquamarine::CDRMOutput::commitState(bool onlyTest) { auto OPTIONS = swapchain->currentOptions(); OPTIONS.multigpu = false; // this is not a shared swapchain, and additionally, don't make it linear, nvidia would be mad + OPTIONS.cursor = false; + OPTIONS.scanout = true; if (!mgpu.swapchain->reconfigure(OPTIONS)) { backend->backend->log(AQ_LOG_ERROR, "drm: Backend requires blit, but the mgpu swapchain failed reconfiguring"); return false; diff --git a/src/backend/drm/Renderer.cpp b/src/backend/drm/Renderer.cpp index 1a1311f..9f24876 100644 --- a/src/backend/drm/Renderer.cpp +++ b/src/backend/drm/Renderer.cpp @@ -541,6 +541,12 @@ bool CDRMRenderer::blit(SP from, SP to) { EGLImageKHR rboImage = nullptr; GLuint rboID = 0, fboID = 0; auto toDma = to->dmabuf(); + + if (!verifyDestinationDMABUF(toDma)) { + backend->log(AQ_LOG_ERROR, "EGL (blit): failed to blit: destination dmabuf unsupported"); + return false; + } + { auto attachment = to->attachments.get(AQ_ATTACHMENT_DRM_RENDERER_DATA); if (attachment) { @@ -674,6 +680,26 @@ void CDRMRenderer::onBufferAttachmentDrop(CDRMRendererBufferAttachment* attachme restoreEGL(); } +bool CDRMRenderer::verifyDestinationDMABUF(const SDMABUFAttrs& attrs) { + for (auto& fmt : formats) { + if (fmt.drmFormat != attrs.format) + continue; + + if (fmt.modifier != attrs.modifier) + continue; + + if (fmt.external) { + backend->log(AQ_LOG_ERROR, "EGL (verifyDestinationDMABUF): FAIL, format is external-only"); + return false; + } + + return true; + } + + backend->log(AQ_LOG_ERROR, "EGL (verifyDestinationDMABUF): FAIL, format is unsupported by EGL"); + return false; +} + CDRMRendererBufferAttachment::CDRMRendererBufferAttachment(Hyprutils::Memory::CWeakPointer renderer_, Hyprutils::Memory::CSharedPointer buffer, EGLImageKHR image, GLuint fbo_, GLuint rbo_, GLuint texid_) : eglImage(image), fbo(fbo_), rbo(rbo_), renderer(renderer_), texid(texid_) { diff --git a/src/backend/drm/Renderer.hpp b/src/backend/drm/Renderer.hpp index 697d3e5..692d224 100644 --- a/src/backend/drm/Renderer.hpp +++ b/src/backend/drm/Renderer.hpp @@ -96,6 +96,7 @@ namespace Aquamarine { EGLImageKHR createEGLImage(const SDMABUFAttrs& attrs); std::optional>> getModsForFormat(EGLint format); bool initDRMFormats(); + bool verifyDestinationDMABUF(const SDMABUFAttrs& attrs); bool hasModifiers = false; Hyprutils::Memory::CWeakPointer backend;