From 4c3b03516209a49244a8f044143c1162752b8a7a Mon Sep 17 00:00:00 2001 From: Vaxry Date: Mon, 22 Jul 2024 19:19:37 +0200 Subject: pointer/hw: rollback the swapchain on multiple renders without a commit fixes the hack --- src/managers/PointerManager.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/managers/PointerManager.cpp') diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index 55bd0509..3b425688 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -24,6 +24,14 @@ CPointerManager::CPointerManager() { }, nullptr); }); + + hooks.monitorPreRender = g_pHookSystem->hookDynamic("preRender", [this](void* self, SCallbackInfo& info, std::any data) { + auto state = stateFor(std::any_cast(data)->self.lock()); + if (!state) + return; + + state->cursorRendered = false; + }); } void CPointerManager::lockSoftwareAll() { @@ -373,10 +381,7 @@ SP CPointerManager::renderHWCursorBuffer(SPmonitor->cursorSwapchain->currentOptions(); options.size = maxSize; - // TODO: this is a band-aid. If the current cursor image has not yet been committed (no rendering has yet been done) - // we should revert the swapchain and avoid rendering to the front buffer. - // as a band-aid, extend the swapchain to 3 as we sometimes double-render on a cursor shape change. - options.length = 3; + options.length = 2; options.scanout = true; options.cursor = true; options.multigpu = state->monitor->output->getBackend()->preferredAllocator()->drmFD() != g_pCompositor->m_iDRMFD; @@ -389,6 +394,14 @@ SP CPointerManager::renderHWCursorBuffer(SPcursorRendered) + state->monitor->cursorSwapchain->rollback(); + + state->cursorRendered = true; + auto buf = state->monitor->cursorSwapchain->next(nullptr); if (!buf) { Debug::log(TRACE, "Failed to acquire a buffer from the cursor swapchain"); -- cgit v1.2.3