From 31ed061beae779b0a750e1344c76a75af8275f91 Mon Sep 17 00:00:00 2001
From: riperiperi <rhy3756547@hotmail.com>
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 <thog@protonmail.com>

---------

Co-authored-by: Mary Guillemard <thog@protonmail.com>
---
 .../Multithreading/Commands/SetImageCommand.cs                     | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'src/Ryujinx.Graphics.GAL/Multithreading/Commands/SetImageCommand.cs')

diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/SetImageCommand.cs b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/SetImageCommand.cs
index b4e966ca..243480a8 100644
--- a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/SetImageCommand.cs
+++ b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/SetImageCommand.cs
@@ -1,17 +1,20 @@
 using Ryujinx.Graphics.GAL.Multithreading.Model;
 using Ryujinx.Graphics.GAL.Multithreading.Resources;
+using Ryujinx.Graphics.Shader;
 
 namespace Ryujinx.Graphics.GAL.Multithreading.Commands
 {
     struct SetImageCommand : IGALCommand, IGALCommand<SetImageCommand>
     {
         public readonly CommandType CommandType => CommandType.SetImage;
+        private ShaderStage _stage;
         private int _binding;
         private TableRef<ITexture> _texture;
         private Format _imageFormat;
 
-        public void Set(int binding, TableRef<ITexture> texture, Format imageFormat)
+        public void Set(ShaderStage stage, int binding, TableRef<ITexture> texture, Format imageFormat)
         {
+            _stage = stage;
             _binding = binding;
             _texture = texture;
             _imageFormat = imageFormat;
@@ -19,7 +22,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands
 
         public static void Run(ref SetImageCommand command, ThreadedRenderer threaded, IRenderer renderer)
         {
-            renderer.Pipeline.SetImage(command._binding, command._texture.GetAs<ThreadedTexture>(threaded)?.Base, command._imageFormat);
+            renderer.Pipeline.SetImage(command._stage, command._binding, command._texture.GetAs<ThreadedTexture>(threaded)?.Base, command._imageFormat);
         }
     }
 }
-- 
cgit v1.2.3-70-g09d2