Multisampling support

This commit is contained in:
gdk 2022-02-20 17:13:47 -03:00 committed by riperiperi
parent fb20e5b371
commit 6810796638
4 changed files with 23 additions and 11 deletions

View file

@ -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<DisposableImageView>[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);

View file

@ -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,

View file

@ -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<PipelineShaderStageCreateInfo> 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
};

View file

@ -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;