From 9f3c9ac01a9a6ecef74429dc9a1dea250ef43c50 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Wed, 1 Jan 2025 21:35:42 +0100 Subject: [PATCH] pass: mark crucial elements as undiscardable --- src/render/pass/FramebufferElement.cpp | 6 +++++- src/render/pass/FramebufferElement.hpp | 1 + src/render/pass/Pass.cpp | 4 ++-- src/render/pass/PassElement.cpp | 4 ++++ src/render/pass/PassElement.hpp | 1 + src/render/pass/PreBlurElement.cpp | 4 ++++ src/render/pass/PreBlurElement.hpp | 1 + src/render/pass/RendererHintsPassElement.cpp | 4 ++++ src/render/pass/RendererHintsPassElement.hpp | 1 + 9 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/render/pass/FramebufferElement.cpp b/src/render/pass/FramebufferElement.cpp index 268e5589..8271777f 100644 --- a/src/render/pass/FramebufferElement.cpp +++ b/src/render/pass/FramebufferElement.cpp @@ -45,4 +45,8 @@ bool CFramebufferElement::needsLiveBlur() { bool CFramebufferElement::needsPrecomputeBlur() { return false; -} \ No newline at end of file +} + +bool CFramebufferElement::undiscardable() { + return true; +} diff --git a/src/render/pass/FramebufferElement.hpp b/src/render/pass/FramebufferElement.hpp index f3d181d4..ab1f1426 100644 --- a/src/render/pass/FramebufferElement.hpp +++ b/src/render/pass/FramebufferElement.hpp @@ -14,6 +14,7 @@ class CFramebufferElement : public IPassElement { virtual void draw(const CRegion& damage); virtual bool needsLiveBlur(); virtual bool needsPrecomputeBlur(); + virtual bool undiscardable(); virtual const char* passName() { return "CFramebufferElement"; diff --git a/src/render/pass/Pass.cpp b/src/render/pass/Pass.cpp index a2ecddaa..8fdc3049 100644 --- a/src/render/pass/Pass.cpp +++ b/src/render/pass/Pass.cpp @@ -35,14 +35,14 @@ void CRenderPass::simplify() { CRegion newDamage = damage.copy().intersect(CBox{{}, g_pHyprOpenGL->m_RenderData.pMonitor->vecTransformedSize}); for (auto& el : m_vPassElements | std::views::reverse) { - if (newDamage.empty()) { + if (newDamage.empty() && !el->element->undiscardable()) { el->discard = true; continue; } el->elementDamage = newDamage; auto bb1 = el->element->boundingBox(); - if (!bb1) + if (!bb1 || newDamage.empty()) continue; auto bb = bb1->scale(g_pHyprOpenGL->m_RenderData.pMonitor->scale); diff --git a/src/render/pass/PassElement.cpp b/src/render/pass/PassElement.cpp index 737c6b27..3ae52ef5 100644 --- a/src/render/pass/PassElement.cpp +++ b/src/render/pass/PassElement.cpp @@ -15,3 +15,7 @@ bool IPassElement::disableSimplification() { void IPassElement::discard() { ; } + +bool IPassElement::undiscardable() { + return false; +} diff --git a/src/render/pass/PassElement.hpp b/src/render/pass/PassElement.hpp index 025840f4..b45970aa 100644 --- a/src/render/pass/PassElement.hpp +++ b/src/render/pass/PassElement.hpp @@ -12,6 +12,7 @@ class IPassElement { virtual bool needsPrecomputeBlur() = 0; virtual const char* passName() = 0; virtual void discard(); + virtual bool undiscardable(); virtual std::optional boundingBox(); virtual CRegion opaqueRegion(); virtual bool disableSimplification(); diff --git a/src/render/pass/PreBlurElement.cpp b/src/render/pass/PreBlurElement.cpp index 9fa3471d..6f282232 100644 --- a/src/render/pass/PreBlurElement.cpp +++ b/src/render/pass/PreBlurElement.cpp @@ -18,3 +18,7 @@ bool CPreBlurElement::needsPrecomputeBlur() { bool CPreBlurElement::disableSimplification() { return true; } + +bool CPreBlurElement::undiscardable() { + return true; +} diff --git a/src/render/pass/PreBlurElement.hpp b/src/render/pass/PreBlurElement.hpp index 6c52c815..80474a29 100644 --- a/src/render/pass/PreBlurElement.hpp +++ b/src/render/pass/PreBlurElement.hpp @@ -10,6 +10,7 @@ class CPreBlurElement : public IPassElement { virtual bool needsLiveBlur(); virtual bool needsPrecomputeBlur(); virtual bool disableSimplification(); + virtual bool undiscardable(); virtual const char* passName() { return "CPreBlurElement"; diff --git a/src/render/pass/RendererHintsPassElement.cpp b/src/render/pass/RendererHintsPassElement.cpp index 8ea79a27..5b6d0098 100644 --- a/src/render/pass/RendererHintsPassElement.cpp +++ b/src/render/pass/RendererHintsPassElement.cpp @@ -17,3 +17,7 @@ bool CRendererHintsPassElement::needsLiveBlur() { bool CRendererHintsPassElement::needsPrecomputeBlur() { return false; } + +bool CRendererHintsPassElement::undiscardable() { + return true; +} diff --git a/src/render/pass/RendererHintsPassElement.hpp b/src/render/pass/RendererHintsPassElement.hpp index 99ed0759..a333e031 100644 --- a/src/render/pass/RendererHintsPassElement.hpp +++ b/src/render/pass/RendererHintsPassElement.hpp @@ -15,6 +15,7 @@ class CRendererHintsPassElement : public IPassElement { virtual void draw(const CRegion& damage); virtual bool needsLiveBlur(); virtual bool needsPrecomputeBlur(); + virtual bool undiscardable(); virtual const char* passName() { return "CRendererHintsPassElement";