Skip to content

Commit

Permalink
Stuf
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Dec 9, 2024
1 parent a7f6dd4 commit 5cea2fd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/render/OpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ bool CHyprOpenGLImpl::passRequiresIntrospection(PHLMONITOR pMonitor) {
if (*PBLUR == 0)
return false;

if (m_RenderData.pCurrentMonData->blurFBShouldRender)
if (preBlurQueued())
return true;

if (!pMonitor->solitaryClient.expired())
Expand Down Expand Up @@ -2020,7 +2020,7 @@ bool CHyprOpenGLImpl::preBlurQueued() {
static auto PBLURNEWOPTIMIZE = CConfigValue<Hyprlang::INT>("decoration:blur:new_optimizations");
static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled");

return !(!m_RenderData.pCurrentMonData->blurFBDirty || !*PBLURNEWOPTIMIZE || !*PBLUR || !m_RenderData.pCurrentMonData->blurFBShouldRender);
return m_RenderData.pCurrentMonData->blurFBDirty && *PBLURNEWOPTIMIZE && *PBLUR && m_RenderData.pCurrentMonData->blurFBShouldRender;
}

bool CHyprOpenGLImpl::shouldUseNewBlurOptimizations(PHLLS pLayer, PHLWINDOW pWindow) {
Expand Down
56 changes: 28 additions & 28 deletions src/render/pass/Pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,7 @@ void CRenderPass::simplify() {
// TODO: use precompute blur for instances where there is nothing in between

// if there is live blur, we need to NOT occlude any area where it will be influenced
// TODO: do this better. This should be layered, cuz we don't need to check infringement
// if the blur is ABOVE our thing.
CRegion liveBlurRegion;
for (auto& el : m_vPassElements) {
if (!el->element->needsLiveBlur())
continue;

const auto BB = el->element->boundingBox();
RASSERT(BB, "No bounding box for an element with live blur is illegal");

liveBlurRegion.add(*BB);
}
const auto WILLBLUR = std::ranges::any_of(m_vPassElements, [](const auto& el) { return el->element->needsLiveBlur(); });

std::vector<SP<SPassElementData>> toRemove;
CRegion newDamage = damage.copy().intersect(CBox{{}, g_pHyprOpenGL->m_RenderData.pMonitor->vecSize});
Expand All @@ -62,10 +51,28 @@ void CRenderPass::simplify() {
if (!opaque.empty()) {
// if this intersects the liveBlur region, allow live blur to operate correctly.
// do not occlude a border near it.
if (auto infringement = opaque.copy().intersect(liveBlurRegion); !infringement.empty()) {
// eh, this is not the correct solution, but it will do...
// TODO: is this *easily* fixable?
opaque.subtract(infringement);
if (WILLBLUR) {
CRegion liveBlurRegion;
for (auto& el2 : m_vPassElements) {
// if we reach self, no problem, we can break.
// if the blur is above us, we don't care, it will work fine.
if (el2 == el)
break;

if (!el2->element->needsLiveBlur())
continue;

const auto BB = el2->element->boundingBox();
RASSERT(BB, "No bounding box for an element with live blur is illegal");

liveBlurRegion.add(*BB);
}

if (auto infringement = opaque.copy().intersect(liveBlurRegion); !infringement.empty()) {
// eh, this is not the correct solution, but it will do...
// TODO: is this *easily* fixable?
opaque.subtract(infringement.expand(oneBlurRadius()));
}
}
newDamage.subtract(opaque);
}
Expand Down Expand Up @@ -96,13 +103,14 @@ CRegion CRenderPass::render(const CRegion& damage_) {
blurRegion.add(*BB);
}

blurRegion.intersect(damage);

blurRegion = expandRegionForBlur(blurRegion);
blurRegion.intersect(damage).expand(oneBlurRadius());

g_pHyprOpenGL->m_RenderData.finalDamage = blurRegion.copy().add(damage);

blurRegion = expandRegionForBlur(blurRegion);
// FIXME: why does this break on * 1.F ?
// used to work when we expand all the damage... I think? Well, before pass.
// moving a window over blur shows the edges being wonk.
blurRegion.expand(oneBlurRadius() * 1.5F);

damage = blurRegion.copy().add(damage);
} else
Expand Down Expand Up @@ -135,11 +143,3 @@ float CRenderPass::oneBlurRadius() {
static auto PBLURPASSES = CConfigValue<Hyprlang::INT>("decoration:blur:passes");
return *PBLURPASSES > 10 ? pow(2, 15) : std::clamp(*PBLURSIZE, (int64_t)1, (int64_t)40) * pow(2, *PBLURPASSES); // is this 2^pass? I don't know but it works... I think.
}

// If we use live blur we need to expand the damage for proper blurring.
// This function expands only ONCE, while we need to expand twice.
// Once for final damage
// Once more for rendering
CRegion CRenderPass::expandRegionForBlur(const CRegion& rg) {
return rg.copy().expand(oneBlurRadius());
}
1 change: 0 additions & 1 deletion src/render/pass/Pass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class CRenderPass {
SP<IPassElement> currentPassInfo = nullptr;

void simplify();
CRegion expandRegionForBlur(const CRegion& rg);
float oneBlurRadius();

friend class CHyprOpenGLImpl;
Expand Down

0 comments on commit 5cea2fd

Please sign in to comment.