@@ -1603,7 +1603,7 @@ void RB_RenderSSAO()
16031603
16041604void RB_FXAA ()
16051605{
1606- if ( !r_FXAA.Get () || !gl_fxaaShader )
1606+ if ( !r_FXAA.Get () || !gl_fxaaShader || !glConfig. samplerObjectsAvailable )
16071607 {
16081608 return ;
16091609 }
@@ -1625,11 +1625,42 @@ void RB_FXAA()
16251625 GL_BindToTMU ( 0 , tr.currentRenderImage [backEnd.currentMainFBO ] )
16261626 );
16271627
1628+ // FXAA expects GL_LINEAR for the sampling to work.
1629+ GLuint64 handle = 0 ;
1630+
1631+ if ( glConfig.usingBindlessTextures )
1632+ {
1633+ // Set a handler.
1634+ GLuint texture = tr.currentRenderImage [backEnd.currentMainFBO ]->texnum ;
1635+ handle = glGetTextureSamplerHandleARB ( texture, tr.linearSampler );
1636+ glMakeTextureHandleResidentARB ( handle );
1637+ GLuint program = gl_fxaaShader->GetProgram ()->id ;
1638+ GLint location = glGetUniformLocation ( program, " u_ColorMap_linear" );
1639+ glUniformHandleui64ARB ( location, handle );
1640+ }
1641+ else
1642+ {
1643+ // Bind a sampler.
1644+ glBindSampler ( 0 , tr.linearSampler );
1645+ }
1646+
16281647 // This shader is run last, so let it render to screen.
16291648 R_BindNullFBO ();
16301649
16311650 Tess_InstantScreenSpaceQuad ();
16321651
1652+ // Make sure we didn't break other effects expecting GL_NEAREST.
1653+ if ( glConfig.usingBindlessTextures )
1654+ {
1655+ // Unset the handler.
1656+ glMakeTextureHandleNonResidentARB ( handle );
1657+ }
1658+ else
1659+ {
1660+ // Unbind the sampler.
1661+ glBindSampler ( 0 , 0 );
1662+ }
1663+
16331664 GL_CheckErrors ();
16341665}
16351666
@@ -1697,7 +1728,7 @@ void RB_CameraPostFX() {
16971728 GL_BindToTMU ( 0 , tr.currentRenderImage [backEnd.currentMainFBO ] )
16981729 );
16991730
1700- if ( r_FXAA.Get () && gl_fxaaShader )
1731+ if ( r_FXAA.Get () && gl_fxaaShader && glConfig. samplerObjectsAvailable )
17011732 {
17021733 // Swap main FBOs.
17031734 backEnd.currentMainFBO = 1 - backEnd.currentMainFBO ;
@@ -3848,6 +3879,12 @@ void R_ShutdownBackend()
38483879 glDisableVertexAttribArray ( i );
38493880 }
38503881 glState.vertexAttribsState = 0 ;
3882+
3883+ if ( tr.linearSampler )
3884+ {
3885+ glDeleteSamplers ( 1 , &tr.linearSampler );
3886+ tr.linearSampler = 0 ;
3887+ }
38513888}
38523889
38533890const RenderCommand *EndOfListCommand::ExecuteSelf ( ) const
0 commit comments