aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2023-01-15 19:12:52 -0300
committerGitHub <noreply@github.com>2023-01-15 23:12:52 +0100
commit065c4e520d1c8d9fc7de2097839976f9934ef8d0 (patch)
tree59dcc13f4828cc8fa06f111c6775300f3b665a5f
parent139a93040741ec78a4ee13035eab1b1b705bdcf8 (diff)
Specify image view usage flags on Vulkan (#4283)1.1.561
* Specify image view usage flags on Vulkan * PR feedback
-rw-r--r--Ryujinx.Graphics.Vulkan/TextureStorage.cs37
-rw-r--r--Ryujinx.Graphics.Vulkan/TextureView.cs11
2 files changed, 28 insertions, 20 deletions
diff --git a/Ryujinx.Graphics.Vulkan/TextureStorage.cs b/Ryujinx.Graphics.Vulkan/TextureStorage.cs
index 28fabb4f..92209997 100644
--- a/Ryujinx.Graphics.Vulkan/TextureStorage.cs
+++ b/Ryujinx.Graphics.Vulkan/TextureStorage.cs
@@ -79,21 +79,7 @@ namespace Ryujinx.Graphics.Vulkan
var sampleCountFlags = ConvertToSampleCountFlags(gd.Capabilities.SupportedSampleCounts, (uint)info.Samples);
- var usage = DefaultUsageFlags;
-
- if (info.Format.IsDepthOrStencil())
- {
- usage |= ImageUsageFlags.DepthStencilAttachmentBit;
- }
- else if (info.Format.IsRtColorCompatible())
- {
- usage |= ImageUsageFlags.ColorAttachmentBit;
- }
-
- if (info.Format.IsImageCompatible())
- {
- usage |= ImageUsageFlags.StorageBit;
- }
+ var usage = GetImageUsageFromFormat(info.Format);
var flags = ImageCreateFlags.CreateMutableFormatBit;
@@ -306,6 +292,27 @@ namespace Ryujinx.Graphics.Vulkan
}
}
+ public static ImageUsageFlags GetImageUsageFromFormat(GAL.Format format)
+ {
+ var usage = DefaultUsageFlags;
+
+ if (format.IsDepthOrStencil())
+ {
+ usage |= ImageUsageFlags.DepthStencilAttachmentBit;
+ }
+ else if (format.IsRtColorCompatible())
+ {
+ usage |= ImageUsageFlags.ColorAttachmentBit;
+ }
+
+ if (format.IsImageCompatible())
+ {
+ usage |= ImageUsageFlags.StorageBit;
+ }
+
+ return usage;
+ }
+
public static SampleCountFlags ConvertToSampleCountFlags(SampleCountFlags supportedSampleCounts, uint samples)
{
if (samples == 0 || samples > (uint)SampleCountFlags.Count64Bit)
diff --git a/Ryujinx.Graphics.Vulkan/TextureView.cs b/Ryujinx.Graphics.Vulkan/TextureView.cs
index a9e1ed36..67f20721 100644
--- a/Ryujinx.Graphics.Vulkan/TextureView.cs
+++ b/Ryujinx.Graphics.Vulkan/TextureView.cs
@@ -54,6 +54,7 @@ namespace Ryujinx.Graphics.Vulkan
gd.Textures.Add(this);
var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format);
+ var usage = TextureStorage.GetImageUsageFromFormat(info.Format);
var levels = (uint)info.Levels;
var layers = (uint)info.GetLayers();
@@ -94,7 +95,7 @@ namespace Ryujinx.Graphics.Vulkan
var subresourceRange = new ImageSubresourceRange(aspectFlags, (uint)firstLevel, levels, (uint)firstLayer, layers);
var subresourceRangeDepth = new ImageSubresourceRange(aspectFlagsDepth, (uint)firstLevel, levels, (uint)firstLayer, layers);
- unsafe Auto<DisposableImageView> CreateImageView(ComponentMapping cm, ImageSubresourceRange sr, ImageViewType viewType, ImageUsageFlags usageFlags = 0)
+ unsafe Auto<DisposableImageView> CreateImageView(ComponentMapping cm, ImageSubresourceRange sr, ImageViewType viewType, ImageUsageFlags usageFlags)
{
var usage = new ImageViewUsageCreateInfo()
{
@@ -110,14 +111,14 @@ namespace Ryujinx.Graphics.Vulkan
Format = format,
Components = cm,
SubresourceRange = sr,
- PNext = usageFlags == 0 ? null : &usage
+ PNext = &usage
};
gd.Api.CreateImageView(device, imageCreateInfo, null, out var imageView).ThrowOnError();
return new Auto<DisposableImageView>(new DisposableImageView(gd.Api, device, imageView), null, storage.GetImage());
}
- _imageView = CreateImageView(componentMapping, subresourceRange, type);
+ _imageView = CreateImageView(componentMapping, subresourceRange, type, ImageUsageFlags.SampledBit);
// Framebuffer attachments and storage images requires a identity component mapping.
var identityComponentMapping = new ComponentMapping(
@@ -126,7 +127,7 @@ namespace Ryujinx.Graphics.Vulkan
ComponentSwizzle.B,
ComponentSwizzle.A);
- _imageViewIdentity = CreateImageView(identityComponentMapping, subresourceRangeDepth, type);
+ _imageViewIdentity = CreateImageView(identityComponentMapping, subresourceRangeDepth, type, usage);
// Framebuffer attachments also require 3D textures to be bound as 2D array.
if (info.Target == Target.Texture3D)
@@ -144,7 +145,7 @@ namespace Ryujinx.Graphics.Vulkan
{
subresourceRange = new ImageSubresourceRange(aspectFlags, (uint)firstLevel, levels, (uint)firstLayer, (uint)info.Depth);
- _imageView2dArray = CreateImageView(identityComponentMapping, subresourceRange, ImageViewType.Type2DArray);
+ _imageView2dArray = CreateImageView(identityComponentMapping, subresourceRange, ImageViewType.Type2DArray, usage);
}
}