Skip to content

Commit

Permalink
ee
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Dec 9, 2024
1 parent 137bf57 commit 66068b0
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 16 deletions.
7 changes: 5 additions & 2 deletions src/protocols/core/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,14 @@ void CWLSurfaceResource::updateCursorShm(CRegion damage) {
}
}

void CWLSurfaceResource::presentFeedback(timespec* when, PHLMONITOR pMonitor) {
void CWLSurfaceResource::presentFeedback(timespec* when, PHLMONITOR pMonitor, bool discarded) {
frame(when);
auto FEEDBACK = makeShared<CQueuedPresentationData>(self.lock());
FEEDBACK->attachMonitor(pMonitor);
FEEDBACK->presented();
if (discarded)
FEEDBACK->discarded();
else
FEEDBACK->presented();
PROTO::presentation->queueData(FEEDBACK);

if (!pMonitor || !pMonitor->outTimeline || !syncobj)
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/core/Compositor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class CWLSurfaceResource {

void breadthfirst(std::function<void(SP<CWLSurfaceResource>, const Vector2D&, void*)> fn, void* data);
CRegion accumulateCurrentBufferDamage();
void presentFeedback(timespec* when, PHLMONITOR pMonitor);
void presentFeedback(timespec* when, PHLMONITOR pMonitor, bool discarded = false);
void lockPendingState();
void unlockPendingState();

Expand Down
16 changes: 9 additions & 7 deletions src/render/pass/Pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ 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
const auto WILLBLUR = std::ranges::any_of(m_vPassElements, [](const auto& el) { return el->element->needsLiveBlur(); });
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});
CRegion newDamage = damage.copy().intersect(CBox{{}, g_pHyprOpenGL->m_RenderData.pMonitor->vecSize});
for (auto& el : m_vPassElements | std::views::reverse) {

if (newDamage.empty()) {
toRemove.emplace_back(el);
el->discard = true;
continue;
}

Expand All @@ -42,7 +41,7 @@ void CRenderPass::simplify() {

// drop if empty
if (CRegion copy = newDamage.copy(); copy.intersect(*bb).empty()) {
toRemove.emplace_back(el);
el->discard = true;
continue;
}

Expand Down Expand Up @@ -77,8 +76,6 @@ void CRenderPass::simplify() {
newDamage.subtract(opaque);
}
}

std::erase_if(m_vPassElements, [&toRemove](const auto& el) { return std::find(toRemove.begin(), toRemove.end(), el) != toRemove.end(); });
}

void CRenderPass::clear() {
Expand Down Expand Up @@ -129,6 +126,11 @@ CRegion CRenderPass::render(const CRegion& damage_) {
return {};

for (auto& el : m_vPassElements) {
if (el->discard) {
el->element->discard();
continue;
}

g_pHyprOpenGL->m_RenderData.damage = el->elementDamage;
el->element->draw(el->elementDamage);
}
Expand Down
2 changes: 2 additions & 0 deletions src/render/pass/Pass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ class CRenderPass {
struct SPassElementData {
CRegion elementDamage;
SP<IPassElement> element;
bool discard = false;
};

std::vector<SP<SPassElementData>> m_vPassElements;
std::vector<SP<SPassElementData>> m_vDiscardedPassElements;

SP<IPassElement> currentPassInfo = nullptr;

Expand Down
4 changes: 4 additions & 0 deletions src/render/pass/PassElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ CRegion IPassElement::opaqueRegion() {
bool IPassElement::disableSimplification() {
return false;
}

void IPassElement::discard() {
;
}
1 change: 1 addition & 0 deletions src/render/pass/PassElement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class IPassElement {
virtual bool needsLiveBlur() = 0;
virtual bool needsPrecomputeBlur() = 0;
virtual const char* passName() = 0;
virtual void discard();
virtual std::optional<CBox> boundingBox();
virtual CRegion opaqueRegion();
virtual bool disableSimplification();
Expand Down
18 changes: 12 additions & 6 deletions src/render/pass/TexPassElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,8 @@ void CTexPassElement::draw(const CRegion& damage) {
windowBox.round();

if (windowBox.width <= 1 || windowBox.height <= 1) {
if (!g_pHyprRenderer->m_bBlockSurfaceFeedback) {
Debug::log(TRACE, "presentFeedback for invisible surface");
data.surface->presentFeedback(data.when, data.pMonitor->self.lock());
}

return; // invisible
discard();
return;
}

const bool MISALIGNEDFSV1 = std::floor(data.pMonitor->scale) != data.pMonitor->scale /* Fractional */ && data.surface->current.scale == 1 /* fs protocol */ &&
Expand Down Expand Up @@ -239,3 +235,13 @@ CRegion CTexPassElement::opaqueRegion() {

return data.texture && data.texture->m_bOpaque ? boundingBox()->expand(-data.rounding) : CRegion{};
}

void CTexPassElement::discard() {
if (simple)
return;

if (!g_pHyprRenderer->m_bBlockSurfaceFeedback) {
Debug::log(TRACE, "discard for invisible surface");
data.surface->presentFeedback(data.when, data.pMonitor->self.lock(), true);
}
}
1 change: 1 addition & 0 deletions src/render/pass/TexPassElement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class CTexPassElement : public IPassElement {
virtual bool needsPrecomputeBlur();
virtual std::optional<CBox> boundingBox();
virtual CRegion opaqueRegion();
virtual void discard();

virtual const char* passName() {
return "CTexPassElement";
Expand Down

0 comments on commit 66068b0

Please sign in to comment.