mirror of
https://github.com/hyprwm/Hyprland
synced 2025-02-17 00:42:11 +01:00
pointer/hw: rollback the swapchain on multiple renders without a commit
fixes the hack
This commit is contained in:
parent
f17f8b219c
commit
4c3b035162
2 changed files with 21 additions and 6 deletions
|
@ -24,6 +24,14 @@ CPointerManager::CPointerManager() {
|
||||||
},
|
},
|
||||||
nullptr);
|
nullptr);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
hooks.monitorPreRender = g_pHookSystem->hookDynamic("preRender", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||||
|
auto state = stateFor(std::any_cast<CMonitor*>(data)->self.lock());
|
||||||
|
if (!state)
|
||||||
|
return;
|
||||||
|
|
||||||
|
state->cursorRendered = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPointerManager::lockSoftwareAll() {
|
void CPointerManager::lockSoftwareAll() {
|
||||||
|
@ -373,10 +381,7 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
|
||||||
|
|
||||||
auto options = state->monitor->cursorSwapchain->currentOptions();
|
auto options = state->monitor->cursorSwapchain->currentOptions();
|
||||||
options.size = maxSize;
|
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)
|
options.length = 2;
|
||||||
// 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.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;
|
||||||
|
@ -389,6 +394,14 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we already rendered the cursor, revert the swapchain to avoid rendering the cursor over
|
||||||
|
// the current front buffer
|
||||||
|
// this flag will be reset in the preRender hook, so when we commit this buffer to KMS
|
||||||
|
if (state->cursorRendered)
|
||||||
|
state->monitor->cursorSwapchain->rollback();
|
||||||
|
|
||||||
|
state->cursorRendered = true;
|
||||||
|
|
||||||
auto buf = state->monitor->cursorSwapchain->next(nullptr);
|
auto buf = state->monitor->cursorSwapchain->next(nullptr);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
Debug::log(TRACE, "Failed to acquire a buffer from the cursor swapchain");
|
Debug::log(TRACE, "Failed to acquire a buffer from the cursor swapchain");
|
||||||
|
|
|
@ -163,8 +163,9 @@ class CPointerManager {
|
||||||
int softwareLocks = 0;
|
int softwareLocks = 0;
|
||||||
bool hardwareFailed = false;
|
bool hardwareFailed = false;
|
||||||
CBox box; // logical
|
CBox box; // logical
|
||||||
bool entered = false;
|
bool entered = false;
|
||||||
bool hwApplied = false;
|
bool hwApplied = false;
|
||||||
|
bool cursorRendered = false;
|
||||||
|
|
||||||
SP<Aquamarine::IBuffer> cursorFrontBuffer;
|
SP<Aquamarine::IBuffer> cursorFrontBuffer;
|
||||||
};
|
};
|
||||||
|
@ -177,6 +178,7 @@ class CPointerManager {
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
SP<HOOK_CALLBACK_FN> monitorAdded;
|
SP<HOOK_CALLBACK_FN> monitorAdded;
|
||||||
|
SP<HOOK_CALLBACK_FN> monitorPreRender;
|
||||||
} hooks;
|
} hooks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue