Implement scaled vertex format emulation (#5564)

* Implement scaled vertex format emulation

* Auto-format (whitespace)

* Delete ToVec4Type
This commit is contained in:
gdkchan 2023-08-16 08:30:33 -03:00 committed by GitHub
parent 492a046335
commit effd546331
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 164 additions and 8 deletions

View file

@ -9,6 +9,48 @@ namespace Ryujinx.Graphics.Vulkan
{
class FormatCapabilities
{
private static readonly GAL.Format[] _scaledFormats = {
GAL.Format.R8Uscaled,
GAL.Format.R8Sscaled,
GAL.Format.R16Uscaled,
GAL.Format.R16Sscaled,
GAL.Format.R8G8Uscaled,
GAL.Format.R8G8Sscaled,
GAL.Format.R16G16Uscaled,
GAL.Format.R16G16Sscaled,
GAL.Format.R8G8B8Uscaled,
GAL.Format.R8G8B8Sscaled,
GAL.Format.R16G16B16Uscaled,
GAL.Format.R16G16B16Sscaled,
GAL.Format.R8G8B8A8Uscaled,
GAL.Format.R8G8B8A8Sscaled,
GAL.Format.R16G16B16A16Uscaled,
GAL.Format.R16G16B16A16Sscaled,
GAL.Format.R10G10B10A2Uscaled,
GAL.Format.R10G10B10A2Sscaled,
};
private static readonly GAL.Format[] _intFormats = {
GAL.Format.R8Uint,
GAL.Format.R8Sint,
GAL.Format.R16Uint,
GAL.Format.R16Sint,
GAL.Format.R8G8Uint,
GAL.Format.R8G8Sint,
GAL.Format.R16G16Uint,
GAL.Format.R16G16Sint,
GAL.Format.R8G8B8Uint,
GAL.Format.R8G8B8Sint,
GAL.Format.R16G16B16Uint,
GAL.Format.R16G16B16Sint,
GAL.Format.R8G8B8A8Uint,
GAL.Format.R8G8B8A8Sint,
GAL.Format.R16G16B16A16Uint,
GAL.Format.R16G16B16A16Sint,
GAL.Format.R10G10B10A2Uint,
GAL.Format.R10G10B10A2Sint,
};
private readonly FormatFeatureFlags[] _bufferTable;
private readonly FormatFeatureFlags[] _optimalTable;
@ -66,6 +108,25 @@ namespace Ryujinx.Graphics.Vulkan
return (formatFeatureFlags & flags) == flags;
}
public bool SupportsScaledVertexFormats()
{
// We want to check is all scaled formats are supported,
// but if the integer variant is not supported either,
// then the format is likely not supported at all,
// we ignore formats that are entirely unsupported here.
for (int i = 0; i < _scaledFormats.Length; i++)
{
if (!BufferFormatSupports(FormatFeatureFlags.VertexBufferBit, _scaledFormats[i]) &&
BufferFormatSupports(FormatFeatureFlags.VertexBufferBit, _intFormats[i]))
{
return false;
}
}
return true;
}
public bool BufferFormatSupports(FormatFeatureFlags flags, VkFormat format)
{
_api.GetPhysicalDeviceFormatProperties(_physicalDevice, format, out var fp);

View file

@ -604,6 +604,7 @@ namespace Ryujinx.Graphics.Vulkan
supportsMismatchingViewFormat: true,
supportsCubemapView: !IsAmdGcn,
supportsNonConstantTextureOffset: false,
supportsScaledVertexFormats: FormatCapabilities.SupportsScaledVertexFormats(),
supportsShaderBallot: false,
supportsShaderBarrierDivergence: Vendor != Vendor.Intel,
supportsShaderFloat64: Capabilities.SupportsShaderFloat64,