From 31ed061beae779b0a750e1344c76a75af8275f91 Mon Sep 17 00:00:00 2001 From: riperiperi Date: Sat, 17 Feb 2024 03:21:37 +0000 Subject: Vulkan: Improve texture barrier usage, timing and batching (#6240) * WIP barrier batch * Add store op to image usage barrier * Dispose the barrier batch * Fix encoding? * Handle read and write on the load op barrier. Load op consumes read accesses but does not add one, as the only other operation that can read is another load. * Simplify null check * Insert barriers on program change in case stale bindings are reintroduced * Not sure how I messed this one up * Improve location of bindings barrier update This is also important for emergency deferred clear * Update src/Ryujinx.Graphics.Vulkan/BarrierBatch.cs Co-authored-by: Mary Guillemard --------- Co-authored-by: Mary Guillemard --- src/Ryujinx.Graphics.Vulkan/FramebufferParams.cs | 48 +++--------------------- 1 file changed, 5 insertions(+), 43 deletions(-) (limited to 'src/Ryujinx.Graphics.Vulkan/FramebufferParams.cs') diff --git a/src/Ryujinx.Graphics.Vulkan/FramebufferParams.cs b/src/Ryujinx.Graphics.Vulkan/FramebufferParams.cs index af22f265..8079e5ff 100644 --- a/src/Ryujinx.Graphics.Vulkan/FramebufferParams.cs +++ b/src/Ryujinx.Graphics.Vulkan/FramebufferParams.cs @@ -243,41 +243,6 @@ namespace Ryujinx.Graphics.Vulkan return new Auto(new DisposableFramebuffer(api, _device, framebuffer), null, _attachments); } - public void UpdateModifications() - { - if (_colors != null) - { - for (int index = 0; index < _colors.Length; index++) - { - _colors[index].Storage.SetModification( - AccessFlags.ColorAttachmentWriteBit, - PipelineStageFlags.ColorAttachmentOutputBit); - } - } - - _depthStencil?.Storage.SetModification( - AccessFlags.DepthStencilAttachmentWriteBit, - PipelineStageFlags.LateFragmentTestsBit); - } - - public void InsertClearBarrier(CommandBufferScoped cbs, int index) - { - _colorsCanonical?[index]?.Storage?.InsertReadToWriteBarrier( - cbs, - AccessFlags.ColorAttachmentWriteBit, - PipelineStageFlags.ColorAttachmentOutputBit, - insideRenderPass: true); - } - - public void InsertClearBarrierDS(CommandBufferScoped cbs) - { - _depthStencil?.Storage?.InsertReadToWriteBarrier( - cbs, - AccessFlags.DepthStencilAttachmentWriteBit, - PipelineStageFlags.LateFragmentTestsBit, - insideRenderPass: true); - } - public TextureView[] GetAttachmentViews() { var result = new TextureView[_attachments.Length]; @@ -297,23 +262,20 @@ namespace Ryujinx.Graphics.Vulkan return new RenderPassCacheKey(_depthStencil, _colorsCanonical); } - public void InsertLoadOpBarriers(CommandBufferScoped cbs) + public void InsertLoadOpBarriers(VulkanRenderer gd, CommandBufferScoped cbs) { if (_colors != null) { foreach (var color in _colors) { // If Clear or DontCare were used, this would need to be write bit. - color.Storage?.InsertWriteToReadBarrier(cbs, AccessFlags.ColorAttachmentReadBit, PipelineStageFlags.ColorAttachmentOutputBit); - color.Storage?.SetModification(AccessFlags.ColorAttachmentWriteBit, PipelineStageFlags.ColorAttachmentOutputBit); + color.Storage?.QueueLoadOpBarrier(cbs, false); } } - if (_depthStencil != null) - { - _depthStencil.Storage?.InsertWriteToReadBarrier(cbs, AccessFlags.DepthStencilAttachmentReadBit, PipelineStageFlags.EarlyFragmentTestsBit); - _depthStencil.Storage?.SetModification(AccessFlags.DepthStencilAttachmentWriteBit, PipelineStageFlags.LateFragmentTestsBit); - } + _depthStencil?.Storage?.QueueLoadOpBarrier(cbs, true); + + gd.Barriers.Flush(cbs.CommandBuffer, false, null); } public (Auto renderPass, Auto framebuffer) GetPassAndFramebuffer( -- cgit v1.2.3