@@ -43,8 +43,14 @@ namespace ReplaceGL
4343 glViewport (GLint (x), GLint (y), GLsizei (w), GLsizei (h));
4444 }
4545
46+ static void GLAPIENTRY MemoryBarrierAsTextureBarrier ()
47+ {
48+ glMemoryBarrier (GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
49+ }
50+
4651 static void GLAPIENTRY TextureBarrier ()
4752 {
53+
4854 }
4955
5056} // namespace ReplaceGL
@@ -751,11 +757,17 @@ bool GSDeviceOGL::CheckFeatures()
751757
752758 if (!GLAD_GL_ARB_texture_barrier)
753759 {
754- glTextureBarrier = ReplaceGL::TextureBarrier;
755- // Switch to fallback.
756- m_features.multidraw_fb_copy = true ;
757- Host::AddOSDMessage (
758- " GL_ARB_texture_barrier is not supported, blending will be slower." , Host::OSD_ERROR_DURATION);
760+ // First try NV only barrier.
761+ // If that doesn't work then switch to multidraw fb copy.
762+ if (GLAD_GL_NV_texture_barrier)
763+ glTextureBarrier = glTextureBarrierNV;
764+ else
765+ {
766+ glTextureBarrier = ReplaceGL::TextureBarrier;
767+ m_features.multidraw_fb_copy = true ;
768+ Host::AddOSDMessage (
769+ " GL_ARB_texture_barrier is not supported, blending will be slower." , Host::OSD_ERROR_DURATION);
770+ }
759771 }
760772
761773 if (!GLAD_GL_ARB_direct_state_access)
@@ -797,11 +809,16 @@ bool GSDeviceOGL::CheckFeatures()
797809 }
798810 else if (GSConfig.OverrideTextureBarriers == 1 )
799811 {
812+ // No texture barriers supported so try to use memory barrier.
813+ // Not guaranteed to work so only enable it in Force Enabled mode.
814+ if (!GLAD_GL_ARB_texture_barrier && !GLAD_GL_NV_texture_barrier && GLAD_GL_ARB_shader_image_load_store)
815+ glTextureBarrier = ReplaceGL::MemoryBarrierAsTextureBarrier;
816+
800817 m_features.texture_barrier = true ; // Force Enabled
801818 m_features.multidraw_fb_copy = false ;
802819 }
803820 else
804- m_features.texture_barrier = m_features.framebuffer_fetch || GLAD_GL_ARB_texture_barrier;
821+ m_features.texture_barrier = m_features.framebuffer_fetch || GLAD_GL_ARB_texture_barrier || GLAD_GL_NV_texture_barrier ;
805822
806823 m_features.provoking_vertex_last = true ;
807824 m_features.dxt_textures = GLAD_GL_EXT_texture_compression_s3tc;
0 commit comments