From 4ca78eded52f21089400cc28351b9353279b8171 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 23 May 2023 05:41:37 -0300 Subject: [PATCH] Vulkan: Do not set storage flag for multisample textures if not supported (#5060) --- src/Ryujinx.Graphics.Vulkan/HardwareCapabilities.cs | 3 +++ src/Ryujinx.Graphics.Vulkan/TextureStorage.cs | 6 +++--- src/Ryujinx.Graphics.Vulkan/TextureView.cs | 2 +- src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/HardwareCapabilities.cs b/src/Ryujinx.Graphics.Vulkan/HardwareCapabilities.cs index 5cab4113ae..4b9ace3aa3 100644 --- a/src/Ryujinx.Graphics.Vulkan/HardwareCapabilities.cs +++ b/src/Ryujinx.Graphics.Vulkan/HardwareCapabilities.cs @@ -28,6 +28,7 @@ namespace Ryujinx.Graphics.Vulkan public readonly bool SupportsSubgroupSizeControl; public readonly bool SupportsShaderInt8; public readonly bool SupportsShaderStencilExport; + public readonly bool SupportsShaderStorageImageMultisample; public readonly bool SupportsConditionalRendering; public readonly bool SupportsExtendedDynamicState; public readonly bool SupportsMultiView; @@ -63,6 +64,7 @@ namespace Ryujinx.Graphics.Vulkan bool supportsSubgroupSizeControl, bool supportsShaderInt8, bool supportsShaderStencilExport, + bool supportsShaderStorageImageMultisample, bool supportsConditionalRendering, bool supportsExtendedDynamicState, bool supportsMultiView, @@ -97,6 +99,7 @@ namespace Ryujinx.Graphics.Vulkan SupportsSubgroupSizeControl = supportsSubgroupSizeControl; SupportsShaderInt8 = supportsShaderInt8; SupportsShaderStencilExport = supportsShaderStencilExport; + SupportsShaderStorageImageMultisample = supportsShaderStorageImageMultisample; SupportsConditionalRendering = supportsConditionalRendering; SupportsExtendedDynamicState = supportsExtendedDynamicState; SupportsMultiView = supportsMultiView; diff --git a/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs b/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs index 0582e6ca85..4edb6f2fe9 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 = GetImageUsageFromFormat(info.Format); + var usage = GetImageUsage(info.Format, info.Target, gd.Capabilities.SupportsShaderStorageImageMultisample); var flags = ImageCreateFlags.CreateMutableFormatBit; @@ -293,7 +293,7 @@ namespace Ryujinx.Graphics.Vulkan } } - public static ImageUsageFlags GetImageUsageFromFormat(GAL.Format format) + public static ImageUsageFlags GetImageUsage(GAL.Format format, Target target, bool supportsMsStorage) { var usage = DefaultUsageFlags; @@ -306,7 +306,7 @@ namespace Ryujinx.Graphics.Vulkan usage |= ImageUsageFlags.ColorAttachmentBit; } - if (format.IsImageCompatible()) + if (format.IsImageCompatible() && (supportsMsStorage || !target.IsMultisample())) { usage |= ImageUsageFlags.StorageBit; } diff --git a/src/Ryujinx.Graphics.Vulkan/TextureView.cs b/src/Ryujinx.Graphics.Vulkan/TextureView.cs index 62d481eb9f..c2be74974b 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureView.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureView.cs @@ -54,7 +54,7 @@ namespace Ryujinx.Graphics.Vulkan gd.Textures.Add(this); var format = _gd.FormatCapabilities.ConvertToVkFormat(info.Format); - var usage = TextureStorage.GetImageUsageFromFormat(info.Format); + var usage = TextureStorage.GetImageUsage(info.Format, info.Target, gd.Capabilities.SupportsShaderStorageImageMultisample); var levels = (uint)info.Levels; var layers = (uint)info.GetLayers(); diff --git a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs index 74267325c0..4f3f72345b 100644 --- a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs +++ b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs @@ -295,6 +295,7 @@ namespace Ryujinx.Graphics.Vulkan supportsSubgroupSizeControl, featuresShaderInt8.ShaderInt8, _physicalDevice.IsDeviceExtensionPresent("VK_EXT_shader_stencil_export"), + features2.Features.ShaderStorageImageMultisample, _physicalDevice.IsDeviceExtensionPresent(ExtConditionalRendering.ExtensionName), _physicalDevice.IsDeviceExtensionPresent(ExtExtendedDynamicState.ExtensionName), features2.Features.MultiViewport,