ソースを参照

Vulkan: Use aspect flags for identity views for bindings (#5267)

riperiperi 2 年 前
コミット
0003a7c118
1 ファイル変更9 行追加2 行削除
  1. 9 2
      src/Ryujinx.Graphics.Vulkan/TextureView.cs

+ 9 - 2
src/Ryujinx.Graphics.Vulkan/TextureView.cs

@@ -15,6 +15,7 @@ namespace Ryujinx.Graphics.Vulkan
         private readonly Device _device;
         private readonly Device _device;
 
 
         private readonly Auto<DisposableImageView> _imageView;
         private readonly Auto<DisposableImageView> _imageView;
+        private readonly Auto<DisposableImageView> _imageViewDraw;
         private readonly Auto<DisposableImageView> _imageViewIdentity;
         private readonly Auto<DisposableImageView> _imageViewIdentity;
         private readonly Auto<DisposableImageView> _imageView2dArray;
         private readonly Auto<DisposableImageView> _imageView2dArray;
         private Dictionary<GAL.Format, TextureView> _selfManagedViews;
         private Dictionary<GAL.Format, TextureView> _selfManagedViews;
@@ -127,7 +128,8 @@ namespace Ryujinx.Graphics.Vulkan
                 ComponentSwizzle.B,
                 ComponentSwizzle.B,
                 ComponentSwizzle.A);
                 ComponentSwizzle.A);
 
 
-            _imageViewIdentity = CreateImageView(identityComponentMapping, subresourceRangeDepth, type, usage);
+            _imageViewDraw = CreateImageView(identityComponentMapping, subresourceRangeDepth, type, usage);
+            _imageViewIdentity = aspectFlagsDepth == aspectFlags ? _imageViewDraw : CreateImageView(identityComponentMapping, subresourceRange, type, usage);
 
 
             // Framebuffer attachments also require 3D textures to be bound as 2D array.
             // Framebuffer attachments also require 3D textures to be bound as 2D array.
             if (info.Target == Target.Texture3D)
             if (info.Target == Target.Texture3D)
@@ -169,7 +171,7 @@ namespace Ryujinx.Graphics.Vulkan
 
 
         public Auto<DisposableImageView> GetImageViewForAttachment()
         public Auto<DisposableImageView> GetImageViewForAttachment()
         {
         {
-            return _imageView2dArray ?? _imageViewIdentity;
+            return _imageView2dArray ?? _imageViewDraw;
         }
         }
 
 
         public void CopyTo(ITexture destination, int firstLayer, int firstLevel)
         public void CopyTo(ITexture destination, int firstLayer, int firstLevel)
@@ -909,6 +911,11 @@ namespace Ryujinx.Graphics.Vulkan
                     _imageViewIdentity.Dispose();
                     _imageViewIdentity.Dispose();
                     _imageView2dArray?.Dispose();
                     _imageView2dArray?.Dispose();
 
 
+                    if (_imageViewDraw != _imageViewIdentity)
+                    {
+                        _imageViewDraw.Dispose();
+                    }
+
                     Storage.DecrementViewsCount();
                     Storage.DecrementViewsCount();
                 }
                 }
             }
             }