gbm/drm: conform to different scanout requirements for different planes

ref https://github.com/hyprwm/Hyprland/issues/7005
This commit is contained in:
Vaxry 2024-08-31 13:52:04 +02:00
parent b9ab839ab3
commit 865cd94f97
3 changed files with 13 additions and 5 deletions

View file

@ -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 {

View file

@ -74,12 +74,18 @@ Aquamarine::CGBMBuffer::CGBMBuffer(const SAllocatorBufferParams& params, Hypruti
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())));

View file

@ -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));
@ -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);