From 1830296df3515222bf0f03b90822e3b23e74b775 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 22 Dec 2024 17:20:33 +0000 Subject: [PATCH] debug: add debug:pass for debugging the render pass --- src/config/ConfigManager.cpp | 1 + src/render/pass/Pass.cpp | 30 ++++++++++++++++++++++++++++-- src/render/pass/Pass.hpp | 2 ++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 9b6e29e40..f9ad54aa2 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -413,6 +413,7 @@ CConfigManager::CConfigManager() { m_pConfig->addConfigValue("debug:log_damage", Hyprlang::INT{0}); m_pConfig->addConfigValue("debug:overlay", Hyprlang::INT{0}); m_pConfig->addConfigValue("debug:damage_blink", Hyprlang::INT{0}); + m_pConfig->addConfigValue("debug:pass", Hyprlang::INT{0}); m_pConfig->addConfigValue("debug:disable_logs", Hyprlang::INT{1}); m_pConfig->addConfigValue("debug:disable_time", Hyprlang::INT{1}); m_pConfig->addConfigValue("debug:enable_stdout_logs", Hyprlang::INT{0}); diff --git a/src/render/pass/Pass.cpp b/src/render/pass/Pass.cpp index 31385acb7..b6256c44d 100644 --- a/src/render/pass/Pass.cpp +++ b/src/render/pass/Pass.cpp @@ -21,6 +21,8 @@ void CRenderPass::add(SP el) { } void CRenderPass::simplify() { + static auto PDEBUGPASS = CConfigValue("debug:pass"); + // 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 @@ -78,6 +80,20 @@ void CRenderPass::simplify() { } } newDamage.subtract(opaque); + if (*PDEBUGPASS) + occludedRegion.add(opaque); + } + } + + if (*PDEBUGPASS) { + for (auto& el2 : m_vPassElements) { + if (!el2->element->needsLiveBlur()) + continue; + + const auto BB = el2->element->boundingBox(); + RASSERT(BB, "No bounding box for an element with live blur is illegal"); + + totalLiveBlurRegion.add(*BB); } } } @@ -87,9 +103,13 @@ void CRenderPass::clear() { } CRegion CRenderPass::render(const CRegion& damage_) { - const auto WILLBLUR = std::ranges::any_of(m_vPassElements, [](const auto& el) { return el->element->needsLiveBlur(); }); + static auto PDEBUGPASS = CConfigValue("debug:pass"); - damage = damage_.copy(); + 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{}; if (damage.empty()) { g_pHyprOpenGL->m_RenderData.damage = damage; @@ -145,6 +165,12 @@ CRegion CRenderPass::render(const CRegion& damage_) { el->element->draw(el->elementDamage); } + if (*PDEBUGPASS) { + CBox monbox = {{}, g_pHyprOpenGL->m_RenderData.pMonitor->vecTransformedSize}; + g_pHyprOpenGL->renderRectWithDamage(&monbox, CHyprColor{1.F, 0.1F, 0.1F, 0.5F}, occludedRegion); + g_pHyprOpenGL->renderRectWithDamage(&monbox, CHyprColor{0.1F, 1.F, 0.1F, 0.5F}, totalLiveBlurRegion); + } + g_pHyprOpenGL->m_RenderData.damage = damage; return damage; } diff --git a/src/render/pass/Pass.hpp b/src/render/pass/Pass.hpp index 7f332c19c..6fe6938f5 100644 --- a/src/render/pass/Pass.hpp +++ b/src/render/pass/Pass.hpp @@ -18,6 +18,8 @@ class CRenderPass { private: CRegion damage; + CRegion occludedRegion; + CRegion totalLiveBlurRegion; struct SPassElementData { CRegion elementDamage;