From 7c327fecb3794ee41df6f3b82e8d18e0942ad1b9 Mon Sep 17 00:00:00 2001 From: riperiperi Date: Wed, 3 May 2023 09:42:21 +0100 Subject: [PATCH] Vulkan: Record modifications after changing the framebuffer (#4775) Our Vulkan backend inserts image barriers when a texture is sampled after it is rendered. This is done via a "modification flag" which is set when a render target is unbound (presuming that a texture has finished drawing to it). Imagine the following scenario: - Game sets render target to texture A - Game renders to texture A - (render pass ends) - Game binds texture A to a sampler - Game sets render target to texture B - Renders to texture B using texture A (barrier required) Because of the previous behaviour, the check to add a barrier for sampling a texture actually happens before it is registered as modified, meaning no barrier was added at all. This isn't always the case, but it was definitely causing issues in Xenoblade 2. This doesn't fix any more complicated issues where a texture is repeatedly sampled while it is currently being rendered. Fixes visual glitches at lower resolutions in Xenoblade 2. May fix other cases. --- src/Ryujinx.Graphics.Vulkan/PipelineBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index c54d7980c8..cf31a7f832 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -1015,8 +1015,8 @@ namespace Ryujinx.Graphics.Vulkan private void SetRenderTargetsInternal(ITexture[] colors, ITexture depthStencil, bool filterWriteMasked) { - FramebufferParams?.UpdateModifications(); CreateFramebuffer(colors, depthStencil, filterWriteMasked); + FramebufferParams?.UpdateModifications(); CreateRenderPass(); SignalStateChange(); SignalAttachmentChange();