mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-05-13 15:20:36 +01:00
renderer: only commit hw cursor stuff if needed (#9654)
This commit is contained in:
parent
c4f46473df
commit
5f60fc7d00
3 changed files with 29 additions and 5 deletions
|
@ -1355,8 +1355,26 @@ bool CMonitor::attemptDirectScanout() {
|
||||||
|
|
||||||
Debug::log(TRACE, "attemptDirectScanout: surface {:x} passed, will attempt, buffer {}", (uintptr_t)PSURFACE.get(), (uintptr_t)PSURFACE->current.buffer->buffer.get());
|
Debug::log(TRACE, "attemptDirectScanout: surface {:x} passed, will attempt, buffer {}", (uintptr_t)PSURFACE.get(), (uintptr_t)PSURFACE->current.buffer->buffer.get());
|
||||||
|
|
||||||
auto PBUFFER = PSURFACE->current.buffer->buffer.lock();
|
auto PBUFFER = PSURFACE->current.buffer->buffer.lock();
|
||||||
bool SAMEBUFFER = PBUFFER == output->state->state().buffer;
|
|
||||||
|
if (PBUFFER == output->state->state().buffer) {
|
||||||
|
if (scanoutNeedsCursorUpdate) {
|
||||||
|
if (!state.test()) {
|
||||||
|
Debug::log(TRACE, "attemptDirectScanout: failed basic test");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!output->commit()) {
|
||||||
|
Debug::log(TRACE, "attemptDirectScanout: failed to commit cursor update");
|
||||||
|
lastScanout.reset();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
scanoutNeedsCursorUpdate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: make sure the buffer actually follows the available scanout dmabuf formats
|
// FIXME: make sure the buffer actually follows the available scanout dmabuf formats
|
||||||
// and comes from the appropriate device. This may implode on multi-gpu!!
|
// and comes from the appropriate device. This may implode on multi-gpu!!
|
||||||
|
@ -1370,8 +1388,7 @@ bool CMonitor::attemptDirectScanout() {
|
||||||
drmFormat = params.format;
|
drmFormat = params.format;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SAMEBUFFER)
|
output->state->setBuffer(PBUFFER);
|
||||||
output->state->setBuffer(PBUFFER);
|
|
||||||
output->state->setPresentationMode(tearingState.activelyTearing ? Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_IMMEDIATE :
|
output->state->setPresentationMode(tearingState.activelyTearing ? Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_IMMEDIATE :
|
||||||
Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_VSYNC);
|
Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_VSYNC);
|
||||||
|
|
||||||
|
@ -1426,7 +1443,9 @@ bool CMonitor::attemptDirectScanout() {
|
||||||
Debug::log(LOG, "Entered a direct scanout to {:x}: \"{}\"", (uintptr_t)PCANDIDATE.get(), PCANDIDATE->m_szTitle);
|
Debug::log(LOG, "Entered a direct scanout to {:x}: \"{}\"", (uintptr_t)PCANDIDATE.get(), PCANDIDATE->m_szTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PBUFFER->lockedByBackend || PBUFFER->hlEvents.backendRelease || SAMEBUFFER)
|
scanoutNeedsCursorUpdate = false;
|
||||||
|
|
||||||
|
if (!PBUFFER->lockedByBackend || PBUFFER->hlEvents.backendRelease)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// lock buffer while DRM/KMS is using it, then release it when page flip happens since DRM/KMS should be done by then
|
// lock buffer while DRM/KMS is using it, then release it when page flip happens since DRM/KMS should be done by then
|
||||||
|
|
|
@ -158,6 +158,7 @@ class CMonitor {
|
||||||
|
|
||||||
// for direct scanout
|
// for direct scanout
|
||||||
PHLWINDOWREF lastScanout;
|
PHLWINDOWREF lastScanout;
|
||||||
|
bool scanoutNeedsCursorUpdate = false;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool canTear = false;
|
bool canTear = false;
|
||||||
|
|
|
@ -323,6 +323,8 @@ void CPointerManager::onCursorMoved() {
|
||||||
|
|
||||||
const auto CURSORPOS = getCursorPosForMonitor(m);
|
const auto CURSORPOS = getCursorPosForMonitor(m);
|
||||||
m->output->moveCursor(CURSORPOS, m->shouldSkipScheduleFrameOnMouseEvent());
|
m->output->moveCursor(CURSORPOS, m->shouldSkipScheduleFrameOnMouseEvent());
|
||||||
|
|
||||||
|
state->monitor->scanoutNeedsCursorUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recalc)
|
if (recalc)
|
||||||
|
@ -382,6 +384,8 @@ bool CPointerManager::setHWCursorBuffer(SP<SMonitorPointerState> state, SP<Aquam
|
||||||
if (!state->monitor->shouldSkipScheduleFrameOnMouseEvent())
|
if (!state->monitor->shouldSkipScheduleFrameOnMouseEvent())
|
||||||
g_pCompositor->scheduleFrameForMonitor(state->monitor.lock(), Aquamarine::IOutput::AQ_SCHEDULE_CURSOR_SHAPE);
|
g_pCompositor->scheduleFrameForMonitor(state->monitor.lock(), Aquamarine::IOutput::AQ_SCHEDULE_CURSOR_SHAPE);
|
||||||
|
|
||||||
|
state->monitor->scanoutNeedsCursorUpdate = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue