Skip to content

Commit

Permalink
drm: allow multigpu blit from explicit to implicit (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikalco authored Dec 9, 2024
1 parent 1af9816 commit 9fc2d8e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
12 changes: 7 additions & 5 deletions src/allocator/GBM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ Aquamarine::CGBMBuffer::CGBMBuffer(const SAllocatorBufferParams& params, Hypruti
return;
}

bool foundFormat = false;
// check if we can use modifiers. If the requested support has any explicit modifier
// supported by the primary backend, we can.
for (auto const& f : FORMATS) {
if (f.drmFormat != attrs.format)
continue;

foundFormat = true;
for (auto const& m : f.modifiers) {
if (m == DRM_FORMAT_MOD_INVALID)
continue;
Expand All @@ -134,17 +136,17 @@ Aquamarine::CGBMBuffer::CGBMBuffer(const SAllocatorBufferParams& params, Hypruti
}
}

if (!foundFormat) {
allocator->backend->log(AQ_LOG_ERROR, std::format("GBM: Failed to allocate a GBM buffer: format {} isn't supported by primary backend", fourccToName(attrs.format)));
return;
}

// FIXME: Nvidia cannot render to linear buffers. What do?
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.
explicitModifiers.push_back(DRM_FORMAT_MOD_LINEAR);
}

uint32_t flags = GBM_BO_USE_RENDERING;
if (params.scanout)
flags |= GBM_BO_USE_SCANOUT;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/drm/DRM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ void Aquamarine::CDRMBackend::buildGlFormats(const std::vector<SGLFormat>& fmts)
std::vector<SDRMFormat> result;

for (auto const& fmt : fmts) {
if (fmt.external)
if (fmt.external && fmt.modifier != DRM_FORMAT_MOD_INVALID)
continue;

if (auto it = std::find_if(result.begin(), result.end(), [fmt](const auto& e) { return fmt.drmFormat == e.drmFormat; }); it != result.end()) {
Expand Down
5 changes: 0 additions & 5 deletions src/backend/drm/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,11 +809,6 @@ bool CDRMRenderer::verifyDestinationDMABUF(const SDMABUFAttrs& attrs) {
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;
}

Expand Down

0 comments on commit 9fc2d8e

Please sign in to comment.