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
This commit is contained in:
Alex Shvartzkop 2024-03-12 08:00:28 +03:00
parent 0f57d76ecd
commit bf6ff5b805
2 changed files with 9 additions and 1 deletions

View File

@ -185,7 +185,11 @@ void ANTIALIASING_SUPERSAMPLING::Present()
glBindTexture( GL_TEXTURE_2D, compositor->GetBufferTexture( ssaaMainBuffer ) ); glBindTexture( GL_TEXTURE_2D, compositor->GetBufferTexture( ssaaMainBuffer ) );
compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING ); compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING );
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE );
draw_fullscreen_primitive(); draw_fullscreen_primitive();
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
} }
@ -547,7 +551,11 @@ void ANTIALIASING_SMAA::Present()
glActiveTexture( GL_TEXTURE1 ); glActiveTexture( GL_TEXTURE1 );
glBindTexture( GL_TEXTURE_2D, blendTex ); glBindTexture( GL_TEXTURE_2D, blendTex );
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE );
pass_3_shader->Use(); pass_3_shader->Use();
draw_fullscreen_triangle(); draw_fullscreen_triangle();
pass_3_shader->Deactivate(); pass_3_shader->Deactivate();
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
} }

View File

@ -297,7 +297,7 @@ void OPENGL_COMPOSITOR::ClearBuffer( const COLOR4D& aColor )
{ {
wxASSERT( m_initialized ); 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 ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
} }