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:
@ -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();
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user