diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 6bb04cfae..97e3fd7af 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -1660,6 +1660,7 @@ SP CHyprOpenGLImpl::blurFramebufferWithDamage(float a, CRegion* or static auto PBLEND = CConfigValue("render:use_shader_blur_blend"); PMIRRORSWAPFB->bind(); + GLFB(PMIRRORSWAPFB)->clearAfterInvalidation(); glActiveTexture(GL_TEXTURE0); @@ -1754,6 +1755,7 @@ SP CHyprOpenGLImpl::blurFramebufferWithDamage(float a, CRegion* or // draw the things. // first draw is swap -> mirr PMIRRORFB->bind(); + GLFB(PMIRRORFB)->clearAfterInvalidation(); PMIRRORSWAPFB->getTexture()->bind(); // damage region will be scaled, make a temp diff --git a/src/render/gl/GLFramebuffer.cpp b/src/render/gl/GLFramebuffer.cpp index d8b198c3e..196f33275 100644 --- a/src/render/gl/GLFramebuffer.cpp +++ b/src/render/gl/GLFramebuffer.cpp @@ -171,4 +171,15 @@ void CGLFramebuffer::invalidate(const std::vector& attachments) { return; glInvalidateFramebuffer(GL_FRAMEBUFFER, attachments.size(), attachments.data()); + m_cleared = false; +} + +void CGLFramebuffer::clearAfterInvalidation() { + if (m_cleared) + return; + + m_cleared = true; + glClearColor(0, 0, 0, 0); + g_pHyprOpenGL->scissor(nullptr); + glClear(GL_COLOR_BUFFER_BIT); } diff --git a/src/render/gl/GLFramebuffer.hpp b/src/render/gl/GLFramebuffer.hpp index 1be5d0e02..34051656f 100644 --- a/src/render/gl/GLFramebuffer.hpp +++ b/src/render/gl/GLFramebuffer.hpp @@ -21,11 +21,15 @@ namespace Render::GL { GLuint getFBID(); void invalidate(const std::vector& attachments); + // clear at most once per invalidate() + void clearAfterInvalidation(); + protected: bool internalAlloc(int w, int h, DRMFormat format = DRM_FORMAT_ARGB8888) override; private: - GLuint m_fb = -1; + GLuint m_fb = -1; + bool m_cleared = false; friend class CGLRenderbuffer; }; diff --git a/src/render/shaders/glsl/blur1.glsl b/src/render/shaders/glsl/blur1.glsl index 86a37d88a..8d9e39aec 100644 --- a/src/render/shaders/glsl/blur1.glsl +++ b/src/render/shaders/glsl/blur1.glsl @@ -104,10 +104,10 @@ vec4 blur1(vec2 v_texcoord, sampler2D tex, float radius, vec2 halfpixel, int pas // That garbage maps to 0.0-1.0 range with UINT8 buffer and doesn't have any significant impact on the end result. // FP16 garbage maps to -65,504 - 65,504 and defines the end result. Clamp it here to 0.0 - 1.0 to get the same quality outcome as with UINT8. // Rerendering an undamaged area to get some insignificant color accuracy increase on blur edges isn't worth it. - sum += clamp(texture(tex, uv - halfpixel.xy * radius), 0.0, 1.0); - sum += clamp(texture(tex, uv + halfpixel.xy * radius), 0.0, 1.0); - sum += clamp(texture(tex, uv + vec2(halfpixel.x, -halfpixel.y) * radius), 0.0, 1.0); - sum += clamp(texture(tex, uv - vec2(halfpixel.x, -halfpixel.y) * radius), 0.0, 1.0); + sum += texture(tex, uv - halfpixel.xy * radius); + sum += texture(tex, uv + halfpixel.xy * radius); + sum += texture(tex, uv + vec2(halfpixel.x, -halfpixel.y) * radius); + sum += texture(tex, uv - vec2(halfpixel.x, -halfpixel.y) * radius); vec4 color = sum / 8.0;