From 3262fd13dadb98b189e8e8447aacc4762845bbe5 Mon Sep 17 00:00:00 2001 From: greggameplayer <33609333+greggameplayer@users.noreply.github.com> Date: Thu, 28 Jun 2018 23:32:07 +0200 Subject: [PATCH 1/5] add the forgotten mm:u link (#190) --- Ryujinx.HLE/OsHle/Services/ServiceFactory.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Ryujinx.HLE/OsHle/Services/ServiceFactory.cs b/Ryujinx.HLE/OsHle/Services/ServiceFactory.cs index 0720c5d25..914c84490 100644 --- a/Ryujinx.HLE/OsHle/Services/ServiceFactory.cs +++ b/Ryujinx.HLE/OsHle/Services/ServiceFactory.cs @@ -8,6 +8,7 @@ using Ryujinx.HLE.OsHle.Services.Friend; using Ryujinx.HLE.OsHle.Services.FspSrv; using Ryujinx.HLE.OsHle.Services.Hid; using Ryujinx.HLE.OsHle.Services.Lm; +using Ryujinx.HLE.OsHle.Services.Mm; using Ryujinx.HLE.OsHle.Services.Nfp; using Ryujinx.HLE.OsHle.Services.Ns; using Ryujinx.HLE.OsHle.Services.Nv; @@ -79,7 +80,10 @@ namespace Ryujinx.HLE.OsHle.Services case "lm": return new ILogService(); - + + case "mm:u": + return new IRequest(); + case "nfp:user": return new IUserManager(); From 3e81421b2f8789fd2e57124dd6805e031e1a2a9f Mon Sep 17 00:00:00 2001 From: gdkchan Date: Thu, 28 Jun 2018 20:48:18 -0300 Subject: [PATCH 2/5] Add support for vertex base on indexed draws, fix index buffer first (untested) (#197) --- Ryujinx.Graphics/Gal/IGalRasterizer.cs | 2 +- Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs | 18 ++++++++++++++++-- Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs | 4 +++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Ryujinx.Graphics/Gal/IGalRasterizer.cs b/Ryujinx.Graphics/Gal/IGalRasterizer.cs index 45f92f27f..e0469382f 100644 --- a/Ryujinx.Graphics/Gal/IGalRasterizer.cs +++ b/Ryujinx.Graphics/Gal/IGalRasterizer.cs @@ -28,6 +28,6 @@ namespace Ryujinx.Graphics.Gal void DrawArrays(int First, int PrimCount, GalPrimitiveType PrimType); - void DrawElements(long IboKey, int First, GalPrimitiveType PrimType); + void DrawElements(long IboKey, int First, int VertexBase, GalPrimitiveType PrimType); } } \ No newline at end of file diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs index ebd1e8d1c..8bff6bb3e 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs @@ -54,6 +54,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL private struct IbInfo { public int Count; + public int ElemSizeLog2; public DrawElementsType Type; } @@ -206,6 +207,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL IndexBuffer.Type = OGLEnumConverter.GetDrawElementsType(Format); IndexBuffer.Count = Size >> (int)Format; + + IndexBuffer.ElemSizeLog2 = (int)Format; } public void DrawArrays(int First, int PrimCount, GalPrimitiveType PrimType) @@ -220,7 +223,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL GL.DrawArrays(OGLEnumConverter.GetPrimitiveType(PrimType), First, PrimCount); } - public void DrawElements(long IboKey, int First, GalPrimitiveType PrimType) + public void DrawElements(long IboKey, int First, int VertexBase, GalPrimitiveType PrimType) { if (!IboCache.TryGetValue(IboKey, out int IboHandle)) { @@ -233,7 +236,18 @@ namespace Ryujinx.Graphics.Gal.OpenGL GL.BindBuffer(BufferTarget.ElementArrayBuffer, IboHandle); - GL.DrawElements(Mode, IndexBuffer.Count, IndexBuffer.Type, First); + First <<= IndexBuffer.ElemSizeLog2; + + if (VertexBase != 0) + { + IntPtr Indices = new IntPtr(First); + + GL.DrawElementsBaseVertex(Mode, IndexBuffer.Count, IndexBuffer.Type, Indices, VertexBase); + } + else + { + GL.DrawElements(Mode, IndexBuffer.Count, IndexBuffer.Type, First); + } } } } \ No newline at end of file diff --git a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs index 56cb7688b..b27f5c142 100644 --- a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs @@ -487,7 +487,9 @@ namespace Ryujinx.HLE.Gpu.Engines if (IndexCount != 0) { - Gpu.Renderer.Rasterizer.DrawElements(IndexPosition, IndexFirst, PrimType); + int VertexBase = ReadRegister(NvGpuEngine3dReg.VertexArrayElemBase); + + Gpu.Renderer.Rasterizer.DrawElements(IndexPosition, IndexFirst, VertexBase, PrimType); } else { From bc26aa558a500a07ded8e3f32f5b26fe19794ad2 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Thu, 28 Jun 2018 20:51:38 -0300 Subject: [PATCH 3/5] Add support for the FMLA (by element/scalar) instruction (#187) * Add support for the FMLA (by element/scalar) instruction * Fix encoding --- ChocolArm64/AOpCodeTable.cs | 1 + ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs | 9 +++++++++ ChocolArm64/Instruction/AInstEmitSimdHelper.cs | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/ChocolArm64/AOpCodeTable.cs b/ChocolArm64/AOpCodeTable.cs index e78d0b572..1f60be1c3 100644 --- a/ChocolArm64/AOpCodeTable.cs +++ b/ChocolArm64/AOpCodeTable.cs @@ -271,6 +271,7 @@ namespace ChocolArm64 SetA64("000111100x1xxxxx010110xxxxxxxxxx", AInstEmit.Fmin_S, typeof(AOpCodeSimdReg)); SetA64("0x0011101x1xxxxx111101xxxxxxxxxx", AInstEmit.Fmin_V, typeof(AOpCodeSimdReg)); SetA64("000111100x1xxxxx011110xxxxxxxxxx", AInstEmit.Fminnm_S, typeof(AOpCodeSimdReg)); + SetA64("010111111<0011100<1xxxxx110011xxxxxxxxxx", AInstEmit.Fmla_V, typeof(AOpCodeSimdReg)); SetA64("0x0011111<0011101<1xxxxx110011xxxxxxxxxx", AInstEmit.Fmls_V, typeof(AOpCodeSimdReg)); diff --git a/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs b/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs index 14dbf1d66..efd3cc6e8 100644 --- a/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs +++ b/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs @@ -516,6 +516,15 @@ namespace ChocolArm64.Instruction Fmin_S(Context); } + public static void Fmla_Se(AILEmitterCtx Context) + { + EmitScalarTernaryOpByElemF(Context, () => + { + Context.Emit(OpCodes.Mul); + Context.Emit(OpCodes.Add); + }); + } + public static void Fmla_V(AILEmitterCtx Context) { EmitVectorTernaryOpF(Context, () => diff --git a/ChocolArm64/Instruction/AInstEmitSimdHelper.cs b/ChocolArm64/Instruction/AInstEmitSimdHelper.cs index 80c6aeb7a..bca456497 100644 --- a/ChocolArm64/Instruction/AInstEmitSimdHelper.cs +++ b/ChocolArm64/Instruction/AInstEmitSimdHelper.cs @@ -260,6 +260,13 @@ namespace ChocolArm64.Instruction EmitScalarOpByElemF(Context, Emit, Op.Index, Ternary: false); } + public static void EmitScalarTernaryOpByElemF(AILEmitterCtx Context, Action Emit) + { + AOpCodeSimdRegElemF Op = (AOpCodeSimdRegElemF)Context.CurrOp; + + EmitScalarOpByElemF(Context, Emit, Op.Index, Ternary: true); + } + public static void EmitScalarOpByElemF(AILEmitterCtx Context, Action Emit, int Elem, bool Ternary) { AOpCodeSimdReg Op = (AOpCodeSimdReg)Context.CurrOp; From 4c7c21634eeab768971777f62dab8224f7ed2eb0 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Thu, 28 Jun 2018 20:52:32 -0300 Subject: [PATCH 4/5] Add Sse2 fallback to Vector{Extract|Insert}Single methods on the CPU (#193) --- ChocolArm64/Instruction/AVectorHelper.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ChocolArm64/Instruction/AVectorHelper.cs b/ChocolArm64/Instruction/AVectorHelper.cs index 1a2135923..dbfaab756 100644 --- a/ChocolArm64/Instruction/AVectorHelper.cs +++ b/ChocolArm64/Instruction/AVectorHelper.cs @@ -422,6 +422,15 @@ namespace ChocolArm64.Instruction { return Sse41.Extract(Vector, Index); } + else if (Sse2.IsSupported) + { + Vector128 ShortVector = Sse.StaticCast(Vector); + + int Low = Sse2.Extract(ShortVector, (byte)(Index * 2 + 0)); + int High = Sse2.Extract(ShortVector, (byte)(Index * 2 + 1)); + + return BitConverter.Int32BitsToSingle(Low | (High << 16)); + } throw new PlatformNotSupportedException(); } @@ -509,6 +518,20 @@ namespace ChocolArm64.Instruction { return Sse41.Insert(Vector, Value, (byte)(Index << 4)); } + else if (Sse2.IsSupported) + { + int IntValue = BitConverter.SingleToInt32Bits(Value); + + ushort Low = (ushort)(IntValue >> 0); + ushort High = (ushort)(IntValue >> 16); + + Vector128 ShortVector = Sse.StaticCast(Vector); + + ShortVector = Sse2.Insert(ShortVector, Low, (byte)(Index * 2 + 0)); + ShortVector = Sse2.Insert(ShortVector, High, (byte)(Index * 2 + 1)); + + return Sse.StaticCast(ShortVector); + } throw new PlatformNotSupportedException(); } From edfd4bc860e05698946605c740fdb5857d64e917 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Thu, 28 Jun 2018 22:01:58 -0300 Subject: [PATCH 5/5] Explicit GLSL "position" attribute location (#199) --- Ryujinx.Graphics/Gal/Shader/GlslDecl.cs | 2 ++ Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs index 5c7dd794e..867f90160 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs @@ -15,6 +15,8 @@ namespace Ryujinx.Graphics.Gal.Shader public const int GlPositionVec4Index = 7; + public const int PositionOutAttrLocation = 15; + private const int AttrStartIndex = 8; private const int TexStartIndex = 8; diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs index 2bc350da3..87d448689 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs @@ -208,7 +208,7 @@ namespace Ryujinx.Graphics.Gal.Shader { if (Decl.ShaderType == GalShaderType.Fragment) { - SB.AppendLine("in vec4 " + GlslDecl.PositionOutAttrName + ";"); + SB.AppendLine("layout (location = " + GlslDecl.PositionOutAttrLocation + ") in vec4 " + GlslDecl.PositionOutAttrName + ";"); } PrintDeclAttributes(Decl.InAttributes.Values, "in"); @@ -218,7 +218,7 @@ namespace Ryujinx.Graphics.Gal.Shader { if (Decl.ShaderType == GalShaderType.Vertex) { - SB.AppendLine("out vec4 " + GlslDecl.PositionOutAttrName + ";"); + SB.AppendLine("layout (location = " + GlslDecl.PositionOutAttrLocation + ") out vec4 " + GlslDecl.PositionOutAttrName + ";"); } PrintDeclAttributes(Decl.OutAttributes.Values, "out");