Skip to content

Commit

Permalink
pass: improve pass debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Jan 5, 2025
1 parent a5c1437 commit 391ff29
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
42 changes: 37 additions & 5 deletions src/render/pass/Pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void CRenderPass::simplify() {
}
newDamage.subtract(opaque);
if (*PDEBUGPASS)
occludedRegion.add(opaque);
occludedRegions.emplace_back(opaque);
}
}

Expand All @@ -114,9 +114,11 @@ CRegion CRenderPass::render(const CRegion& damage_) {

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

damage = *PDEBUGPASS ? CRegion{CBox{{}, {INT32_MAX, INT32_MAX}}} : damage_.copy();
occludedRegion = CRegion{};
totalLiveBlurRegion = CRegion{};
damage = *PDEBUGPASS ? CRegion{CBox{{}, {INT32_MAX, INT32_MAX}}} : damage_.copy();
if (*PDEBUGPASS) {
occludedRegions.clear();
totalLiveBlurRegion = CRegion{};
}

if (damage.empty()) {
g_pHyprOpenGL->m_RenderData.damage = damage;
Expand Down Expand Up @@ -198,7 +200,9 @@ CRegion CRenderPass::render(const CRegion& damage_) {

void CRenderPass::renderDebugData() {
CBox box = {{}, g_pHyprOpenGL->m_RenderData.pMonitor->vecTransformedSize};
g_pHyprOpenGL->renderRectWithDamage(&box, Colors::RED.modifyA(0.1F), occludedRegion);
for (const auto& rg : occludedRegions) {
g_pHyprOpenGL->renderRectWithDamage(&box, Colors::RED.modifyA(0.1F), rg);
}
g_pHyprOpenGL->renderRectWithDamage(&box, Colors::GREEN.modifyA(0.1F), totalLiveBlurRegion);

std::unordered_map<CWLSurfaceResource*, float> offsets;
Expand Down Expand Up @@ -239,6 +243,34 @@ void CRenderPass::renderDebugData() {
renderHLSurface(debugData.pointerFocusText, g_pSeatManager->state.pointerFocus.lock(), Colors::ORANGE.modifyA(0.1F));
if (g_pCompositor->m_pLastWindow)
renderHLSurface(debugData.lastWindowText, g_pCompositor->m_pLastWindow->m_pWLSurface->resource(), Colors::LIGHT_BLUE.modifyA(0.1F));

const auto DISCARDED_ELEMENTS = std::count_if(m_vPassElements.begin(), m_vPassElements.end(), [](const auto& e) { return e->discard; });
auto tex = g_pHyprOpenGL->renderText(std::format("occlusion layers: {}\npass elements: {} ({} discarded)\nviewport: {:X0}", occludedRegions.size(), m_vPassElements.size(),
DISCARDED_ELEMENTS, g_pHyprOpenGL->m_RenderData.pMonitor->vecPixelSize),
Colors::WHITE, 12);

if (tex) {
box = CBox{{0.F, g_pHyprOpenGL->m_RenderData.pMonitor->vecSize.y - tex->m_vSize.y}, tex->m_vSize}.scale(g_pHyprOpenGL->m_RenderData.pMonitor->scale);
g_pHyprOpenGL->renderTexture(tex, &box, 1.F);
}

std::string passStructure;
auto yn = [](const bool val) -> const char* { return val ? "yes" : "no"; };
auto tick = [](const bool val) -> const char* { return val ? "" : ""; };
for (const auto& el : m_vPassElements | std::views::reverse) {
passStructure += std::format("{} {} (bb: {} op: {})\n", tick(!el->discard), el->element->passName(), yn(el->element->boundingBox().has_value()),
yn(!el->element->opaqueRegion().empty()));
}

if (!passStructure.empty())
passStructure.pop_back();

tex = g_pHyprOpenGL->renderText(passStructure, Colors::WHITE, 12);
if (tex) {
box = CBox{{g_pHyprOpenGL->m_RenderData.pMonitor->vecSize.x - tex->m_vSize.x, g_pHyprOpenGL->m_RenderData.pMonitor->vecSize.y - tex->m_vSize.y}, tex->m_vSize}.scale(
g_pHyprOpenGL->m_RenderData.pMonitor->scale);
g_pHyprOpenGL->renderTexture(tex, &box, 1.F);
}
}

float CRenderPass::oneBlurRadius() {
Expand Down
6 changes: 3 additions & 3 deletions src/render/pass/Pass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class CRenderPass {
CRegion render(const CRegion& damage_);

private:
CRegion damage;
CRegion occludedRegion;
CRegion totalLiveBlurRegion;
CRegion damage;
std::vector<CRegion> occludedRegions;
CRegion totalLiveBlurRegion;

struct SPassElementData {
CRegion elementDamage;
Expand Down

0 comments on commit 391ff29

Please sign in to comment.