opengl: minor egl changes (#14147)

* opengl: explicitly set stencil mask

set stencil mask to 0xFF to allow writes, when done set it back to 0x00
to become readonly, avoids potential mishaps. also at the end set the
stencil op to GL_KEEP and it will certainly be read only until next time
its changed.

* opengl: use modern glClearBufferfv over glClear

use more modern glClearBufferfv instead, and also clear the entire
buffer if a clearpass has been added but no renderdamage exist.
This commit is contained in:
Tom Englund 2026-04-23 14:32:11 +02:00 committed by GitHub
parent 300cdb7c32
commit b65714e3b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View file

@ -1933,6 +1933,7 @@ void CHyprOpenGLImpl::renderTextureWithBlurInternal(SP<ITexture> tex, const CBox
if (NEEDS_STENCIL) {
scissor(nullptr); // allow the entire window and stencil to render
glStencilMask(0xFF);
glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT);
@ -1964,7 +1965,8 @@ void CHyprOpenGLImpl::renderTextureWithBlurInternal(SP<ITexture> tex, const CBox
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glStencilFunc(GL_EQUAL, 1, 0xFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glStencilMask(0x00);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
}
// stencil done. Render everything.

View file

@ -24,15 +24,17 @@ void CGLElementRenderer::draw(WP<CClearPassElement> element, const CRegion& dama
RASSERT(g_pHyprRenderer->m_renderData.pMonitor, "Tried to render without begin()!");
TRACY_GPU_ZONE("RenderClear");
GLCALL(glClearColor(color.r, color.g, color.b, color.a));
const std::array<GLfloat, 4> c = {sc<GLfloat>(color.r), sc<GLfloat>(color.g), sc<GLfloat>(color.b), sc<GLfloat>(color.a)};
if (!g_pHyprRenderer->m_renderData.damage.empty()) {
g_pHyprRenderer->m_renderData.damage.forEachRect([](const auto& RECT) {
g_pHyprRenderer->m_renderData.damage.forEachRect([&c](const auto& RECT) {
g_pHyprOpenGL->scissor(&RECT, g_pHyprRenderer->m_renderData.transformDamage);
glClear(GL_COLOR_BUFFER_BIT);
glClearBufferfv(GL_COLOR, 0, c.data());
});
}
g_pHyprOpenGL->scissor(nullptr);
} else
glClearBufferfv(GL_COLOR, 0, c.data());
};
void CGLElementRenderer::draw(WP<CFramebufferElement> element, const CRegion& damage) {