From e3a81cfdee9201add9a1c005cfa38c1aff48a8a9 Mon Sep 17 00:00:00 2001
From: Gabriel A <gab.dark.100@gmail.com>
Date: Mon, 21 Aug 2023 19:39:25 -0300
Subject: [PATCH] Extend Adreno binding workaround to buffer textures

---
 src/Ryujinx.Graphics.Vulkan/ShaderCollection.cs | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/Ryujinx.Graphics.Vulkan/ShaderCollection.cs b/src/Ryujinx.Graphics.Vulkan/ShaderCollection.cs
index 42dc45e0b..783e7113f 100644
--- a/src/Ryujinx.Graphics.Vulkan/ShaderCollection.cs
+++ b/src/Ryujinx.Graphics.Vulkan/ShaderCollection.cs
@@ -117,10 +117,10 @@ namespace Ryujinx.Graphics.Vulkan
 
             Stages = stages;
 
-            bool hasBatchedTextureSamplerBug = gd.Vendor == Vendor.Qualcomm;
+            bool hasBatchedTextureBug = gd.Vendor == Vendor.Qualcomm;
 
             ClearSegments = BuildClearSegments(resourceLayout.Sets);
-            BindingSegments = BuildBindingSegments(resourceLayout.SetUsages, hasBatchedTextureSamplerBug);
+            BindingSegments = BuildBindingSegments(resourceLayout.SetUsages, hasBatchedTextureBug);
             Templates = BuildTemplates();
 
             _compileTask = Task.CompletedTask;
@@ -193,7 +193,7 @@ namespace Ryujinx.Graphics.Vulkan
             return segments;
         }
 
-        private static ResourceBindingSegment[][] BuildBindingSegments(ReadOnlyCollection<ResourceUsageCollection> setUsages, bool hasBatchedTextureSamplerBug)
+        private static ResourceBindingSegment[][] BuildBindingSegments(ReadOnlyCollection<ResourceUsageCollection> setUsages, bool hasBatchedTextureBug)
         {
             ResourceBindingSegment[][] segments = new ResourceBindingSegment[setUsages.Count][];
 
@@ -210,7 +210,7 @@ namespace Ryujinx.Graphics.Vulkan
 
                     if (currentUsage.Binding + currentCount != usage.Binding ||
                         currentUsage.Type != usage.Type ||
-                        (currentUsage.Type == ResourceType.TextureAndSampler && hasBatchedTextureSamplerBug) ||
+                        (IsReadOnlyTexture(currentUsage.Type) && hasBatchedTextureBug) ||
                         currentUsage.Stages != usage.Stages ||
                         currentUsage.Access != usage.Access)
                     {
@@ -264,6 +264,11 @@ namespace Ryujinx.Graphics.Vulkan
             return templates;
         }
 
+        private static bool IsReadOnlyTexture(ResourceType resourceType)
+        {
+            return resourceType == ResourceType.TextureAndSampler || resourceType == ResourceType.BufferTexture;
+        }
+
         private async Task BackgroundCompilation()
         {
             await Task.WhenAll(_shaders.Select(shader => shader.CompileTask));