core: optimize some common branches
This commit is contained in:
parent
2e697ce2bf
commit
eff484b96c
3 changed files with 22 additions and 22 deletions
|
|
@ -252,8 +252,8 @@ void CHyprAnimationManager::frameTick() {
|
|||
if (!shouldTickForNext())
|
||||
return;
|
||||
|
||||
if (!g_pCompositor->m_sessionActive || !g_pHookSystem || g_pCompositor->m_unsafeState ||
|
||||
!std::ranges::any_of(g_pCompositor->m_monitors, [](const auto& mon) { return mon->m_enabled && mon->m_output; }))
|
||||
if UNLIKELY (!g_pCompositor->m_sessionActive || !g_pHookSystem || g_pCompositor->m_unsafeState ||
|
||||
!std::ranges::any_of(g_pCompositor->m_monitors, [](const auto& mon) { return mon->m_enabled && mon->m_output; }))
|
||||
return;
|
||||
|
||||
if (!m_lastTickValid || m_lastTickTimer.getMillis() >= 1.0f) {
|
||||
|
|
|
|||
|
|
@ -770,29 +770,29 @@ void CHyprOpenGLImpl::end() {
|
|||
TRACY_GPU_ZONE("RenderEnd");
|
||||
|
||||
// end the render, copy the data to the main framebuffer
|
||||
if (m_offloadedFramebuffer) {
|
||||
if LIKELY (m_offloadedFramebuffer) {
|
||||
m_renderData.damage = m_renderData.finalDamage;
|
||||
pushMonitorTransformEnabled(true);
|
||||
|
||||
CBox monbox = {0, 0, m_renderData.pMonitor->m_transformedSize.x, m_renderData.pMonitor->m_transformedSize.y};
|
||||
|
||||
if (g_pHyprRenderer->m_renderMode == RENDER_MODE_NORMAL && m_renderData.mouseZoomFactor == 1.0f)
|
||||
if LIKELY (g_pHyprRenderer->m_renderMode == RENDER_MODE_NORMAL && m_renderData.mouseZoomFactor == 1.0f)
|
||||
m_renderData.pMonitor->m_zoomController.m_resetCameraState = true;
|
||||
m_renderData.pMonitor->m_zoomController.applyZoomTransform(monbox, m_renderData);
|
||||
|
||||
m_applyFinalShader = !m_renderData.blockScreenShader;
|
||||
if (m_renderData.mouseZoomUseMouse && *PZOOMDISABLEAA)
|
||||
if UNLIKELY (m_renderData.mouseZoomFactor != 1.F && m_renderData.mouseZoomUseMouse && *PZOOMDISABLEAA)
|
||||
m_renderData.useNearestNeighbor = true;
|
||||
|
||||
// copy the damaged areas into the mirror buffer
|
||||
// we can't use the offloadFB for mirroring, as it contains artifacts from blurring
|
||||
if (!m_renderData.pMonitor->m_mirrors.empty() && !m_fakeFrame)
|
||||
if UNLIKELY (!m_renderData.pMonitor->m_mirrors.empty() && !m_fakeFrame)
|
||||
saveBufferForMirror(monbox);
|
||||
|
||||
m_renderData.outFB->bind();
|
||||
blend(false);
|
||||
|
||||
if (m_finalScreenShader->program() < 1 && !g_pHyprRenderer->m_crashingInProgress)
|
||||
if LIKELY (m_finalScreenShader->program() < 1 && !g_pHyprRenderer->m_crashingInProgress)
|
||||
renderTexturePrimitive(m_renderData.pCurrentMonData->offloadFB.getTexture(), monbox);
|
||||
else
|
||||
renderTexture(m_renderData.pCurrentMonData->offloadFB.getTexture(), monbox, {});
|
||||
|
|
@ -827,13 +827,13 @@ void CHyprOpenGLImpl::end() {
|
|||
// if we dropped to offMain, release it now.
|
||||
// if there is a plugin constantly using it, this might be a bit slow,
|
||||
// but I haven't seen a single plugin yet use these, so it's better to drop a bit of vram.
|
||||
if (m_renderData.pCurrentMonData->offMainFB.isAllocated())
|
||||
if UNLIKELY (m_renderData.pCurrentMonData->offMainFB.isAllocated())
|
||||
m_renderData.pCurrentMonData->offMainFB.release();
|
||||
|
||||
// check for gl errors
|
||||
const GLenum ERR = glGetError();
|
||||
|
||||
if (ERR == GL_CONTEXT_LOST) /* We don't have infra to recover from this */
|
||||
if UNLIKELY (ERR == GL_CONTEXT_LOST) /* We don't have infra to recover from this */
|
||||
RASSERT(false, "glGetError at Opengl::end() returned GL_CONTEXT_LOST. Cannot continue until proper GPU reset handling is implemented.");
|
||||
}
|
||||
|
||||
|
|
@ -3076,7 +3076,7 @@ UP<CEGLSync> CEGLSync::create() {
|
|||
|
||||
EGLSyncKHR sync = g_pHyprOpenGL->m_proc.eglCreateSyncKHR(g_pHyprOpenGL->m_eglDisplay, EGL_SYNC_NATIVE_FENCE_ANDROID, nullptr);
|
||||
|
||||
if (sync == EGL_NO_SYNC_KHR) {
|
||||
if UNLIKELY (sync == EGL_NO_SYNC_KHR) {
|
||||
Log::logger->log(Log::ERR, "eglCreateSyncKHR failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -3085,7 +3085,7 @@ UP<CEGLSync> CEGLSync::create() {
|
|||
glFlush();
|
||||
|
||||
int fd = g_pHyprOpenGL->m_proc.eglDupNativeFenceFDANDROID(g_pHyprOpenGL->m_eglDisplay, sync);
|
||||
if (fd == EGL_NO_NATIVE_FENCE_FD_ANDROID) {
|
||||
if UNLIKELY (fd == EGL_NO_NATIVE_FENCE_FD_ANDROID) {
|
||||
Log::logger->log(Log::ERR, "eglDupNativeFenceFDANDROID failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -3099,10 +3099,10 @@ UP<CEGLSync> CEGLSync::create() {
|
|||
}
|
||||
|
||||
CEGLSync::~CEGLSync() {
|
||||
if (m_sync == EGL_NO_SYNC_KHR)
|
||||
if UNLIKELY (m_sync == EGL_NO_SYNC_KHR)
|
||||
return;
|
||||
|
||||
if (g_pHyprOpenGL && g_pHyprOpenGL->m_proc.eglDestroySyncKHR(g_pHyprOpenGL->m_eglDisplay, m_sync) != EGL_TRUE)
|
||||
if UNLIKELY (g_pHyprOpenGL && g_pHyprOpenGL->m_proc.eglDestroySyncKHR(g_pHyprOpenGL->m_eglDisplay, m_sync) != EGL_TRUE)
|
||||
Log::logger->log(Log::ERR, "eglDestroySyncKHR failed");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -902,10 +902,10 @@ void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPA
|
|||
static auto PXPMODE = CConfigValue<Hyprlang::INT>("render:xp_mode");
|
||||
static auto PSESSIONLOCKXRAY = CConfigValue<Hyprlang::INT>("misc:session_lock_xray");
|
||||
|
||||
if (!pMonitor)
|
||||
if UNLIKELY (!pMonitor)
|
||||
return;
|
||||
|
||||
if (g_pSessionLockManager->isSessionLocked() && !*PSESSIONLOCKXRAY) {
|
||||
if UNLIKELY (g_pSessionLockManager->isSessionLocked() && !*PSESSIONLOCKXRAY) {
|
||||
// We stop to render workspaces as soon as the lockscreen was sent the "locked" or "finished" (aka denied) event.
|
||||
// In addition we make sure to stop rendering workspaces after misc:lockdead_screen_delay has passed.
|
||||
if (g_pSessionLockManager->shallConsiderLockMissing() || g_pSessionLockManager->clientLocked() || g_pSessionLockManager->clientDenied())
|
||||
|
|
@ -919,10 +919,10 @@ void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPA
|
|||
SRenderModifData RENDERMODIFDATA;
|
||||
if (translate != Vector2D{0, 0})
|
||||
RENDERMODIFDATA.modifs.emplace_back(std::make_pair<>(SRenderModifData::eRenderModifType::RMOD_TYPE_TRANSLATE, translate));
|
||||
if (scale != 1.f)
|
||||
if UNLIKELY (scale != 1.f)
|
||||
RENDERMODIFDATA.modifs.emplace_back(std::make_pair<>(SRenderModifData::eRenderModifType::RMOD_TYPE_SCALE, scale));
|
||||
|
||||
if (!RENDERMODIFDATA.modifs.empty())
|
||||
if UNLIKELY (!RENDERMODIFDATA.modifs.empty())
|
||||
g_pHyprRenderer->m_renderPass.add(makeUnique<CRendererHintsPassElement>(CRendererHintsPassElement::SData{RENDERMODIFDATA}));
|
||||
|
||||
CScopeGuard x([&RENDERMODIFDATA] {
|
||||
|
|
@ -931,7 +931,7 @@ void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPA
|
|||
}
|
||||
});
|
||||
|
||||
if (!pWorkspace) {
|
||||
if UNLIKELY (!pWorkspace) {
|
||||
// allow rendering without a workspace. In this case, just render layers.
|
||||
|
||||
renderBackground(pMonitor);
|
||||
|
|
@ -957,7 +957,7 @@ void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPA
|
|||
return;
|
||||
}
|
||||
|
||||
if (!*PXPMODE) {
|
||||
if LIKELY (!*PXPMODE) {
|
||||
renderBackground(pMonitor);
|
||||
|
||||
for (auto const& ls : pMonitor->m_layerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]) {
|
||||
|
|
@ -974,13 +974,13 @@ void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPA
|
|||
// pre window pass
|
||||
g_pHyprOpenGL->preWindowPass();
|
||||
|
||||
if (pWorkspace->m_hasFullscreenWindow)
|
||||
if UNLIKELY /* subjective? */ (pWorkspace->m_hasFullscreenWindow)
|
||||
renderWorkspaceWindowsFullscreen(pMonitor, pWorkspace, time);
|
||||
else
|
||||
renderWorkspaceWindows(pMonitor, pWorkspace, time);
|
||||
|
||||
// and then special
|
||||
if (pMonitor->m_specialFade->value() != 0.F) {
|
||||
if UNLIKELY (pMonitor->m_specialFade->value() != 0.F) {
|
||||
const auto SPECIALANIMPROGRS = pMonitor->m_specialFade->getCurveValue();
|
||||
const bool ANIMOUT = !pMonitor->m_activeSpecialWorkspace;
|
||||
|
||||
|
|
@ -2370,7 +2370,7 @@ void CHyprRenderer::endRender(const std::function<void()>& renderingDoneCallback
|
|||
}
|
||||
|
||||
UP<CEGLSync> eglSync = CEGLSync::create();
|
||||
if (eglSync && eglSync->isValid()) {
|
||||
if LIKELY (eglSync && eglSync->isValid()) {
|
||||
for (auto const& buf : m_usedAsyncBuffers) {
|
||||
for (const auto& releaser : buf->m_syncReleasers) {
|
||||
releaser->addSyncFileFd(eglSync->fd());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue