fix: triple buffering hack to fix cursor jumping

This commit is contained in:
Virt 2024-08-21 10:37:36 +02:00
commit eabab33f00

View file

@ -157,14 +157,16 @@ SP<Aquamarine::IBuffer> CDynamicCursors::renderHardware(CPointerManager* pointer
} else } else
maxSize = targetSize; maxSize = targetSize;
if (!state->monitor->cursorSwapchain || maxSize != state->monitor->cursorSwapchain->currentOptions().size) { if (!state->monitor->cursorSwapchain || maxSize != state->monitor->cursorSwapchain->currentOptions().size || state->monitor->cursorSwapchain->currentOptions().length != 3) {
if (!state->monitor->cursorSwapchain) if (!state->monitor->cursorSwapchain)
state->monitor->cursorSwapchain = Aquamarine::CSwapchain::create(state->monitor->output->getBackend()->preferredAllocator(), state->monitor->output->getBackend()); state->monitor->cursorSwapchain = Aquamarine::CSwapchain::create(state->monitor->output->getBackend()->preferredAllocator(), state->monitor->output->getBackend());
auto options = state->monitor->cursorSwapchain->currentOptions(); auto options = state->monitor->cursorSwapchain->currentOptions();
options.size = maxSize; options.size = maxSize;
options.length = 2; // we still have to create a triple buffering swapchain, as we seem to be running into some sort of race condition
// or something. I'll continue debugging this when I find some energy again, I've spent too much time here already.
options.length = 3;
options.scanout = true; options.scanout = true;
options.cursor = true; options.cursor = true;
options.multigpu = state->monitor->output->getBackend()->preferredAllocator()->drmFD() != g_pCompositor->m_iDRMFD; options.multigpu = state->monitor->output->getBackend()->preferredAllocator()->drmFD() != g_pCompositor->m_iDRMFD;
@ -181,6 +183,7 @@ SP<Aquamarine::IBuffer> CDynamicCursors::renderHardware(CPointerManager* pointer
// the current front buffer // the current front buffer
// this flag will be reset in the preRender hook, so when we commit this buffer to KMS // this flag will be reset in the preRender hook, so when we commit this buffer to KMS
// see https://github.com/hyprwm/Hyprland/commit/4c3b03516209a49244a8f044143c1162752b8a7a // see https://github.com/hyprwm/Hyprland/commit/4c3b03516209a49244a8f044143c1162752b8a7a
// this is however still not enough, see above
if (state->cursorRendered) if (state->cursorRendered)
state->monitor->cursorSwapchain->rollback(); state->monitor->cursorSwapchain->rollback();