From 8bf715379496be5da24ca90985e8e5fe09dc244d Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Wed, 17 Jul 2024 23:26:52 -0700 Subject: [PATCH 1/7] This should allow resolution of pending validation error by creating an image with extended usage flags, but narrowed usage for image views. --- src/Ryujinx.Graphics.Vulkan/TextureStorage.cs | 6 +++--- src/Ryujinx.Graphics.Vulkan/TextureView.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs b/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs index f36db68de3..fb7928f9af 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs @@ -80,7 +80,7 @@ namespace Ryujinx.Graphics.Vulkan var sampleCountFlags = ConvertToSampleCountFlags(gd.Capabilities.SupportedSampleCounts, (uint)info.Samples); - var usage = GetImageUsage(info.Format, info.Target, gd.Capabilities.SupportsShaderStorageImageMultisample); + var usage = GetImageUsage(info.Format, info.Target, gd.Capabilities.SupportsShaderStorageImageMultisample, true); var flags = ImageCreateFlags.CreateMutableFormatBit | ImageCreateFlags.CreateExtendedUsageBit; @@ -292,7 +292,7 @@ namespace Ryujinx.Graphics.Vulkan } } - public static ImageUsageFlags GetImageUsage(Format format, Target target, bool supportsMsStorage) + public static ImageUsageFlags GetImageUsage(Format format, Target target, bool supportsMsStorage, bool extendedUsage) { var usage = DefaultUsageFlags; @@ -305,7 +305,7 @@ namespace Ryujinx.Graphics.Vulkan usage |= ImageUsageFlags.ColorAttachmentBit; } - if (format.IsImageCompatible() && (supportsMsStorage || !target.IsMultisample())) + if ((format.IsImageCompatible() && (supportsMsStorage || !target.IsMultisample())) || extendedUsage) { usage |= ImageUsageFlags.StorageBit; } diff --git a/src/Ryujinx.Graphics.Vulkan/TextureView.cs b/src/Ryujinx.Graphics.Vulkan/TextureView.cs index eb612da796..084f984bdf 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureView.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureView.cs @@ -60,7 +60,7 @@ namespace Ryujinx.Graphics.Vulkan gd.Textures.Add(this); var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format); - var usage = TextureStorage.GetImageUsage(info.Format, info.Target, gd.Capabilities.SupportsShaderStorageImageMultisample); + var usage = TextureStorage.GetImageUsage(info.Format, info.Target, gd.Capabilities.SupportsShaderStorageImageMultisample, false); var levels = (uint)info.Levels; var layers = (uint)info.GetLayers(); From 87105b0ad133859abb970f8b2d5cee17469a398d Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Sat, 20 Jul 2024 18:00:33 -0700 Subject: [PATCH 2/7] Request Storage image bit feature flag only if its required --- .../FormatCapabilities.cs | 4 ++-- .../PipelineConverter.cs | 19 +++++++++++++++---- src/Ryujinx.Graphics.Vulkan/TextureStorage.cs | 4 +++- src/Ryujinx.Graphics.Vulkan/TextureView.cs | 4 +++- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs index 9ea8cec4be..6ddc217c1f 100644 --- a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs +++ b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs @@ -148,7 +148,7 @@ namespace Ryujinx.Graphics.Vulkan return (formatFeatureFlags & flags) == flags; } - public VkFormat ConvertToVkFormat(Format srcFormat) + public VkFormat ConvertToVkFormat(Format srcFormat, bool required) { var format = FormatTable.GetFormat(srcFormat); @@ -165,7 +165,7 @@ namespace Ryujinx.Graphics.Vulkan requiredFeatures |= FormatFeatureFlags.ColorAttachmentBit; } - if (srcFormat.IsImageCompatible()) + if (srcFormat.IsImageCompatible() && required) { requiredFeatures |= FormatFeatureFlags.StorageImageBit; } diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs b/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs index 89ce10b0aa..3ed56381d0 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs @@ -29,11 +29,17 @@ namespace Ryujinx.Graphics.Vulkan int colorCount = 0; int maxColorAttachmentIndex = -1; + bool supported = gd.Capabilities.SupportsShaderStorageImageMultisample || + !state.DepthStencilFormat.IsImageCompatible(); + for (int i = 0; i < state.AttachmentEnable.Length; i++) { if (state.AttachmentEnable[i]) { - attachmentFormats[attachmentCount] = gd.FormatCapabilities.ConvertToVkFormat(state.AttachmentFormats[i]); + bool supportedAttachment = gd.Capabilities.SupportsShaderStorageImageMultisample || + !state.AttachmentFormats[i].IsImageCompatible(); + + attachmentFormats[attachmentCount] = gd.FormatCapabilities.ConvertToVkFormat(state.AttachmentFormats[i], supportedAttachment); attachmentIndices[attachmentCount++] = i; colorCount++; @@ -43,7 +49,7 @@ namespace Ryujinx.Graphics.Vulkan if (state.DepthStencilEnable) { - attachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.DepthStencilFormat); + attachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.DepthStencilFormat, supported); } if (attachmentCount != 0) @@ -296,7 +302,9 @@ namespace Ryujinx.Graphics.Vulkan { if (state.AttachmentEnable[i]) { - pipeline.Internal.AttachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.AttachmentFormats[i]); + bool supportedAttachment = gd.Capabilities.SupportsShaderStorageImageMultisample || + !state.AttachmentFormats[i].IsImageCompatible(); + pipeline.Internal.AttachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.AttachmentFormats[i], supportedAttachment); maxColorAttachmentIndex = i; if (state.AttachmentFormats[i].IsInteger()) @@ -310,7 +318,10 @@ namespace Ryujinx.Graphics.Vulkan if (state.DepthStencilEnable) { - pipeline.Internal.AttachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.DepthStencilFormat); + bool supported = !state.DepthStencilFormat.IsImageCompatible() || + gd.Capabilities.SupportsShaderStorageImageMultisample; + + pipeline.Internal.AttachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.DepthStencilFormat, supported); } pipeline.ColorBlendAttachmentStateCount = (uint)(maxColorAttachmentIndex + 1); diff --git a/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs b/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs index fb7928f9af..9998a4018a 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs @@ -67,7 +67,9 @@ namespace Ryujinx.Graphics.Vulkan _device = device; _info = info; - var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format); + bool multisample = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); + + var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, multisample); var levels = (uint)info.Levels; var layers = (uint)info.GetLayers(); var depth = (uint)(info.Target == Target.Texture3D ? info.Depth : 1); diff --git a/src/Ryujinx.Graphics.Vulkan/TextureView.cs b/src/Ryujinx.Graphics.Vulkan/TextureView.cs index 084f984bdf..e12d064126 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureView.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureView.cs @@ -59,7 +59,9 @@ namespace Ryujinx.Graphics.Vulkan gd.Textures.Add(this); - var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format); + bool multisample = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); + + var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, multisample); var usage = TextureStorage.GetImageUsage(info.Format, info.Target, gd.Capabilities.SupportsShaderStorageImageMultisample, false); var levels = (uint)info.Levels; var layers = (uint)info.GetLayers(); From 36294a60b3929fd1dbd237c82bce987347263a3e Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Sun, 21 Jul 2024 18:33:09 -0700 Subject: [PATCH 3/7] Renamed some variables for code review --- .../FormatCapabilities.cs | 4 +-- .../PipelineConverter.cs | 25 ++++++++++--------- src/Ryujinx.Graphics.Vulkan/TextureStorage.cs | 10 ++++---- src/Ryujinx.Graphics.Vulkan/TextureView.cs | 6 ++--- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs index 6ddc217c1f..d4da4326f2 100644 --- a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs +++ b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs @@ -148,7 +148,7 @@ namespace Ryujinx.Graphics.Vulkan return (formatFeatureFlags & flags) == flags; } - public VkFormat ConvertToVkFormat(Format srcFormat, bool required) + public VkFormat ConvertToVkFormat(Format srcFormat, bool storageFeatureFlagRequired) { var format = FormatTable.GetFormat(srcFormat); @@ -165,7 +165,7 @@ namespace Ryujinx.Graphics.Vulkan requiredFeatures |= FormatFeatureFlags.ColorAttachmentBit; } - if (srcFormat.IsImageCompatible() && required) + if (srcFormat.IsImageCompatible() && storageFeatureFlagRequired) { requiredFeatures |= FormatFeatureFlags.StorageImageBit; } diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs b/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs index 3ed56381d0..89df38fde1 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs @@ -29,17 +29,17 @@ namespace Ryujinx.Graphics.Vulkan int colorCount = 0; int maxColorAttachmentIndex = -1; - bool supported = gd.Capabilities.SupportsShaderStorageImageMultisample || - !state.DepthStencilFormat.IsImageCompatible(); + bool supportsIsNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || + !state.DepthStencilFormat.IsImageCompatible(); for (int i = 0; i < state.AttachmentEnable.Length; i++) { if (state.AttachmentEnable[i]) { - bool supportedAttachment = gd.Capabilities.SupportsShaderStorageImageMultisample || - !state.AttachmentFormats[i].IsImageCompatible(); + bool supportsIsNotMsOrSupportsStorageAttachments = gd.Capabilities.SupportsShaderStorageImageMultisample || + !state.AttachmentFormats[i].IsImageCompatible(); - attachmentFormats[attachmentCount] = gd.FormatCapabilities.ConvertToVkFormat(state.AttachmentFormats[i], supportedAttachment); + attachmentFormats[attachmentCount] = gd.FormatCapabilities.ConvertToVkFormat(state.AttachmentFormats[i], supportsIsNotMsOrSupportsStorageAttachments); attachmentIndices[attachmentCount++] = i; colorCount++; @@ -49,7 +49,7 @@ namespace Ryujinx.Graphics.Vulkan if (state.DepthStencilEnable) { - attachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.DepthStencilFormat, supported); + attachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.DepthStencilFormat, supportsIsNotMsOrSupportsStorage); } if (attachmentCount != 0) @@ -302,9 +302,10 @@ namespace Ryujinx.Graphics.Vulkan { if (state.AttachmentEnable[i]) { - bool supportedAttachment = gd.Capabilities.SupportsShaderStorageImageMultisample || - !state.AttachmentFormats[i].IsImageCompatible(); - pipeline.Internal.AttachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.AttachmentFormats[i], supportedAttachment); + bool supportsIsNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || + !state.AttachmentFormats[i].IsImageCompatible(); + + pipeline.Internal.AttachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.AttachmentFormats[i], supportsIsNotMsOrSupportsStorage); maxColorAttachmentIndex = i; if (state.AttachmentFormats[i].IsInteger()) @@ -318,10 +319,10 @@ namespace Ryujinx.Graphics.Vulkan if (state.DepthStencilEnable) { - bool supported = !state.DepthStencilFormat.IsImageCompatible() || - gd.Capabilities.SupportsShaderStorageImageMultisample; + bool supportsIsNotMsOrSupportsStorage = !state.DepthStencilFormat.IsImageCompatible() || + gd.Capabilities.SupportsShaderStorageImageMultisample; - pipeline.Internal.AttachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.DepthStencilFormat, supported); + pipeline.Internal.AttachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.DepthStencilFormat, supportsIsNotMsOrSupportsStorage); } pipeline.ColorBlendAttachmentStateCount = (uint)(maxColorAttachmentIndex + 1); diff --git a/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs b/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs index 9998a4018a..f78075b658 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs @@ -67,9 +67,9 @@ namespace Ryujinx.Graphics.Vulkan _device = device; _info = info; - bool multisample = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); + bool supportsIsNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); - var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, multisample); + var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, supportsIsNotMsOrSupportsStorage); var levels = (uint)info.Levels; var layers = (uint)info.GetLayers(); var depth = (uint)(info.Target == Target.Texture3D ? info.Depth : 1); @@ -82,7 +82,7 @@ namespace Ryujinx.Graphics.Vulkan var sampleCountFlags = ConvertToSampleCountFlags(gd.Capabilities.SupportedSampleCounts, (uint)info.Samples); - var usage = GetImageUsage(info.Format, info.Target, gd.Capabilities.SupportsShaderStorageImageMultisample, true); + var usage = GetImageUsage(info.Format, supportsIsNotMsOrSupportsStorage, true); var flags = ImageCreateFlags.CreateMutableFormatBit | ImageCreateFlags.CreateExtendedUsageBit; @@ -294,7 +294,7 @@ namespace Ryujinx.Graphics.Vulkan } } - public static ImageUsageFlags GetImageUsage(Format format, Target target, bool supportsMsStorage, bool extendedUsage) + public static ImageUsageFlags GetImageUsage(Format format, bool supportsIsNotMsOrSupportsStorage, bool extendedUsage) { var usage = DefaultUsageFlags; @@ -307,7 +307,7 @@ namespace Ryujinx.Graphics.Vulkan usage |= ImageUsageFlags.ColorAttachmentBit; } - if ((format.IsImageCompatible() && (supportsMsStorage || !target.IsMultisample())) || extendedUsage) + if ((format.IsImageCompatible() && supportsIsNotMsOrSupportsStorage) || extendedUsage) { usage |= ImageUsageFlags.StorageBit; } diff --git a/src/Ryujinx.Graphics.Vulkan/TextureView.cs b/src/Ryujinx.Graphics.Vulkan/TextureView.cs index e12d064126..75dc321ddb 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureView.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureView.cs @@ -59,10 +59,10 @@ namespace Ryujinx.Graphics.Vulkan gd.Textures.Add(this); - bool multisample = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); + bool supportsIsNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); - var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, multisample); - var usage = TextureStorage.GetImageUsage(info.Format, info.Target, gd.Capabilities.SupportsShaderStorageImageMultisample, false); + var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, supportsIsNotMsOrSupportsStorage); + var usage = TextureStorage.GetImageUsage(info.Format, supportsIsNotMsOrSupportsStorage, false); var levels = (uint)info.Levels; var layers = (uint)info.GetLayers(); From bc757307d25e151700ccaa186190d96e0b0784f5 Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Sun, 21 Jul 2024 18:36:18 -0700 Subject: [PATCH 4/7] Resolve whitespace --- src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs b/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs index 89df38fde1..77fb6ce27b 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs @@ -302,9 +302,9 @@ namespace Ryujinx.Graphics.Vulkan { if (state.AttachmentEnable[i]) { - bool supportsIsNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || + bool supportsIsNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || !state.AttachmentFormats[i].IsImageCompatible(); - + pipeline.Internal.AttachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.AttachmentFormats[i], supportsIsNotMsOrSupportsStorage); maxColorAttachmentIndex = i; From 53565831e8f9d10b0c37bdc08ff499b1734895ca Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Mon, 22 Jul 2024 18:14:10 -0700 Subject: [PATCH 5/7] Renamed variable to be more descriptive --- src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs | 16 ++++++++-------- src/Ryujinx.Graphics.Vulkan/TextureStorage.cs | 10 +++++----- src/Ryujinx.Graphics.Vulkan/TextureView.cs | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs b/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs index 77fb6ce27b..66f83eb80c 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineConverter.cs @@ -29,17 +29,17 @@ namespace Ryujinx.Graphics.Vulkan int colorCount = 0; int maxColorAttachmentIndex = -1; - bool supportsIsNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || + bool isNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || !state.DepthStencilFormat.IsImageCompatible(); for (int i = 0; i < state.AttachmentEnable.Length; i++) { if (state.AttachmentEnable[i]) { - bool supportsIsNotMsOrSupportsStorageAttachments = gd.Capabilities.SupportsShaderStorageImageMultisample || + bool isNotMsOrSupportsStorageAttachments = gd.Capabilities.SupportsShaderStorageImageMultisample || !state.AttachmentFormats[i].IsImageCompatible(); - attachmentFormats[attachmentCount] = gd.FormatCapabilities.ConvertToVkFormat(state.AttachmentFormats[i], supportsIsNotMsOrSupportsStorageAttachments); + attachmentFormats[attachmentCount] = gd.FormatCapabilities.ConvertToVkFormat(state.AttachmentFormats[i], isNotMsOrSupportsStorageAttachments); attachmentIndices[attachmentCount++] = i; colorCount++; @@ -49,7 +49,7 @@ namespace Ryujinx.Graphics.Vulkan if (state.DepthStencilEnable) { - attachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.DepthStencilFormat, supportsIsNotMsOrSupportsStorage); + attachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.DepthStencilFormat, isNotMsOrSupportsStorage); } if (attachmentCount != 0) @@ -302,10 +302,10 @@ namespace Ryujinx.Graphics.Vulkan { if (state.AttachmentEnable[i]) { - bool supportsIsNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || + bool isNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || !state.AttachmentFormats[i].IsImageCompatible(); - pipeline.Internal.AttachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.AttachmentFormats[i], supportsIsNotMsOrSupportsStorage); + pipeline.Internal.AttachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.AttachmentFormats[i], isNotMsOrSupportsStorage); maxColorAttachmentIndex = i; if (state.AttachmentFormats[i].IsInteger()) @@ -319,10 +319,10 @@ namespace Ryujinx.Graphics.Vulkan if (state.DepthStencilEnable) { - bool supportsIsNotMsOrSupportsStorage = !state.DepthStencilFormat.IsImageCompatible() || + bool isNotMsOrSupportsStorage = !state.DepthStencilFormat.IsImageCompatible() || gd.Capabilities.SupportsShaderStorageImageMultisample; - pipeline.Internal.AttachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.DepthStencilFormat, supportsIsNotMsOrSupportsStorage); + pipeline.Internal.AttachmentFormats[attachmentCount++] = gd.FormatCapabilities.ConvertToVkFormat(state.DepthStencilFormat, isNotMsOrSupportsStorage); } pipeline.ColorBlendAttachmentStateCount = (uint)(maxColorAttachmentIndex + 1); diff --git a/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs b/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs index f78075b658..f15e4b9676 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs @@ -67,9 +67,9 @@ namespace Ryujinx.Graphics.Vulkan _device = device; _info = info; - bool supportsIsNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); + bool isNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); - var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, supportsIsNotMsOrSupportsStorage); + var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isNotMsOrSupportsStorage); var levels = (uint)info.Levels; var layers = (uint)info.GetLayers(); var depth = (uint)(info.Target == Target.Texture3D ? info.Depth : 1); @@ -82,7 +82,7 @@ namespace Ryujinx.Graphics.Vulkan var sampleCountFlags = ConvertToSampleCountFlags(gd.Capabilities.SupportedSampleCounts, (uint)info.Samples); - var usage = GetImageUsage(info.Format, supportsIsNotMsOrSupportsStorage, true); + var usage = GetImageUsage(info.Format, isNotMsOrSupportsStorage, true); var flags = ImageCreateFlags.CreateMutableFormatBit | ImageCreateFlags.CreateExtendedUsageBit; @@ -294,7 +294,7 @@ namespace Ryujinx.Graphics.Vulkan } } - public static ImageUsageFlags GetImageUsage(Format format, bool supportsIsNotMsOrSupportsStorage, bool extendedUsage) + public static ImageUsageFlags GetImageUsage(Format format, bool isNotMsOrSupportsStorage, bool extendedUsage) { var usage = DefaultUsageFlags; @@ -307,7 +307,7 @@ namespace Ryujinx.Graphics.Vulkan usage |= ImageUsageFlags.ColorAttachmentBit; } - if ((format.IsImageCompatible() && supportsIsNotMsOrSupportsStorage) || extendedUsage) + if ((format.IsImageCompatible() && isNotMsOrSupportsStorage) || extendedUsage) { usage |= ImageUsageFlags.StorageBit; } diff --git a/src/Ryujinx.Graphics.Vulkan/TextureView.cs b/src/Ryujinx.Graphics.Vulkan/TextureView.cs index 75dc321ddb..a6f5850e93 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureView.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureView.cs @@ -59,10 +59,10 @@ namespace Ryujinx.Graphics.Vulkan gd.Textures.Add(this); - bool supportsIsNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); + bool isNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); - var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, supportsIsNotMsOrSupportsStorage); - var usage = TextureStorage.GetImageUsage(info.Format, supportsIsNotMsOrSupportsStorage, false); + var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isNotMsOrSupportsStorage); + var usage = TextureStorage.GetImageUsage(info.Format, isNotMsOrSupportsStorage, false); var levels = (uint)info.Levels; var layers = (uint)info.GetLayers(); From 89a70f2aa38b934ea620f40f9b37f94a937cdc4c Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Sun, 1 Sep 2024 22:04:41 -0700 Subject: [PATCH 6/7] Rename variable and resolve a missed change --- src/Ryujinx.Graphics.Vulkan/TextureStorage.cs | 10 +++++----- src/Ryujinx.Graphics.Vulkan/TextureView.cs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs b/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs index 5c63269f10..51ef528d4a 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs @@ -77,9 +77,9 @@ namespace Ryujinx.Graphics.Vulkan _device = device; _info = info; - bool isNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); + bool isMsImageStorageSupported = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); - var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isNotMsOrSupportsStorage); + var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isMsImageStorageSupported); var levels = (uint)info.Levels; var layers = (uint)info.GetLayers(); var depth = (uint)(info.Target == Target.Texture3D ? info.Depth : 1); @@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Vulkan var sampleCountFlags = ConvertToSampleCountFlags(gd.Capabilities.SupportedSampleCounts, (uint)info.Samples); - var usage = GetImageUsage(info.Format, gd.Capabilities, isNotMsOrSupportsStorage, true); + var usage = GetImageUsage(info.Format, gd.Capabilities, isMsImageStorageSupported, true); var flags = ImageCreateFlags.CreateMutableFormatBit | ImageCreateFlags.CreateExtendedUsageBit; @@ -307,7 +307,7 @@ namespace Ryujinx.Graphics.Vulkan } } - public static ImageUsageFlags GetImageUsage(Format format in HardwareCapabilities capabilities, bool isNotMsOrSupportsStorage, bool extendedUsage) + public static ImageUsageFlags GetImageUsage(Format format, in HardwareCapabilities capabilities, bool isMsImageStorageSupported, bool extendedUsage) { var usage = DefaultUsageFlags; @@ -320,7 +320,7 @@ namespace Ryujinx.Graphics.Vulkan usage |= ImageUsageFlags.ColorAttachmentBit; } - if ((format.IsImageCompatible() && isNotMsOrSupportsStorage) || extendedUsage) + if ((format.IsImageCompatible() && isMsImageStorageSupported) || extendedUsage) { usage |= ImageUsageFlags.StorageBit; } diff --git a/src/Ryujinx.Graphics.Vulkan/TextureView.cs b/src/Ryujinx.Graphics.Vulkan/TextureView.cs index dba26b4bc2..b69cb2b4a6 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureView.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureView.cs @@ -61,10 +61,10 @@ namespace Ryujinx.Graphics.Vulkan gd.Textures.Add(this); - bool isNotMsOrSupportsStorage = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); + bool isMsImageStorageSupported = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); - var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isNotMsOrSupportsStorage); - var usage = TextureStorage.GetImageUsage(info.Format, gd.Capabilities, isNotMsOrSupportsStorage, false); + var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isMsImageStorageSupported); + var usage = TextureStorage.GetImageUsage(info.Format, gd.Capabilities, isMsImageStorageSupported, false); var levels = (uint)info.Levels; var layers = (uint)info.GetLayers(); From 08ae5010d369ab4f38fb0863f87df8c53c765f15 Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Tue, 17 Sep 2024 20:13:33 -0700 Subject: [PATCH 7/7] Revert changes to ConvertToVkFormat --- src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs | 4 ++-- src/Ryujinx.Graphics.Vulkan/TextureStorage.cs | 2 +- src/Ryujinx.Graphics.Vulkan/TextureView.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs index d4da4326f2..9ea8cec4be 100644 --- a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs +++ b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs @@ -148,7 +148,7 @@ namespace Ryujinx.Graphics.Vulkan return (formatFeatureFlags & flags) == flags; } - public VkFormat ConvertToVkFormat(Format srcFormat, bool storageFeatureFlagRequired) + public VkFormat ConvertToVkFormat(Format srcFormat) { var format = FormatTable.GetFormat(srcFormat); @@ -165,7 +165,7 @@ namespace Ryujinx.Graphics.Vulkan requiredFeatures |= FormatFeatureFlags.ColorAttachmentBit; } - if (srcFormat.IsImageCompatible() && storageFeatureFlagRequired) + if (srcFormat.IsImageCompatible()) { requiredFeatures |= FormatFeatureFlags.StorageImageBit; } diff --git a/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs b/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs index 51ef528d4a..d4b085d694 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs @@ -79,7 +79,7 @@ namespace Ryujinx.Graphics.Vulkan bool isMsImageStorageSupported = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); - var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isMsImageStorageSupported); + var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format); var levels = (uint)info.Levels; var layers = (uint)info.GetLayers(); var depth = (uint)(info.Target == Target.Texture3D ? info.Depth : 1); diff --git a/src/Ryujinx.Graphics.Vulkan/TextureView.cs b/src/Ryujinx.Graphics.Vulkan/TextureView.cs index b69cb2b4a6..38eede74a3 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureView.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureView.cs @@ -63,7 +63,7 @@ namespace Ryujinx.Graphics.Vulkan bool isMsImageStorageSupported = gd.Capabilities.SupportsShaderStorageImageMultisample || !info.Target.IsMultisample(); - var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format, isMsImageStorageSupported); + var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format); var usage = TextureStorage.GetImageUsage(info.Format, gd.Capabilities, isMsImageStorageSupported, false); var levels = (uint)info.Levels;