From ad4484335fc327a6cf010f455ae258c397861ee0 Mon Sep 17 00:00:00 2001 From: umbrageodotus Date: Mon, 2 Nov 2026 11:08:14 +0000 Subject: [PATCH] internal: minor fixes (#470) * Fix C+P fail * Don't compare a fourcc to a modifier and allow fallbacks independently of forceLinearBlit * Use ranges as per vaxry's request --- src/allocator/GBM.cpp | 33 ++++++++++++++------------------- src/backend/drm/Renderer.cpp | 2 +- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/allocator/GBM.cpp b/src/allocator/GBM.cpp index 6f596b73..8c44ec98 100644 --- a/src/allocator/GBM.cpp +++ b/src/allocator/GBM.cpp @@ -145,12 +145,9 @@ Aquamarine::CGBMBuffer::CGBMBuffer(const SAllocatorBufferParams& params, Hypruti if (MULTIGPU && !forceLinearBlit) { // Try to use the linear format if available for cross-GPU compatibility. // However, Nvidia doesn't support linear, so this is a best-effort basis. - for (auto const& f : FORMATS) { - if (f.drmFormat == DRM_FORMAT_MOD_LINEAR) { - allocator->backend->log(AQ_LOG_DEBUG, "GBM: Buffer is marked as multigpu, using linear format"); - explicitModifiers = {DRM_FORMAT_MOD_LINEAR}; - break; - } + if (std::ranges::find(explicitModifiers, DRM_FORMAT_MOD_LINEAR) != explicitModifiers.end()) { + allocator->backend->log(AQ_LOG_DEBUG, "GBM: Buffer is marked as multigpu, using linear format"); + explicitModifiers = {DRM_FORMAT_MOD_LINEAR}; } } else if (MULTIGPU && forceLinearBlit) { // FIXME: Nvidia cannot render to linear buffers. What do? @@ -200,21 +197,19 @@ Aquamarine::CGBMBuffer::CGBMBuffer(const SAllocatorBufferParams& params, Hypruti } } - if (MULTIGPU && forceLinearBlit) { - // FIXME: most likely nvidia main gpu on multigpu - if (!bo) { - if (oldMods.empty()) - bo = gbm_bo_create(allocator->gbmDevice, attrs.size.x, attrs.size.y, attrs.format, GBM_BO_USE_RENDERING); - else - bo = gbm_bo_create_with_modifiers(allocator->gbmDevice, attrs.size.x, attrs.size.y, attrs.format, oldMods.data(), oldMods.size()); - - if (!bo) { - allocator->backend->log(AQ_LOG_ERROR, "GBM: Failed to allocate a GBM buffer: bo null"); - return; - } + // FIXME: most likely nvidia main gpu on multigpu + if (MULTIGPU && !bo) { + if (oldMods.empty()) + bo = gbm_bo_create(allocator->gbmDevice, attrs.size.x, attrs.size.y, attrs.format, GBM_BO_USE_RENDERING); + else + bo = gbm_bo_create_with_modifiers(allocator->gbmDevice, attrs.size.x, attrs.size.y, attrs.format, oldMods.data(), oldMods.size()); - modifier = gbm_bo_get_modifier(bo); + if (!bo) { + allocator->backend->log(AQ_LOG_ERROR, "GBM: Failed to allocate a GBM buffer: bo null"); + return; } + + modifier = gbm_bo_get_modifier(bo); } if (!bo) { diff --git a/src/backend/drm/Renderer.cpp b/src/backend/drm/Renderer.cpp index 718d79ca..bbb94c7c 100644 --- a/src/backend/drm/Renderer.cpp +++ b/src/backend/drm/Renderer.cpp @@ -1191,7 +1191,7 @@ bool CDRMRenderer::verifyDestinationDMABUF(const SDMABUFAttrs& attrs) { if (fmt.modifier != attrs.modifier) continue; - if (fmt.modifier != DRM_FORMAT_INVALID && fmt.external) { + if (fmt.modifier != DRM_FORMAT_MOD_INVALID && fmt.external) { backend->log(AQ_LOG_ERROR, "EGL (verifyDestinationDMABUF): FAIL, format is external-only"); return false; }