diff --git a/Ryujinx.Graphics.Vulkan/FramebufferParams.cs b/Ryujinx.Graphics.Vulkan/FramebufferParams.cs index 817c26bb4..59e161a9c 100644 --- a/Ryujinx.Graphics.Vulkan/FramebufferParams.cs +++ b/Ryujinx.Graphics.Vulkan/FramebufferParams.cs @@ -15,6 +15,7 @@ namespace Ryujinx.Graphics.Vulkan public uint Height { get; } public uint Layers { get; } + public uint[] AttachmentSamples { get; } public VkFormat[] AttachmentFormats { get; } public int[] AttachmentIndices { get; } @@ -38,6 +39,7 @@ namespace Ryujinx.Graphics.Vulkan Height = height; Layers = 1; + AttachmentSamples = new[] { 1u }; AttachmentFormats = new[] { format }; AttachmentIndices = new[] { 0 }; @@ -56,6 +58,7 @@ namespace Ryujinx.Graphics.Vulkan _attachments = new Auto[count]; + AttachmentSamples = new uint[count]; AttachmentFormats = new VkFormat[count]; AttachmentIndices = new int[count]; MaxColorAttachmentIndex = colors.Length - 1; @@ -75,6 +78,7 @@ namespace Ryujinx.Graphics.Vulkan _attachments[index] = texture.GetImageViewForAttachment(); + AttachmentSamples[index] = (uint)texture.Info.Samples; AttachmentFormats[index] = texture.VkFormat; AttachmentIndices[index] = bindIndex; @@ -95,6 +99,7 @@ namespace Ryujinx.Graphics.Vulkan { _attachments[count - 1] = dsTexture.GetImageViewForAttachment(); + AttachmentSamples[count - 1] = (uint)dsTexture.Info.Samples; AttachmentFormats[count - 1] = dsTexture.VkFormat; width = Math.Min(width, (uint)dsTexture.Width); diff --git a/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/Ryujinx.Graphics.Vulkan/PipelineBase.cs index 6c1f12f0f..e43735732 100644 --- a/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -97,6 +97,7 @@ namespace Ryujinx.Graphics.Vulkan _newState.Initialize(); _newState.LineWidth = 1f; + _newState.SamplesCount = 1; } protected virtual DescriptorSetLayout[] CreateDescriptorSetLayouts(VulkanGraphicsDevice gd, Device device, out PipelineLayout layout) @@ -916,6 +917,7 @@ namespace Ryujinx.Graphics.Vulkan { FramebufferParams = new FramebufferParams(Device, colors, depthStencil); UpdatePipelineAttachmentFormats(); + _newState.SamplesCount = FramebufferParams.AttachmentSamples.Length != 0 ? FramebufferParams.AttachmentSamples[0] : 1; } protected void UpdatePipelineAttachmentFormats() @@ -959,7 +961,7 @@ namespace Ryujinx.Graphics.Vulkan attachmentDescs[i] = new AttachmentDescription( 0, FramebufferParams.AttachmentFormats[i], - SampleCountFlags.SampleCount1Bit, + TextureStorage.ConvertToSampleCountFlags(FramebufferParams.AttachmentSamples[i]), AttachmentLoadOp.Load, AttachmentStoreOp.Store, AttachmentLoadOp.Load, diff --git a/Ryujinx.Graphics.Vulkan/PipelineState.cs b/Ryujinx.Graphics.Vulkan/PipelineState.cs index b97954f27..1e8cc2ae5 100644 --- a/Ryujinx.Graphics.Vulkan/PipelineState.cs +++ b/Ryujinx.Graphics.Vulkan/PipelineState.cs @@ -33,37 +33,37 @@ namespace Ryujinx.Graphics.Vulkan public uint StencilFrontCompareMask { - get => (UInt32)((Internal.Id2 >> 0) & 0xFFFFFFFF); + get => (uint)((Internal.Id2 >> 0) & 0xFFFFFFFF); set => Internal.Id2 = (Internal.Id2 & 0xFFFFFFFF00000000) | ((ulong)value << 0); } public uint StencilFrontWriteMask { - get => (UInt32)((Internal.Id2 >> 32) & 0xFFFFFFFF); + get => (uint)((Internal.Id2 >> 32) & 0xFFFFFFFF); set => Internal.Id2 = (Internal.Id2 & 0xFFFFFFFF) | ((ulong)value << 32); } public uint StencilFrontReference { - get => (UInt32)((Internal.Id3 >> 0) & 0xFFFFFFFF); + get => (uint)((Internal.Id3 >> 0) & 0xFFFFFFFF); set => Internal.Id3 = (Internal.Id3 & 0xFFFFFFFF00000000) | ((ulong)value << 0); } public uint StencilBackCompareMask { - get => (UInt32)((Internal.Id3 >> 32) & 0xFFFFFFFF); + get => (uint)((Internal.Id3 >> 32) & 0xFFFFFFFF); set => Internal.Id3 = (Internal.Id3 & 0xFFFFFFFF) | ((ulong)value << 32); } public uint StencilBackWriteMask { - get => (UInt32)((Internal.Id4 >> 0) & 0xFFFFFFFF); + get => (uint)((Internal.Id4 >> 0) & 0xFFFFFFFF); set => Internal.Id4 = (Internal.Id4 & 0xFFFFFFFF00000000) | ((ulong)value << 0); } public uint StencilBackReference { - get => (UInt32)((Internal.Id4 >> 32) & 0xFFFFFFFF); + get => (uint)((Internal.Id4 >> 32) & 0xFFFFFFFF); set => Internal.Id4 = (Internal.Id4 & 0xFFFFFFFF) | ((ulong)value << 32); } @@ -285,10 +285,16 @@ namespace Ryujinx.Graphics.Vulkan public uint PatchControlPoints { - get => (UInt32)((Internal.Id10 >> 0) & 0xFFFFFFFF); + get => (uint)((Internal.Id10 >> 0) & 0xFFFFFFFF); set => Internal.Id10 = (Internal.Id10 & 0xFFFFFFFF00000000) | ((ulong)value << 0); } + public uint SamplesCount + { + get => (uint)((Internal.Id10 >> 32) & 0xFFFFFFFF); + set => Internal.Id10 = (Internal.Id10 & 0xFFFFFFFF) | ((ulong)value << 32); + } + public NativeArray Stages; public PipelineLayout PipelineLayout; @@ -406,7 +412,7 @@ namespace Ryujinx.Graphics.Vulkan { SType = StructureType.PipelineMultisampleStateCreateInfo, SampleShadingEnable = false, - RasterizationSamples = SampleCountFlags.SampleCount1Bit, + RasterizationSamples = TextureStorage.ConvertToSampleCountFlags(SamplesCount), MinSampleShading = 1 }; diff --git a/Ryujinx.Graphics.Vulkan/TextureStorage.cs b/Ryujinx.Graphics.Vulkan/TextureStorage.cs index 88a24d09a..d1a8b444e 100644 --- a/Ryujinx.Graphics.Vulkan/TextureStorage.cs +++ b/Ryujinx.Graphics.Vulkan/TextureStorage.cs @@ -302,9 +302,8 @@ namespace Ryujinx.Graphics.Vulkan } } - private static SampleCountFlags ConvertToSampleCountFlags(uint samples) + public static SampleCountFlags ConvertToSampleCountFlags(uint samples) { - return SampleCountFlags.SampleCount1Bit; if (samples == 0 || samples > (uint)SampleCountFlags.SampleCount64Bit) { return SampleCountFlags.SampleCount1Bit;