From a42ab2e40cae5db96cc58634f1e70c4e31bb095d Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Sat, 25 Aug 2018 01:16:58 -0300 Subject: Implement vertex instancing (#381) --- Ryujinx.Graphics/Gal/Shader/GlslDecl.cs | 1 + Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'Ryujinx.Graphics/Gal/Shader') diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs index 25f64db8..c22a282d 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs @@ -41,6 +41,7 @@ namespace Ryujinx.Graphics.Gal.Shader public const string ExtraUniformBlockName = "Extra"; public const string FlipUniformName = "flip"; + public const string InstanceUniformName = "instance"; public const string ProgramName = "program"; public const string ProgramAName = ProgramName + "_a"; diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs index 8baf30e0..984684f1 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs @@ -241,10 +241,15 @@ namespace Ryujinx.Graphics.Gal.Shader { if (Decl.ShaderType == GalShaderType.Vertex) { - SB.AppendLine("layout (std140) uniform " + GlslDecl.ExtraUniformBlockName + "{"); + //Memory layout here is [flip_x, flip_y, instance, unused] + //It's using 4 bytes, not 8 + + SB.AppendLine("layout (std140) uniform " + GlslDecl.ExtraUniformBlockName + " {"); SB.AppendLine(IdentationStr + "vec2 " + GlslDecl.FlipUniformName + ";"); + SB.AppendLine(IdentationStr + "int " + GlslDecl.InstanceUniformName + ";"); + SB.AppendLine("};"); } @@ -816,7 +821,7 @@ namespace Ryujinx.Graphics.Gal.Shader switch (Abuf.Offs) { case GlslDecl.VertexIdAttr: return "gl_VertexID"; - case GlslDecl.InstanceIdAttr: return "gl_InstanceID"; + case GlslDecl.InstanceIdAttr: return GlslDecl.InstanceUniformName; } } else if (Decl.ShaderType == GalShaderType.TessEvaluation) -- cgit v1.2.3