Skip to content

Commit

Permalink
gbm/drm: conform to different scanout requirements for different planes
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Aug 31, 2024
1 parent b9ab839 commit 865cd94
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions include/aquamarine/allocator/Swapchain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
namespace Aquamarine {

class IBackendImplementation;
class IOutput;

struct SSwapchainOptions {
size_t length = 0;
Hyprutils::Math::Vector2D size;
uint32_t format = DRM_FORMAT_INVALID; // if you leave this on invalid, the swapchain will choose an appropriate format (and modifier) for you.
bool scanout = false, cursor = false /* requires scanout = true */, multigpu = false /* if true, will force linear */;
Hyprutils::Memory::CWeakPointer<IOutput> scanoutOutput;
};

class CSwapchain {
Expand Down
12 changes: 9 additions & 3 deletions src/allocator/GBM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,20 @@ 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;
const bool EXPLICIT_SCANOUT = params.scanout && swapchain->currentOptions().scanoutOutput;

TRACE(allocator->backend->log(AQ_LOG_TRACE,
std::format("GBM: Allocating a buffer: size {}, format {}, cursor: {}, multigpu: {}, scanout: {}", attrs.size, fourccToName(attrs.format), CURSOR,
MULTIGPU, params.scanout)));

const auto FORMATS = CURSOR ? swapchain->backendImpl->getCursorFormats() : swapchain->backendImpl->getRenderFormats();
if (EXPLICIT_SCANOUT)
TRACE(allocator->backend->log(
AQ_LOG_TRACE, std::format("GBM: Explicit scanout output, output has {} explicit formats", swapchain->currentOptions().scanoutOutput->getRenderFormats().size())));

const auto FORMATS = CURSOR ? swapchain->backendImpl->getCursorFormats() :
(EXPLICIT_SCANOUT ? swapchain->currentOptions().scanoutOutput->getRenderFormats() : swapchain->backendImpl->getRenderFormats());
const auto RENDERABLE = swapchain->backendImpl->getRenderableFormats();

TRACE(allocator->backend->log(AQ_LOG_TRACE, std::format("GBM: Available formats: {}", FORMATS.size())));
Expand Down
4 changes: 2 additions & 2 deletions src/backend/drm/DRM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ void Aquamarine::CDRMBackend::onReady() {

// swapchain has to be created here because allocator is absent in connect if not ready
c->output->swapchain = CSwapchain::create(backend->primaryAllocator, self.lock());
c->output->swapchain->reconfigure(SSwapchainOptions{.length = 0, .scanout = true, .multigpu = !!primary}); // mark the swapchain for scanout
c->output->swapchain->reconfigure(SSwapchainOptions{.length = 0, .scanout = true, .multigpu = !!primary, .scanoutOutput = c->output}); // mark the swapchain for scanout
c->output->needsFrame = true;

backend->events.newOutput.emit(SP<IOutput>(c->output));
Expand Down Expand Up @@ -1283,7 +1283,7 @@ void Aquamarine::SDRMConnector::connect(drmModeConnector* connector) {
return;

output->swapchain = CSwapchain::create(backend->backend->primaryAllocator, backend->self.lock());
output->swapchain->reconfigure(SSwapchainOptions{.length = 0, .scanout = true, .multigpu = !!backend->primary}); // mark the swapchain for scanout
output->swapchain->reconfigure(SSwapchainOptions{.length = 0, .scanout = true, .multigpu = !!backend->primary, .scanoutOutput = output}); // mark the swapchain for scanout
output->needsFrame = true;
backend->backend->events.newOutput.emit(SP<IOutput>(output));
output->scheduleFrame(IOutput::AQ_SCHEDULE_NEW_CONNECTOR);
Expand Down

0 comments on commit 865cd94

Please sign in to comment.