Skip to content

Commit 24fe6b1

Browse files
committed
fixup: make it working with bindless textures
1 parent 24a5f26 commit 24fe6b1

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

src/engine/renderer/glsl_source/fxaa_fp.glsl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4646

4747
#insert fxaa3_11_fp
4848

49+
#if defined(HAVE_ARB_bindless_texture)
50+
uniform sampler2D u_ColorMap_linear;
51+
#define u_ColorMap u_ColorMap_linear
52+
#else
4953
uniform sampler2D u_ColorMap;
54+
#endif
5055

5156
#if __VERSION__ > 120
5257
out vec4 outputColor;

src/engine/renderer/tr_backend.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,15 +1627,31 @@ void RB_FXAA()
16271627

16281628
bool greaterThanGL33 = std::make_pair( glConfig.glMajor, glConfig.glMinor ) >= std::make_pair( 3, 3 );
16291629

1630+
GLuint64 handle = 0;
1631+
16301632
// FXAA expect GL_LINEAR for the sampling to work.
16311633
if ( greaterThanGL33 )
16321634
{
1633-
// Bind a sampler.
16341635
GLuint sampler = 0;
16351636
glGenSamplers( 1, &sampler );
16361637
glSamplerParameteri( sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR) ;
16371638
glSamplerParameteri( sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1638-
glBindSampler( 0, sampler );
1639+
1640+
if ( glConfig.usingBindlessTextures )
1641+
{
1642+
// Set a handler.
1643+
GLuint texture = tr.currentRenderImage[backEnd.currentMainFBO]->texnum;
1644+
handle = glGetTextureSamplerHandleARB( texture, sampler );
1645+
glMakeTextureHandleResidentARB( handle );
1646+
GLuint program = gl_fxaaShader->GetProgram()->id;
1647+
GLint location = glGetUniformLocation( program, "u_ColorMap_linear" );
1648+
glUniformHandleui64ARB( location, handle );
1649+
}
1650+
else
1651+
{
1652+
// Bind a sampler.
1653+
glBindSampler( 0, sampler );
1654+
}
16391655
}
16401656
else
16411657
{
@@ -1652,8 +1668,16 @@ void RB_FXAA()
16521668
// Make sure we didn't break other effects expecting GL_NEAREST.
16531669
if ( greaterThanGL33 )
16541670
{
1655-
// Unbind the sampler.
1656-
glBindSampler( 0, 0 );
1671+
if ( glConfig.usingBindlessTextures )
1672+
{
1673+
// Unset the handler.
1674+
glMakeTextureHandleNonResidentARB( handle );
1675+
}
1676+
else
1677+
{
1678+
// Unbind the sampler.
1679+
glBindSampler( 0, 0 );
1680+
}
16571681
}
16581682
else
16591683
{

0 commit comments

Comments
 (0)