mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-07 22:26:00 +01:00
renderer: fix invalid damage accumulation with invalid buffer_age
fixes #4670
This commit is contained in:
parent
fae47ef462
commit
301b48b740
2 changed files with 36 additions and 39 deletions
|
@ -1098,11 +1098,42 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
|
||||||
if (UNLOCK_SC)
|
if (UNLOCK_SC)
|
||||||
wlr_output_lock_software_cursors(pMonitor->output, true);
|
wlr_output_lock_software_cursors(pMonitor->output, true);
|
||||||
|
|
||||||
CRegion damage;
|
if (pMonitor->forceFullFrames > 0) {
|
||||||
wlr_damage_ring_get_buffer_damage(&pMonitor->damage, m_iLastBufferAge, damage.pixman());
|
pMonitor->forceFullFrames -= 1;
|
||||||
|
if (pMonitor->forceFullFrames > 10)
|
||||||
|
pMonitor->forceFullFrames = 0;
|
||||||
|
}
|
||||||
|
|
||||||
pMonitor->renderingActive = true;
|
pMonitor->renderingActive = true;
|
||||||
|
|
||||||
|
TRACY_GPU_ZONE("Render");
|
||||||
|
|
||||||
|
if (pMonitor == g_pCompositor->getMonitorFromCursor())
|
||||||
|
g_pHyprOpenGL->m_RenderData.mouseZoomFactor = std::clamp(**PZOOMFACTOR, 1.f, INFINITY);
|
||||||
|
else
|
||||||
|
g_pHyprOpenGL->m_RenderData.mouseZoomFactor = 1.f;
|
||||||
|
|
||||||
|
if (zoomInFactorFirstLaunch > 1.f) {
|
||||||
|
g_pHyprOpenGL->m_RenderData.mouseZoomFactor = zoomInFactorFirstLaunch;
|
||||||
|
g_pHyprOpenGL->m_RenderData.mouseZoomUseMouse = false;
|
||||||
|
g_pHyprOpenGL->m_RenderData.useNearestNeighbor = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CRegion damage;
|
||||||
|
|
||||||
|
if (!beginRender(pMonitor, damage, RENDER_MODE_NORMAL)) {
|
||||||
|
Debug::log(ERR, "renderer: couldn't beginRender()!");
|
||||||
|
|
||||||
|
if (UNLOCK_SC)
|
||||||
|
wlr_output_lock_software_cursors(pMonitor->output, false);
|
||||||
|
|
||||||
|
pMonitor->state.clear();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_damage_ring_rotate_buffer(&pMonitor->damage, m_pCurrentWlrBuffer, damage.pixman());
|
||||||
|
|
||||||
// we need to cleanup fading out when rendering the appropriate context
|
// we need to cleanup fading out when rendering the appropriate context
|
||||||
g_pCompositor->cleanupFadingOut(pMonitor->ID);
|
g_pCompositor->cleanupFadingOut(pMonitor->ID);
|
||||||
|
|
||||||
|
@ -1134,38 +1165,8 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMonitor->forceFullFrames > 0) {
|
// apply modified damage to render pass
|
||||||
pMonitor->forceFullFrames -= 1;
|
g_pHyprOpenGL->m_RenderData.damage.set(damage);
|
||||||
if (pMonitor->forceFullFrames > 10)
|
|
||||||
pMonitor->forceFullFrames = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: this is getting called with extents being 0,0,0,0 should it be?
|
|
||||||
// potentially can save on resources.
|
|
||||||
|
|
||||||
TRACY_GPU_ZONE("Render");
|
|
||||||
|
|
||||||
if (pMonitor == g_pCompositor->getMonitorFromCursor())
|
|
||||||
g_pHyprOpenGL->m_RenderData.mouseZoomFactor = std::clamp(**PZOOMFACTOR, 1.f, INFINITY);
|
|
||||||
else
|
|
||||||
g_pHyprOpenGL->m_RenderData.mouseZoomFactor = 1.f;
|
|
||||||
|
|
||||||
if (zoomInFactorFirstLaunch > 1.f) {
|
|
||||||
g_pHyprOpenGL->m_RenderData.mouseZoomFactor = zoomInFactorFirstLaunch;
|
|
||||||
g_pHyprOpenGL->m_RenderData.mouseZoomUseMouse = false;
|
|
||||||
g_pHyprOpenGL->m_RenderData.useNearestNeighbor = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!beginRender(pMonitor, damage, RENDER_MODE_NORMAL)) {
|
|
||||||
Debug::log(ERR, "renderer: couldn't beginRender()!");
|
|
||||||
|
|
||||||
if (UNLOCK_SC)
|
|
||||||
wlr_output_lock_software_cursors(pMonitor->output, false);
|
|
||||||
|
|
||||||
pMonitor->state.clear();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
EMIT_HOOK_EVENT("render", RENDER_BEGIN);
|
EMIT_HOOK_EVENT("render", RENDER_BEGIN);
|
||||||
|
|
||||||
|
@ -1263,8 +1264,6 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
|
||||||
if (shouldTear)
|
if (shouldTear)
|
||||||
pMonitor->tearingState.busy = true;
|
pMonitor->tearingState.busy = true;
|
||||||
|
|
||||||
wlr_damage_ring_rotate(&pMonitor->damage);
|
|
||||||
|
|
||||||
if (UNLOCK_SC)
|
if (UNLOCK_SC)
|
||||||
wlr_output_lock_software_cursors(pMonitor->output, false);
|
wlr_output_lock_software_cursors(pMonitor->output, false);
|
||||||
|
|
||||||
|
@ -2470,7 +2469,7 @@ bool CHyprRenderer::beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode
|
||||||
if (!wlr_output_configure_primary_swapchain(pMonitor->output, pMonitor->state.wlr(), &pMonitor->output->swapchain))
|
if (!wlr_output_configure_primary_swapchain(pMonitor->output, pMonitor->state.wlr(), &pMonitor->output->swapchain))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_pCurrentWlrBuffer = wlr_swapchain_acquire(pMonitor->output->swapchain, &m_iLastBufferAge);
|
m_pCurrentWlrBuffer = wlr_swapchain_acquire(pMonitor->output->swapchain, nullptr);
|
||||||
if (!m_pCurrentWlrBuffer)
|
if (!m_pCurrentWlrBuffer)
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2521,7 +2520,6 @@ void CHyprRenderer::endRender() {
|
||||||
|
|
||||||
m_pCurrentRenderbuffer = nullptr;
|
m_pCurrentRenderbuffer = nullptr;
|
||||||
m_pCurrentWlrBuffer = nullptr;
|
m_pCurrentWlrBuffer = nullptr;
|
||||||
m_iLastBufferAge = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprRenderer::onRenderbufferDestroy(CRenderbuffer* rb) {
|
void CHyprRenderer::onRenderbufferDestroy(CRenderbuffer* rb) {
|
||||||
|
|
|
@ -122,7 +122,6 @@ class CHyprRenderer {
|
||||||
CRenderbuffer* m_pCurrentRenderbuffer = nullptr;
|
CRenderbuffer* m_pCurrentRenderbuffer = nullptr;
|
||||||
wlr_buffer* m_pCurrentWlrBuffer = nullptr;
|
wlr_buffer* m_pCurrentWlrBuffer = nullptr;
|
||||||
eRenderMode m_eRenderMode = RENDER_MODE_NORMAL;
|
eRenderMode m_eRenderMode = RENDER_MODE_NORMAL;
|
||||||
int m_iLastBufferAge = 0;
|
|
||||||
|
|
||||||
bool m_bNvidia = false;
|
bool m_bNvidia = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue