renderer: only commit hw cursor stuff if needed (#9654)

This commit is contained in:
Ikalco 2025-03-17 16:06:41 -05:00 committed by GitHub
parent c4f46473df
commit 5f60fc7d00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 5 deletions

View file

@ -1356,7 +1356,25 @@ 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,7 +1388,6 @@ 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

View file

@ -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;

View file

@ -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;
} }