From 88a0e720cbe567aff67b6124aa9e6cfc17599739 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sat, 20 Aug 2022 16:20:27 -0300 Subject: Use RGBA16 vertex format if RGB16 is not supported on Vulkan (#3552) * Use RGBA16 vertex format if RGB16 is not supported on Vulkan * Catch all shader compilation exceptions --- Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs | 8 ++-- .../Engine/Threed/ThreedClassState.cs | 50 ++++++++++++++++++++-- 2 files changed, 52 insertions(+), 6 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Engine') diff --git a/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs b/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs index bb43309b..fdf8f822 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs @@ -1317,10 +1317,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed for (int location = 0; location < attributeTypes.Length; location++) { - attributeTypes[location] = vertexAttribState[location].UnpackType() switch + VertexAttribType type = vertexAttribState[location].UnpackType(); + + attributeTypes[location] = type switch { - 3 => AttributeType.Sint, - 4 => AttributeType.Uint, + VertexAttribType.Sint => AttributeType.Sint, + VertexAttribType.Uint => AttributeType.Uint, _ => AttributeType.Float }; } diff --git a/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClassState.cs b/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClassState.cs index c90dea41..e416cd58 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClassState.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClassState.cs @@ -267,6 +267,41 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed #pragma warning restore CS0649 } + /// + /// Vertex attribute vector and component size. + /// + enum VertexAttribSize + { + Size32x4 = 1, + Size32x3 = 2, + Size16x4 = 3, + Size32x2 = 4, + Size16x3 = 5, + Size8x4 = 0xa, + Size16x2 = 0xf, + Size32 = 0x12, + Size8x3 = 0x13, + Size8x2 = 0x18, + Size16 = 0x1b, + Size8 = 0x1d, + Rgb10A2 = 0x30, + Rg11B10 = 0x31 + } + + /// + /// Vertex attribute component type. + /// + enum VertexAttribType + { + Snorm = 1, + Unorm = 2, + Sint = 3, + Uint = 4, + Uscaled = 5, + Sscaled = 6, + Float = 7 + } + /// /// Vertex buffer attribute state. /// @@ -312,13 +347,22 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed return Attribute & 0x3fe00000; } - /// + /// + /// Unpacks the Maxwell attribute size. + /// + /// Attribute size + public VertexAttribSize UnpackSize() + { + return (VertexAttribSize)((Attribute >> 21) & 0x3f); + } + + /// /// Unpacks the Maxwell attribute component type. /// /// Attribute component type - public uint UnpackType() + public VertexAttribType UnpackType() { - return (Attribute >> 27) & 7; + return (VertexAttribType)((Attribute >> 27) & 7); } } -- cgit v1.2.3