internal: more profiling less calls and local copies (#8300)

* compositor: reduce amount of window box copies

mousemoveunified can call this very frequently, the cbox copying
actually shows up as an impact in such cases, move it down in the scope
and only do it when necessery.

* core: constify and reference frequent calls

profiling shows these as frequent called functions try to reduce the
amount of copies with references and const the variables.

* pointermgr: remove not used local copy, const ref

remove unneded local copies and const ref cursorsize.

* inputmgr: reduce amount of calls to vectortowindow

the amount of calls to g_pCompositor->vectorToWindowUnified fast ramps
up in cpu usage with enough windows existing and moving the mouse, move
the PWINDOWIDEAL up and reuse it if its already the same.

* protocol: compositor remove unused local copy

remove unused local copy of accumulateCurrentBufferDamage and const
previousBuffer.

* renderer: reduce scope of variables and refactor

move a few variables down in their scopes to reduce the amount of calls
and copies when not needed, also add one more for loop in
renderWorkspaceWindows and store the windows in a vector with
weakpointers that should be rendered, this adds a loop but reduces the
amount of repeated calls to shouldRenderWindow and also makes the rest
of the loops go over way smaller vector when many windows exist.
This commit is contained in:
Tom Englund
2024-10-31 00:20:32 +01:00
committed by GitHub
parent a0b2169ed6
commit 7c7a84ff60
13 changed files with 71 additions and 68 deletions

View File

@@ -52,7 +52,7 @@ void CPointerManager::unlockSoftwareAll() {
}
void CPointerManager::lockSoftwareForMonitor(PHLMONITOR mon) {
auto state = stateFor(mon);
auto const state = stateFor(mon);
state->softwareLocks++;
if (state->softwareLocks == 1)
@@ -60,7 +60,7 @@ void CPointerManager::lockSoftwareForMonitor(PHLMONITOR mon) {
}
void CPointerManager::unlockSoftwareForMonitor(PHLMONITOR mon) {
auto state = stateFor(mon);
auto const state = stateFor(mon);
state->softwareLocks--;
if (state->softwareLocks < 0)
state->softwareLocks = 0;
@@ -70,7 +70,7 @@ void CPointerManager::unlockSoftwareForMonitor(PHLMONITOR mon) {
}
bool CPointerManager::softwareLockedFor(PHLMONITOR mon) {
auto state = stateFor(mon);
auto const state = stateFor(mon);
return state->softwareLocks > 0 || state->hardwareFailed;
}
@@ -250,14 +250,13 @@ void CPointerManager::updateCursorBackend() {
const auto CURSORBOX = getCursorBoxGlobal();
for (auto const& m : g_pCompositor->m_vMonitors) {
auto state = stateFor(m);
if (!m->m_bEnabled || !m->dpmsStatus) {
Debug::log(TRACE, "Not updating hw cursors: disabled / dpms off display");
continue;
}
auto CROSSES = !m->logicalBox().intersection(CURSORBOX).empty();
auto state = stateFor(m);
if (!CROSSES) {
if (state->cursorFrontBuffer)
@@ -373,10 +372,8 @@ bool CPointerManager::setHWCursorBuffer(SP<SMonitorPointerState> state, SP<Aquam
}
SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager::SMonitorPointerState> state, SP<CTexture> texture) {
auto output = state->monitor->output;
auto maxSize = output->cursorPlaneSize();
auto cursorSize = currentCursorImage.size;
auto maxSize = state->monitor->output->cursorPlaneSize();
auto const& cursorSize = currentCursorImage.size;
if (maxSize == Vector2D{})
return nullptr;
@@ -423,8 +420,6 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
return nullptr;
}
CRegion damage = {0, 0, INT16_MAX, INT16_MAX};
g_pHyprRenderer->makeEGLCurrent();
g_pHyprOpenGL->m_RenderData.pMonitor = state->monitor;
@@ -483,7 +478,7 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
RBO->bind();
g_pHyprOpenGL->beginSimple(state->monitor.lock(), damage, RBO);
g_pHyprOpenGL->beginSimple(state->monitor.lock(), {0, 0, INT16_MAX, INT16_MAX}, RBO);
g_pHyprOpenGL->clear(CColor{0.F, 0.F, 0.F, 0.F});
CBox xbox = {{}, Vector2D{currentCursorImage.size / currentCursorImage.scale * state->monitor->scale}.round()};