renderer: clamp blur:passes 1-8
fixes some UB and dumb things ref #11707
This commit is contained in:
parent
559024c331
commit
9e74d0aea7
2 changed files with 10 additions and 5 deletions
|
|
@ -1848,11 +1848,13 @@ CFramebuffer* CHyprOpenGLImpl::blurFramebufferWithDamage(float a, CRegion* origi
|
||||||
static auto PBLURVIBRANCY = CConfigValue<Hyprlang::FLOAT>("decoration:blur:vibrancy");
|
static auto PBLURVIBRANCY = CConfigValue<Hyprlang::FLOAT>("decoration:blur:vibrancy");
|
||||||
static auto PBLURVIBRANCYDARKNESS = CConfigValue<Hyprlang::FLOAT>("decoration:blur:vibrancy_darkness");
|
static auto PBLURVIBRANCYDARKNESS = CConfigValue<Hyprlang::FLOAT>("decoration:blur:vibrancy_darkness");
|
||||||
|
|
||||||
|
const auto BLUR_PASSES = std::clamp(*PBLURPASSES, sc<int64_t>(1), sc<int64_t>(8));
|
||||||
|
|
||||||
// prep damage
|
// prep damage
|
||||||
CRegion damage{*originalDamage};
|
CRegion damage{*originalDamage};
|
||||||
damage.transform(wlTransformToHyprutils(invertTransform(m_renderData.pMonitor->m_transform)), m_renderData.pMonitor->m_transformedSize.x,
|
damage.transform(wlTransformToHyprutils(invertTransform(m_renderData.pMonitor->m_transform)), m_renderData.pMonitor->m_transformedSize.x,
|
||||||
m_renderData.pMonitor->m_transformedSize.y);
|
m_renderData.pMonitor->m_transformedSize.y);
|
||||||
damage.expand(*PBLURPASSES > 10 ? pow(2, 15) : std::clamp(*PBLURSIZE, sc<int64_t>(1), sc<int64_t>(40)) * pow(2, *PBLURPASSES));
|
damage.expand(std::clamp(*PBLURSIZE, sc<int64_t>(1), sc<int64_t>(40)) * pow(2, BLUR_PASSES));
|
||||||
|
|
||||||
// helper
|
// helper
|
||||||
const auto PMIRRORFB = &m_renderData.pCurrentMonData->mirrorFB;
|
const auto PMIRRORFB = &m_renderData.pCurrentMonData->mirrorFB;
|
||||||
|
|
@ -1934,7 +1936,7 @@ CFramebuffer* CHyprOpenGLImpl::blurFramebufferWithDamage(float a, CRegion* origi
|
||||||
pShader->setUniformFloat(SHADER_RADIUS, *PBLURSIZE * a); // this makes the blursize change with a
|
pShader->setUniformFloat(SHADER_RADIUS, *PBLURSIZE * a); // this makes the blursize change with a
|
||||||
if (pShader == &m_shaders->m_shBLUR1) {
|
if (pShader == &m_shaders->m_shBLUR1) {
|
||||||
m_shaders->m_shBLUR1.setUniformFloat2(SHADER_HALFPIXEL, 0.5f / (m_renderData.pMonitor->m_pixelSize.x / 2.f), 0.5f / (m_renderData.pMonitor->m_pixelSize.y / 2.f));
|
m_shaders->m_shBLUR1.setUniformFloat2(SHADER_HALFPIXEL, 0.5f / (m_renderData.pMonitor->m_pixelSize.x / 2.f), 0.5f / (m_renderData.pMonitor->m_pixelSize.y / 2.f));
|
||||||
m_shaders->m_shBLUR1.setUniformInt(SHADER_PASSES, *PBLURPASSES);
|
m_shaders->m_shBLUR1.setUniformInt(SHADER_PASSES, BLUR_PASSES);
|
||||||
m_shaders->m_shBLUR1.setUniformFloat(SHADER_VIBRANCY, *PBLURVIBRANCY);
|
m_shaders->m_shBLUR1.setUniformFloat(SHADER_VIBRANCY, *PBLURVIBRANCY);
|
||||||
m_shaders->m_shBLUR1.setUniformFloat(SHADER_VIBRANCY_DARKNESS, *PBLURVIBRANCYDARKNESS);
|
m_shaders->m_shBLUR1.setUniformFloat(SHADER_VIBRANCY_DARKNESS, *PBLURVIBRANCYDARKNESS);
|
||||||
} else
|
} else
|
||||||
|
|
@ -1967,12 +1969,12 @@ CFramebuffer* CHyprOpenGLImpl::blurFramebufferWithDamage(float a, CRegion* origi
|
||||||
CRegion tempDamage{damage};
|
CRegion tempDamage{damage};
|
||||||
|
|
||||||
// and draw
|
// and draw
|
||||||
for (auto i = 1; i <= *PBLURPASSES; ++i) {
|
for (auto i = 1; i <= BLUR_PASSES; ++i) {
|
||||||
tempDamage = damage.copy().scale(1.f / (1 << i));
|
tempDamage = damage.copy().scale(1.f / (1 << i));
|
||||||
drawPass(&m_shaders->m_shBLUR1, &tempDamage); // down
|
drawPass(&m_shaders->m_shBLUR1, &tempDamage); // down
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto i = *PBLURPASSES - 1; i >= 0; --i) {
|
for (auto i = BLUR_PASSES - 1; i >= 0; --i) {
|
||||||
tempDamage = damage.copy().scale(1.f / (1 << i)); // when upsampling we make the region twice as big
|
tempDamage = damage.copy().scale(1.f / (1 << i)); // when upsampling we make the region twice as big
|
||||||
drawPass(&m_shaders->m_shBLUR2, &tempDamage); // up
|
drawPass(&m_shaders->m_shBLUR2, &tempDamage); // up
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,10 @@ float CRenderPass::oneBlurRadius() {
|
||||||
// TODO: is this exact range correct?
|
// TODO: is this exact range correct?
|
||||||
static auto PBLURSIZE = CConfigValue<Hyprlang::INT>("decoration:blur:size");
|
static auto PBLURSIZE = CConfigValue<Hyprlang::INT>("decoration:blur:size");
|
||||||
static auto PBLURPASSES = CConfigValue<Hyprlang::INT>("decoration:blur:passes");
|
static auto PBLURPASSES = CConfigValue<Hyprlang::INT>("decoration:blur:passes");
|
||||||
return *PBLURPASSES > 10 ? pow(2, 15) : std::clamp(*PBLURSIZE, sc<int64_t>(1), sc<int64_t>(40)) * pow(2, *PBLURPASSES); // is this 2^pass? I don't know but it works... I think.
|
|
||||||
|
const auto BLUR_PASSES = std::clamp(*PBLURPASSES, sc<int64_t>(1), sc<int64_t>(8));
|
||||||
|
|
||||||
|
return std::clamp(*PBLURSIZE, sc<int64_t>(1), sc<int64_t>(40)) * pow(2, BLUR_PASSES); // is this 2^pass? I don't know but it works... I think.
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRenderPass::removeAllOfType(const std::string& type) {
|
void CRenderPass::removeAllOfType(const std::string& type) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue