Skip to content

Commit

Permalink
Merge pull request #5762 from murraystevenson/intelGraphicsFix
Browse files Browse the repository at this point in the history
Fix selection on Intel GPUs
  • Loading branch information
johnhaddon authored Apr 3, 2024
2 parents b938d6a + 43a9595 commit d6f70d0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,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

0 comments on commit d6f70d0

Please sign in to comment.