renderer: ensure buffer format on commit (#7556)

This commit is contained in:
Ikalco 2024-08-28 08:07:13 -05:00 committed by GitHub
parent 8210a1d7ac
commit 98e99cd03d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View file

@ -915,17 +915,20 @@ CMonitorState::~CMonitorState() {
} }
void CMonitorState::ensureBufferPresent() { void CMonitorState::ensureBufferPresent() {
if (!m_pOwner->output->state->state().enabled) { const auto STATE = m_pOwner->output->state->state();
if (!STATE.enabled) {
Debug::log(TRACE, "CMonitorState::ensureBufferPresent: Ignoring, monitor is not enabled"); Debug::log(TRACE, "CMonitorState::ensureBufferPresent: Ignoring, monitor is not enabled");
return; return;
} }
if (m_pOwner->output->state->state().buffer) if (STATE.buffer) {
return; if (const auto params = STATE.buffer->dmabuf(); params.success && params.format == m_pOwner->drmFormat)
return;
}
// this is required for modesetting being possible and might be missing in case of first tests in the renderer // this is required for modesetting being possible and might be missing in case of first tests in the renderer
// where we test modes and buffers // where we test modes and buffers
Debug::log(LOG, "CMonitorState::ensureBufferPresent: no buffer, attaching one from the swapchain for modeset being possible"); Debug::log(LOG, "CMonitorState::ensureBufferPresent: no buffer or mismatched format, attaching one from the swapchain for modeset being possible");
m_pOwner->output->state->setBuffer(m_pOwner->output->swapchain->next(nullptr)); m_pOwner->output->state->setBuffer(m_pOwner->output->swapchain->next(nullptr));
m_pOwner->output->swapchain->rollback(); // restore the counter, don't advance the swapchain m_pOwner->output->swapchain->rollback(); // restore the counter, don't advance the swapchain
} }

View file

@ -1910,6 +1910,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
pMonitor->currentMode = nullptr; pMonitor->currentMode = nullptr;
pMonitor->output->state->setFormat(DRM_FORMAT_XRGB8888); pMonitor->output->state->setFormat(DRM_FORMAT_XRGB8888);
pMonitor->drmFormat = DRM_FORMAT_XRGB8888;
pMonitor->output->state->resetExplicitFences(); pMonitor->output->state->resetExplicitFences();
bool autoScale = false; bool autoScale = false;