diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs index b144cef306..3489a040d5 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs @@ -6,6 +6,7 @@ namespace Ryujinx.Graphics.Gal.Shader class GlslDecl { public const int LayerAttr = 0x064; + public const int ViewportIdxAttr = 0x068; public const int PointSizeAttr = 0x06c; public const int PointCoordAttrX = 0x2e0; public const int PointCoordAttrY = 0x2e4; diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs index e6fb7ea147..7be7d0a744 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs @@ -190,7 +190,13 @@ namespace Ryujinx.Graphics.Gal.Shader private void PrintDeclHeader() { - if (Decl.ShaderType == GalShaderType.Geometry) + if(Decl.ShaderType == GalShaderType.Vertex) + { + SB.AppendLine("#extension GL_AMD_vertex_shader_viewport_index : require"); + + SB.AppendLine(); + } + else if (Decl.ShaderType == GalShaderType.Geometry) { int MaxVertices = Header.MaxOutputVertexCount; @@ -872,10 +878,18 @@ namespace Ryujinx.Graphics.Gal.Shader return Name + Swizzle; } + else if (Abuf.Offs == GlslDecl.ViewportIdxAttr) + { + return "gl_ViewportIndex"; + } else if (Abuf.Offs == GlslDecl.PointSizeAttr) { return "gl_PointSize"; } + else + { + throw new NotImplementedException($"Attribute with offset 0x{Abuf.Offs:x2} is not implemented."); + } } if (DeclInfo.Index >= 32) @@ -1346,9 +1360,10 @@ namespace Ryujinx.Graphics.Gal.Shader switch (Node) { case ShaderIrOperAbuf Abuf: - return Abuf.Offs == GlslDecl.LayerAttr || - Abuf.Offs == GlslDecl.InstanceIdAttr || - Abuf.Offs == GlslDecl.VertexIdAttr || + return Abuf.Offs == GlslDecl.LayerAttr || + Abuf.Offs == GlslDecl.ViewportIdxAttr || + Abuf.Offs == GlslDecl.InstanceIdAttr || + Abuf.Offs == GlslDecl.VertexIdAttr || Abuf.Offs == GlslDecl.FaceAttr ? OperType.I32 : OperType.F32;