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/TextureView.cs | 33 ++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'src/Ryujinx.Graphics.Vulkan/TextureView.cs') diff --git a/src/Ryujinx.Graphics.Vulkan/TextureView.cs b/src/Ryujinx.Graphics.Vulkan/TextureView.cs index ef511565..31d13965 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureView.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureView.cs @@ -497,21 +497,17 @@ namespace Ryujinx.Graphics.Vulkan null); } - public static unsafe void InsertImageBarrier( - Vk api, - CommandBuffer commandBuffer, + public static ImageMemoryBarrier GetImageBarrier( Image image, AccessFlags srcAccessMask, AccessFlags dstAccessMask, - PipelineStageFlags srcStageMask, - PipelineStageFlags dstStageMask, ImageAspectFlags aspectFlags, int firstLayer, int firstLevel, int layers, int levels) { - ImageMemoryBarrier memoryBarrier = new() + return new() { SType = StructureType.ImageMemoryBarrier, SrcAccessMask = srcAccessMask, @@ -523,6 +519,31 @@ namespace Ryujinx.Graphics.Vulkan NewLayout = ImageLayout.General, SubresourceRange = new ImageSubresourceRange(aspectFlags, (uint)firstLevel, (uint)levels, (uint)firstLayer, (uint)layers), }; + } + + public static unsafe void InsertImageBarrier( + Vk api, + CommandBuffer commandBuffer, + Image image, + AccessFlags srcAccessMask, + AccessFlags dstAccessMask, + PipelineStageFlags srcStageMask, + PipelineStageFlags dstStageMask, + ImageAspectFlags aspectFlags, + int firstLayer, + int firstLevel, + int layers, + int levels) + { + ImageMemoryBarrier memoryBarrier = GetImageBarrier( + image, + srcAccessMask, + dstAccessMask, + aspectFlags, + firstLayer, + firstLevel, + layers, + levels); api.CmdPipelineBarrier( commandBuffer, -- cgit v1.2.3