mirror of
https://github.com/hyprwm/Hyprland
synced 2026-05-07 19:18:05 +02:00
fix fp16 blur with invalidation
This commit is contained in:
parent
c065e951d6
commit
f4ce197905
4 changed files with 22 additions and 5 deletions
|
|
@ -1660,6 +1660,7 @@ SP<IFramebuffer> CHyprOpenGLImpl::blurFramebufferWithDamage(float a, CRegion* or
|
|||
static auto PBLEND = CConfigValue<Config::INTEGER>("render:use_shader_blur_blend");
|
||||
|
||||
PMIRRORSWAPFB->bind();
|
||||
GLFB(PMIRRORSWAPFB)->clearAfterInvalidation();
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
|
|
@ -1754,6 +1755,7 @@ SP<IFramebuffer> 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
|
||||
|
|
|
|||
|
|
@ -171,4 +171,15 @@ void CGLFramebuffer::invalidate(const std::vector<GLenum>& 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,11 +21,15 @@ namespace Render::GL {
|
|||
GLuint getFBID();
|
||||
void invalidate(const std::vector<GLenum>& 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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue