diff --git a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm index 758e6889f4..b8e0318378 100644 --- a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm +++ b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm @@ -2114,7 +2114,7 @@ void GSDeviceMTL::MREInitHWDraw(GSHWDrawConfig& config, const Map& verts) void GSDeviceMTL::RenderHW(GSHWDrawConfig& config) { @autoreleasepool { - if (config.tex && config.ds == config.tex) + if (config.tex && (config.ds == config.tex || config.rt == config.tex)) EndRenderPass(); // Barrier size_t vertsize = config.nverts * sizeof(*config.verts); diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp index b485149ac9..8ae9200c95 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp @@ -2496,12 +2496,6 @@ void GSDeviceOGL::RenderHW(GSHWDrawConfig& config) config.drawarea.width(), config.drawarea.height()); CopyRect(hdr_rt ? hdr_rt : config.rt, draw_rt_clone, config.drawarea, config.drawarea.left, config.drawarea.top); } - else if (config.tex && config.tex == config.ds) - { - // Ensure all depth writes are finished before sampling - GL_INS("Texture barrier to flush depth before reading"); - glTextureBarrier(); - } IASetVertexBuffer(config.verts, config.nverts); if (config.vs.expand != GSHWDrawConfig::VSExpand::None && !GLAD_GL_ARB_shader_draw_parameters) @@ -2563,6 +2557,15 @@ void GSDeviceOGL::RenderHW(GSHWDrawConfig& config) SetupPipeline(psel); + const bool check_barrier = !(config.require_one_barrier && !m_features.texture_barrier); + + // Be careful of the rt already being bound and the blend using the RT without a barrier. + if (check_barrier && ((config.tex && (config.tex == config.ds || config.tex == config.rt)) || ((psel.ps.IsFeedbackLoop() || psel.ps.blend_c == 1) && GLState::rt == config.rt))) + { + // Ensure all depth writes are finished before sampling + GL_INS("Texture barrier to flush depth or rt before reading"); + glTextureBarrier(); + } // additional non-pipeline config stuff const bool point_size_enabled = config.vs.point_size; if (GLState::point_size != point_size_enabled) diff --git a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp index 086779191b..d82df886f6 100644 --- a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp +++ b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp @@ -5641,6 +5641,10 @@ void GSDeviceVK::RenderHW(GSHWDrawConfig& config) PipelineSelector& pipe = m_pipeline_selector; UpdateHWPipelineSelector(config, pipe); + // If we don't have a barrier but the texture was drawn to last draw, end the pass to insert a barrier. + if (InRenderPass() && !pipe.IsRTFeedbackLoop() && (config.tex == m_current_render_target || config.tex == m_current_depth_target)) + EndRenderPass(); + // now blit the hdr texture back to the original target if (hdr_rt) {