From bf6ff5b80529cb9a063bdefbadbc5e0f805e65f8 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Tue, 12 Mar 2024 08:00:28 +0300 Subject: [PATCH] Do not write alpha to the main framebuffer when performing antialiasing. This allows correct background display when the main framebuffer has alpha. Noticeable on Wayland with Mesa 24.0.2 Iris driver. Fixes https://gitlab.com/kicad/code/kicad/-/issues/17341 --- common/gal/opengl/antialiasing.cpp | 8 ++++++++ common/gal/opengl/opengl_compositor.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/common/gal/opengl/antialiasing.cpp b/common/gal/opengl/antialiasing.cpp index 049ac70b86..f0b3821a5c 100644 --- a/common/gal/opengl/antialiasing.cpp +++ b/common/gal/opengl/antialiasing.cpp @@ -185,7 +185,11 @@ void ANTIALIASING_SUPERSAMPLING::Present() glBindTexture( GL_TEXTURE_2D, compositor->GetBufferTexture( ssaaMainBuffer ) ); compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING ); + glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE ); + draw_fullscreen_primitive(); + + glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); } @@ -547,7 +551,11 @@ void ANTIALIASING_SMAA::Present() glActiveTexture( GL_TEXTURE1 ); glBindTexture( GL_TEXTURE_2D, blendTex ); + glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE ); + pass_3_shader->Use(); draw_fullscreen_triangle(); pass_3_shader->Deactivate(); + + glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); } diff --git a/common/gal/opengl/opengl_compositor.cpp b/common/gal/opengl/opengl_compositor.cpp index ef6663e532..3db5168ccc 100644 --- a/common/gal/opengl/opengl_compositor.cpp +++ b/common/gal/opengl/opengl_compositor.cpp @@ -297,7 +297,7 @@ void OPENGL_COMPOSITOR::ClearBuffer( const COLOR4D& aColor ) { wxASSERT( m_initialized ); - glClearColor( aColor.r, aColor.g, aColor.b, 0.0f ); + glClearColor( aColor.r, aColor.g, aColor.b, m_curFbo == DIRECT_RENDERING ? 1.0f : 0.0f ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); }