From 629e7ffa2ffe045e37b6daace49ed8ecbc4a4059 Mon Sep 17 00:00:00 2001 From: lightningterror <18107717+lightningterror@users.noreply.github.com> Date: Tue, 31 Mar 2026 09:13:42 +0200 Subject: [PATCH] GS/GL: Use memory barrier when texture barrier isn't supported. Only in Force Enabled mode as it's not guaranteed to work, otherwise use multidraw fb copy. Also added nv texture barrier fallback when regular texture barrier isn't supported. --- pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp | 29 ++++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp index cb7f92fe5f..6134d7c71e 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp @@ -43,8 +43,14 @@ namespace ReplaceGL glViewport(GLint(x), GLint(y), GLsizei(w), GLsizei(h)); } + static void GLAPIENTRY MemoryBarrierAsTextureBarrier() + { + glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); + } + static void GLAPIENTRY TextureBarrier() { + } } // namespace ReplaceGL @@ -751,11 +757,17 @@ bool GSDeviceOGL::CheckFeatures() if (!GLAD_GL_ARB_texture_barrier) { - glTextureBarrier = ReplaceGL::TextureBarrier; - // Switch to fallback. - m_features.multidraw_fb_copy = true; - Host::AddOSDMessage( - "GL_ARB_texture_barrier is not supported, blending will be slower.", Host::OSD_ERROR_DURATION); + // First try NV only barrier. + // If that doesn't work then switch to multidraw fb copy. + if (GLAD_GL_NV_texture_barrier) + glTextureBarrier = glTextureBarrierNV; + else + { + glTextureBarrier = ReplaceGL::TextureBarrier; + m_features.multidraw_fb_copy = true; + Host::AddOSDMessage( + "GL_ARB_texture_barrier is not supported, blending will be slower.", Host::OSD_ERROR_DURATION); + } } if (!GLAD_GL_ARB_direct_state_access) @@ -797,11 +809,16 @@ bool GSDeviceOGL::CheckFeatures() } else if (GSConfig.OverrideTextureBarriers == 1) { + // No texture barriers supported so try to use memory barrier. + // Not guaranteed to work so only enable it in Force Enabled mode. + if (!GLAD_GL_ARB_texture_barrier && !GLAD_GL_NV_texture_barrier && GLAD_GL_ARB_shader_image_load_store) + glTextureBarrier = ReplaceGL::MemoryBarrierAsTextureBarrier; + m_features.texture_barrier = true; // Force Enabled m_features.multidraw_fb_copy = false; } else - m_features.texture_barrier = m_features.framebuffer_fetch || GLAD_GL_ARB_texture_barrier; + m_features.texture_barrier = m_features.framebuffer_fetch || GLAD_GL_ARB_texture_barrier || GLAD_GL_NV_texture_barrier; m_features.provoking_vertex_last = true; m_features.dxt_textures = GLAD_GL_EXT_texture_compression_s3tc;