diff options
Diffstat (limited to 'src/Ryujinx.Graphics.Vulkan/TextureView.cs')
-rw-r--r-- | src/Ryujinx.Graphics.Vulkan/TextureView.cs | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/src/Ryujinx.Graphics.Vulkan/TextureView.cs b/src/Ryujinx.Graphics.Vulkan/TextureView.cs index eb094b3e..6151d5a9 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureView.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureView.cs @@ -3,6 +3,7 @@ using Ryujinx.Graphics.GAL; using Silk.NET.Vulkan; using System; using System.Collections.Generic; +using Format = Ryujinx.Graphics.GAL.Format; using VkBuffer = Silk.NET.Vulkan.Buffer; using VkFormat = Silk.NET.Vulkan.Format; @@ -18,9 +19,9 @@ namespace Ryujinx.Graphics.Vulkan private readonly Auto<DisposableImageView> _imageViewDraw; private readonly Auto<DisposableImageView> _imageViewIdentity; private readonly Auto<DisposableImageView> _imageView2dArray; - private Dictionary<GAL.Format, TextureView> _selfManagedViews; + private Dictionary<Format, TextureView> _selfManagedViews; - private TextureCreateInfo _info; + private readonly TextureCreateInfo _info; public TextureCreateInfo Info => _info; @@ -68,16 +69,13 @@ namespace Ryujinx.Graphics.Vulkan var swizzleB = info.SwizzleB.Convert(); var swizzleA = info.SwizzleA.Convert(); - if (info.Format == GAL.Format.R5G5B5A1Unorm || - info.Format == GAL.Format.R5G5B5X1Unorm || - info.Format == GAL.Format.R5G6B5Unorm) + if (info.Format == Format.R5G5B5A1Unorm || + info.Format == Format.R5G5B5X1Unorm || + info.Format == Format.R5G6B5Unorm) { - var temp = swizzleR; - - swizzleR = swizzleB; - swizzleB = temp; + (swizzleB, swizzleR) = (swizzleR, swizzleB); } - else if (VkFormat == VkFormat.R4G4B4A4UnormPack16 || info.Format == GAL.Format.A1B5G5R5Unorm) + else if (VkFormat == VkFormat.R4G4B4A4UnormPack16 || info.Format == Format.A1B5G5R5Unorm) { var tempB = swizzleB; var tempA = swizzleA; @@ -98,13 +96,13 @@ namespace Ryujinx.Graphics.Vulkan unsafe Auto<DisposableImageView> CreateImageView(ComponentMapping cm, ImageSubresourceRange sr, ImageViewType viewType, ImageUsageFlags usageFlags) { - var usage = new ImageViewUsageCreateInfo() + var usage = new ImageViewUsageCreateInfo { SType = StructureType.ImageViewUsageCreateInfo, - Usage = usageFlags + Usage = usageFlags, }; - var imageCreateInfo = new ImageViewCreateInfo() + var imageCreateInfo = new ImageViewCreateInfo { SType = StructureType.ImageViewCreateInfo, Image = storage.GetImageForViewCreation(), @@ -112,7 +110,7 @@ namespace Ryujinx.Graphics.Vulkan Format = format, Components = cm, SubresourceRange = sr, - PNext = &usage + PNext = &usage, }; gd.Api.CreateImageView(device, imageCreateInfo, null, out var imageView).ThrowOnError(); @@ -354,8 +352,9 @@ namespace Ryujinx.Graphics.Vulkan return; } - else if (_gd.FormatCapabilities.OptimalFormatSupports(FormatFeatureFlags.BlitSrcBit, srcFormat) && - _gd.FormatCapabilities.OptimalFormatSupports(FormatFeatureFlags.BlitDstBit, dstFormat)) + + if (_gd.FormatCapabilities.OptimalFormatSupports(FormatFeatureFlags.BlitSrcBit, srcFormat) && + _gd.FormatCapabilities.OptimalFormatSupports(FormatFeatureFlags.BlitDstBit, dstFormat)) { TextureCopy.Blit( _gd.Api, @@ -444,7 +443,7 @@ namespace Ryujinx.Graphics.Vulkan int layers, int levels) { - ImageMemoryBarrier memoryBarrier = new ImageMemoryBarrier() + ImageMemoryBarrier memoryBarrier = new() { SType = StructureType.ImageMemoryBarrier, SrcAccessMask = srcAccessMask, @@ -454,7 +453,7 @@ namespace Ryujinx.Graphics.Vulkan Image = image, OldLayout = ImageLayout.General, NewLayout = ImageLayout.General, - SubresourceRange = new ImageSubresourceRange(aspectFlags, (uint)firstLevel, (uint)levels, (uint)firstLayer, (uint)layers) + SubresourceRange = new ImageSubresourceRange(aspectFlags, (uint)firstLevel, (uint)levels, (uint)firstLayer, (uint)layers), }; api.CmdPipelineBarrier( @@ -470,7 +469,7 @@ namespace Ryujinx.Graphics.Vulkan memoryBarrier); } - public TextureView GetView(GAL.Format format) + public TextureView GetView(Format format) { if (format == Info.Format) { @@ -499,7 +498,7 @@ namespace Ryujinx.Graphics.Vulkan Info.SwizzleB, Info.SwizzleA), 0, 0); - (_selfManagedViews ??= new Dictionary<GAL.Format, TextureView>()).Add(format, view); + (_selfManagedViews ??= new Dictionary<Format, TextureView>()).Add(format, view); return view; } @@ -543,10 +542,8 @@ namespace Ryujinx.Graphics.Vulkan return PinnedSpan<byte>.UnsafeFromSpan(GetData(_gd.CommandBufferPool, resources.GetFlushBuffer())); } - else - { - return PinnedSpan<byte>.UnsafeFromSpan(GetData(resources.GetPool(), resources.GetFlushBuffer())); - } + + return PinnedSpan<byte>.UnsafeFromSpan(GetData(resources.GetPool(), resources.GetFlushBuffer())); } public PinnedSpan<byte> GetData(int layer, int level) @@ -559,10 +556,8 @@ namespace Ryujinx.Graphics.Vulkan return PinnedSpan<byte>.UnsafeFromSpan(GetData(_gd.CommandBufferPool, resources.GetFlushBuffer(), layer, level)); } - else - { - return PinnedSpan<byte>.UnsafeFromSpan(GetData(resources.GetPool(), resources.GetFlushBuffer(), layer, level)); - } + + return PinnedSpan<byte>.UnsafeFromSpan(GetData(resources.GetPool(), resources.GetFlushBuffer(), layer, level)); } public void CopyTo(BufferRange range, int layer, int level, int stride) @@ -686,11 +681,11 @@ namespace Ryujinx.Graphics.Vulkan return length; } - private GAL.Format GetCompatibleGalFormat(GAL.Format format) + private Format GetCompatibleGalFormat(Format format) { if (NeedsD24S8Conversion()) { - return GAL.Format.D32FloatS8Uint; + return Format.D32FloatS8Uint; } return format; |