aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2023-08-16 08:30:33 -0300
committerGitHub <noreply@github.com>2023-08-16 08:30:33 -0300
commiteffd546331371928bc38bc8a48b0c26c7c59f3e9 (patch)
treeec760ee09a3751abd3b5a261ad5be599942a3a35 /src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs
parent492a0463358e7706e0fb34537d55810d833ae695 (diff)
Implement scaled vertex format emulation (#5564)1.1.989
* Implement scaled vertex format emulation * Auto-format (whitespace) * Delete ToVec4Type
Diffstat (limited to 'src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs')
-rw-r--r--src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs
index 5f7deeb6..7307a0ee 100644
--- a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs
+++ b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs
@@ -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);