renderer: minor direct scanout fixes (#7594)

This commit is contained in:
Ikalco 2024-08-31 08:07:52 -05:00 committed by GitHub
parent 76b82fdde7
commit 838ed87d6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 4 deletions

View file

@ -832,6 +832,21 @@ bool CMonitor::attemptDirectScanout() {
// FIXME: make sure the buffer actually follows the available scanout dmabuf formats
// and comes from the appropriate device. This may implode on multi-gpu!!
const auto params = PSURFACE->current.buffer->buffer->dmabuf();
// scanout buffer isn't dmabuf, so no scanout
if (!params.success)
return false;
// entering into scanout, so save monitor format
if (lastScanout.expired())
prevDrmFormat = drmFormat;
if (drmFormat != params.format) {
output->state->setFormat(params.format);
drmFormat = params.format;
}
output->state->setBuffer(PSURFACE->current.buffer->buffer.lock());
output->state->setPresentationMode(tearingState.activelyTearing ? Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_IMMEDIATE :
Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_VSYNC);

View file

@ -101,6 +101,7 @@ class CMonitor {
SP<Aquamarine::SOutputMode> currentMode;
SP<Aquamarine::CSwapchain> cursorSwapchain;
uint32_t drmFormat = DRM_FORMAT_INVALID;
uint32_t prevDrmFormat = DRM_FORMAT_INVALID;
bool dpmsStatus = true;
bool vrrActive = false; // this can be TRUE even if VRR is not active in the case that this display does not support it.

View file

@ -1277,7 +1277,8 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
pMonitor->lastScanout.reset();
// reset DRM format, make sure it's the one we want.
pMonitor->output->state->setFormat(pMonitor->drmFormat);
pMonitor->output->state->setFormat(pMonitor->prevDrmFormat);
pMonitor->drmFormat = pMonitor->prevDrmFormat;
}
}
@ -1978,6 +1979,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
pMonitor->currentMode = nullptr;
pMonitor->output->state->setFormat(DRM_FORMAT_XRGB8888);
pMonitor->prevDrmFormat = pMonitor->drmFormat;
pMonitor->drmFormat = DRM_FORMAT_XRGB8888;
pMonitor->output->state->resetExplicitFences();
@ -2219,6 +2221,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
for (auto const& fmt : formats[(int)!RULE->enable10bit]) {
pMonitor->output->state->setFormat(fmt.second);
pMonitor->prevDrmFormat = pMonitor->drmFormat;
pMonitor->drmFormat = fmt.second;
if (!pMonitor->state.test()) {