3
0
mirror of https://github.com/hyprwm/Hyprland.git synced 2026-08-18 11:02:10 +00:00

render: handle explicit sync fallback safely (#14986)

* render: handle explicit sync fallback safely

* render: avoid blocking explicit sync fallback

* ci: retry flaky Hyprland VM tests

* render: avoid blocking explicit sync fallback

---------

Co-authored-by: Pppp1116 <pcaiadoguerreiro@gmail.com>
Co-authored-by: Pppp1116 <ACCOUNT1_NOREPLY>
This commit is contained in:
NotPppp1116
2026-07-16 19:12:32 +01:00
committed by GitHub
parent 83cd85b3d5
commit 82baeb5e92
3 changed files with 21 additions and 4 deletions

View File

@ -2188,11 +2188,13 @@ bool CMonitor::attemptDirectScanout() {
if (g_pHyprRenderer->explicitSyncSupported() && isMultiGPU()) {
auto sync = g_pHyprRenderer->createSyncFDManager();
if (sync->fd().isValid()) {
if (sync && sync->isValid()) {
m_inFence = sync->takeFd();
m_output->state->setExplicitInFence(m_inFence.get());
} else
} else {
m_inFence.reset();
m_output->state->resetExplicitFences(); // good luck.
}
} else
m_output->state->resetExplicitFences();

View File

@ -129,6 +129,13 @@ void CMonitorFrameScheduler::onFrame() {
void CMonitorFrameScheduler::onFinishRender() {
m_sync = g_pHyprRenderer->createSyncFDManager(); // this destroys the old sync
if (!m_sync || !m_sync->isValid()) {
Log::logger->log(Log::ERR, "CMonitorFrameScheduler: explicit sync failed, falling back to frame events");
m_sync.reset();
m_renderAtFrame = true;
return;
}
g_pEventLoopManager->doOnReadable(m_sync->fd().duplicate(), [this, self = m_self] {
if (!self) // might've gotten destroyed
return;

View File

@ -148,9 +148,17 @@ void CHyprGLRenderer::endRender(const std::function<void()>& renderingDoneCallba
PMONITOR->m_output->state->setExplicitInFence(PMONITOR->m_inFence.get());
}
} else {
Log::logger->log(Log::ERR, "renderer: Explicit sync failed, releasing resources");
Log::logger->log(Log::ERR, "renderer: Explicit sync failed, falling back to implicit sync");
m_usedAsyncBuffers.clear(); // release all buffer refs and hope implicit sync works
// Establish an implicit synchronization point without blocking the render loop.
glFlush();
if (m_renderMode == RENDER_MODE_NORMAL && PMONITOR) {
PMONITOR->m_inFence.reset();
PMONITOR->m_output->state->resetExplicitFences();
}
m_usedAsyncBuffers.clear();
if (renderingDoneCallback)
renderingDoneCallback();
}