Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix selection on Intel GPUs #5762

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Fixes
- Dispatcher : Fixed shutdown crashes caused by Python slots connected to the dispatch signals [^1].
- Display : Fixed shutdown crashes caused by Python slots connected to `driverCreatedSignal()` and `imageReceivedSignal()` [^1].
- LightPositionTool : Fixed crash when changing the tool mode with nothing selected [^1].
- ViewportGadget : Fixed selection issues with Intel GPUs (#901, #2788).

API
---
Expand Down
13 changes: 1 addition & 12 deletions src/GafferUI/StandardStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@ void StandardStyle::bind( const Style *currentStyle ) const
return;
}

glEnable( GL_BLEND );
glBlendFuncSeparate( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
glUseProgram( shader()->program() );

Expand Down Expand Up @@ -1130,17 +1129,7 @@ void StandardStyle::renderImage( const Imath::Box2f &box, const IECoreGL::Textur
glPushAttrib( GL_COLOR_BUFFER_BIT );

// As the image is already pre-multiplied we need to change our blend mode.
glEnable( GL_BLEND );
if( !IECoreGL::Selector::currentSelector() )
{
// Some users have reported crashes that were traced back to this call
// when used on the GL_R32UI data type the `IDRender` selection mode
// uses. The `IDRender` buffer would get corrupted with values that
// didn't correspond to actual gadgets.
// Don't change it when rendering the selection pass since
// blending should not be applied to an integer buffer anyways.
glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
}
glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );

glEnable( GL_TEXTURE_2D );
glActiveTexture( GL_TEXTURE0 );
Expand Down
8 changes: 5 additions & 3 deletions src/GafferUI/ViewportGadget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,6 @@ void ViewportGadget::render() const
glClearColor( 0.26f, 0.26f, 0.26f, 0.0f );
glClearDepth( 1.0f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glEnable( GL_BLEND );

// Set up the camera to world matrix in gl_TextureMatrix[0] so that we can
// reference world space positions in shaders
Expand Down Expand Up @@ -1288,13 +1287,16 @@ void ViewportGadget::renderInternal( RenderReason reason, Gadget::Layer filterLa
if( reason != RenderReason::Draw )
{
// We're doing selection so post-processing doesn't matter. Just
// render direct to output buffer.
// render direct to output buffer without blending as that can
// corrupt the selection buffer on some graphics hardware.
glDisable( GL_BLEND );
renderLayerInternal( reason, layer, viewTransform, bound, selector );
continue;
}

// Render to intemediate framebuffer.
// Render to intermediate framebuffer.

glEnable( GL_BLEND );
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, acquireFramebuffer() );
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClear( GL_COLOR_BUFFER_BIT );
Expand Down
Loading