From e7320471b9ae1b2104f759d2f075177fe6544cf0 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sat, 23 Jun 2018 18:22:24 -0300 Subject: [PATCH] Organized the Gpu folder a bit more, renamed a few things, address PR feedback --- Ryujinx.Graphics/Gal/GalConsts.cs | 7 ---- Ryujinx.Graphics/Gal/IGalFrameBuffer.cs | 10 ++--- Ryujinx.Graphics/Gal/IGalRasterizer.cs | 14 +++---- Ryujinx.Graphics/Gal/IGalShader.cs | 12 +++--- Ryujinx.Graphics/Gal/IGalTexture.cs | 6 +-- Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs | 22 +++++----- Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs | 33 +++++++-------- .../{OpenGLRenderer.cs => OGLRenderer.cs} | 4 +- Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs | 22 +++++----- Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs | 14 +++---- Ryujinx.Graphics/Gal/Shader/GlslDecl.cs | 2 + Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs | 2 +- Ryujinx.HLE/Gpu/{ => Engines}/INvGpuEngine.cs | 4 +- .../Gpu/{ => Engines}/MacroInterpreter.cs | 6 ++- Ryujinx.HLE/Gpu/{ => Engines}/NvGpuEngine.cs | 2 +- .../Gpu/{ => Engines}/NvGpuEngine2d.cs | 14 ++++--- .../Gpu/{ => Engines}/NvGpuEngine2dReg.cs | 2 +- .../Gpu/{ => Engines}/NvGpuEngine3d.cs | 42 ++++++++++--------- .../Gpu/{ => Engines}/NvGpuEngine3dReg.cs | 2 +- .../Gpu/{ => Engines}/NvGpuEngineDma.cs | 4 +- .../Gpu/{ => Engines}/NvGpuEngineDmaReg.cs | 2 +- Ryujinx.HLE/Gpu/{ => Engines}/NvGpuFifo.cs | 3 +- .../Gpu/{ => Engines}/NvGpuFifoMeth.cs | 2 +- Ryujinx.HLE/Gpu/{ => Engines}/NvGpuMethod.cs | 4 +- Ryujinx.HLE/Gpu/Exceptions/GpuException.cs | 11 +++++ .../Gpu/Exceptions/GpuExceptionHelper.cs | 12 ++++++ Ryujinx.HLE/Gpu/GpuMacroException.cs | 11 ----- Ryujinx.HLE/Gpu/GpuMacroExceptionMsgs.cs | 7 ---- .../Gpu/{ => Memory}/NvGpuBufferType.cs | 2 +- Ryujinx.HLE/Gpu/{ => Memory}/NvGpuPBEntry.cs | 2 +- .../Gpu/{ => Memory}/NvGpuPushBuffer.cs | 2 +- Ryujinx.HLE/Gpu/{ => Memory}/NvGpuVmm.cs | 2 +- Ryujinx.HLE/Gpu/{ => Memory}/NvGpuVmmCache.cs | 2 +- Ryujinx.HLE/Gpu/NvGpu.cs | 1 + .../Gpu/{ => Texture}/BlockLinearSwizzle.cs | 2 +- Ryujinx.HLE/Gpu/{ => Texture}/ISwizzle.cs | 2 +- .../Gpu/{ => Texture}/LinearSwizzle.cs | 2 +- .../Gpu/{ => Texture}/TextureFactory.cs | 5 ++- .../Gpu/{ => Texture}/TextureHelper.cs | 5 ++- .../{Texture.cs => Texture/TextureInfo.cs} | 8 ++-- .../Gpu/{ => Texture}/TextureReader.cs | 22 +++++----- .../Gpu/{ => Texture}/TextureSwizzle.cs | 2 +- .../Gpu/{ => Texture}/TextureWriter.cs | 22 +++++----- .../OsHle/Services/Nv/NvGpuAS/NvGpuASIoctl.cs | 2 +- .../Nv/NvHostChannel/NvHostChannelIoctl.cs | 2 +- .../OsHle/Services/Nv/NvMap/NvMapIoctl.cs | 2 +- Ryujinx.HLE/OsHle/Services/Vi/NvFlinger.cs | 5 ++- Ryujinx/Ui/Program.cs | 2 +- 48 files changed, 191 insertions(+), 179 deletions(-) delete mode 100644 Ryujinx.Graphics/Gal/GalConsts.cs rename Ryujinx.Graphics/Gal/OpenGL/{OpenGLRenderer.cs => OGLRenderer.cs} (93%) rename Ryujinx.HLE/Gpu/{ => Engines}/INvGpuEngine.cs (67%) rename Ryujinx.HLE/Gpu/{ => Engines}/MacroInterpreter.cs (98%) rename Ryujinx.HLE/Gpu/{ => Engines}/NvGpuEngine.cs (82%) rename Ryujinx.HLE/Gpu/{ => Engines}/NvGpuEngine2d.cs (93%) rename Ryujinx.HLE/Gpu/{ => Engines}/NvGpuEngine2dReg.cs (95%) rename Ryujinx.HLE/Gpu/{ => Engines}/NvGpuEngine3d.cs (94%) rename Ryujinx.HLE/Gpu/{ => Engines}/NvGpuEngine3dReg.cs (98%) rename Ryujinx.HLE/Gpu/{ => Engines}/NvGpuEngineDma.cs (97%) rename Ryujinx.HLE/Gpu/{ => Engines}/NvGpuEngineDmaReg.cs (93%) rename Ryujinx.HLE/Gpu/{ => Engines}/NvGpuFifo.cs (98%) rename Ryujinx.HLE/Gpu/{ => Engines}/NvGpuFifoMeth.cs (86%) rename Ryujinx.HLE/Gpu/{ => Engines}/NvGpuMethod.cs (51%) create mode 100644 Ryujinx.HLE/Gpu/Exceptions/GpuException.cs create mode 100644 Ryujinx.HLE/Gpu/Exceptions/GpuExceptionHelper.cs delete mode 100644 Ryujinx.HLE/Gpu/GpuMacroException.cs delete mode 100644 Ryujinx.HLE/Gpu/GpuMacroExceptionMsgs.cs rename Ryujinx.HLE/Gpu/{ => Memory}/NvGpuBufferType.cs (72%) rename Ryujinx.HLE/Gpu/{ => Memory}/NvGpuPBEntry.cs (94%) rename Ryujinx.HLE/Gpu/{ => Memory}/NvGpuPushBuffer.cs (99%) rename Ryujinx.HLE/Gpu/{ => Memory}/NvGpuVmm.cs (99%) rename Ryujinx.HLE/Gpu/{ => Memory}/NvGpuVmmCache.cs (99%) rename Ryujinx.HLE/Gpu/{ => Texture}/BlockLinearSwizzle.cs (97%) rename Ryujinx.HLE/Gpu/{ => Texture}/ISwizzle.cs (70%) rename Ryujinx.HLE/Gpu/{ => Texture}/LinearSwizzle.cs (91%) rename Ryujinx.HLE/Gpu/{ => Texture}/TextureFactory.cs (96%) rename Ryujinx.HLE/Gpu/{ => Texture}/TextureHelper.cs (94%) rename Ryujinx.HLE/Gpu/{Texture.cs => Texture/TextureInfo.cs} (92%) rename Ryujinx.HLE/Gpu/{ => Texture}/TextureReader.cs (97%) rename Ryujinx.HLE/Gpu/{ => Texture}/TextureSwizzle.cs (85%) rename Ryujinx.HLE/Gpu/{ => Texture}/TextureWriter.cs (77%) diff --git a/Ryujinx.Graphics/Gal/GalConsts.cs b/Ryujinx.Graphics/Gal/GalConsts.cs deleted file mode 100644 index 6c8857c6ed..0000000000 --- a/Ryujinx.Graphics/Gal/GalConsts.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.Graphics.Gal -{ - public static class GalConsts - { - public const string FlipUniformName = "flip"; - } -} \ No newline at end of file diff --git a/Ryujinx.Graphics/Gal/IGalFrameBuffer.cs b/Ryujinx.Graphics/Gal/IGalFrameBuffer.cs index 04e4cd8450..eaae0a492e 100644 --- a/Ryujinx.Graphics/Gal/IGalFrameBuffer.cs +++ b/Ryujinx.Graphics/Gal/IGalFrameBuffer.cs @@ -4,13 +4,13 @@ namespace Ryujinx.Graphics.Gal { public interface IGalFrameBuffer { - void Create(long Tag, int Width, int Height); + void Create(long Key, int Width, int Height); - void Bind(long Tag); + void Bind(long Key); - void BindTexture(long Tag, int Index); + void BindTexture(long Key, int Index); - void Set(long Tag); + void Set(long Key); void Set(byte[] Data, int Width, int Height); @@ -22,6 +22,6 @@ namespace Ryujinx.Graphics.Gal void Render(); - void GetBufferData(long Tag, Action Callback); + void GetBufferData(long Key, Action Callback); } } \ No newline at end of file diff --git a/Ryujinx.Graphics/Gal/IGalRasterizer.cs b/Ryujinx.Graphics/Gal/IGalRasterizer.cs index 7326fd0195..81c922befd 100644 --- a/Ryujinx.Graphics/Gal/IGalRasterizer.cs +++ b/Ryujinx.Graphics/Gal/IGalRasterizer.cs @@ -4,20 +4,20 @@ namespace Ryujinx.Graphics.Gal { void ClearBuffers(int RtIndex, GalClearBufferFlags Flags); - bool IsVboCached(long Tag, long DataSize); + bool IsVboCached(long Key, long DataSize); - bool IsIboCached(long Tag, long DataSize); + bool IsIboCached(long Key, long DataSize); - void CreateVbo(long Tag, byte[] Buffer); + void CreateVbo(long Key, byte[] Buffer); - void CreateIbo(long Tag, byte[] Buffer); + void CreateIbo(long Key, byte[] Buffer); - void SetVertexArray(int VbIndex, int Stride, long VboTag, GalVertexAttrib[] Attribs); + void SetVertexArray(int VbIndex, int Stride, long VboKey, GalVertexAttrib[] Attribs); - void SetIndexArray(long Tag, int Size, GalIndexFormat Format); + void SetIndexArray(long Key, int Size, GalIndexFormat Format); void DrawArrays(int First, int PrimCount, GalPrimitiveType PrimType); - void DrawElements(long IboTag, int First, GalPrimitiveType PrimType); + void DrawElements(long IboKey, int First, GalPrimitiveType PrimType); } } \ No newline at end of file diff --git a/Ryujinx.Graphics/Gal/IGalShader.cs b/Ryujinx.Graphics/Gal/IGalShader.cs index e3f258aaaa..79e77c0a49 100644 --- a/Ryujinx.Graphics/Gal/IGalShader.cs +++ b/Ryujinx.Graphics/Gal/IGalShader.cs @@ -4,17 +4,17 @@ namespace Ryujinx.Graphics.Gal { public interface IGalShader { - void Create(IGalMemory Memory, long Tag, GalShaderType Type); + void Create(IGalMemory Memory, long Key, GalShaderType Type); - IEnumerable GetTextureUsage(long Tag); + IEnumerable GetTextureUsage(long Key); - void SetConstBuffer(long Tag, int Cbuf, byte[] Data); + void SetConstBuffer(long Key, int Cbuf, byte[] Data); - void SetUniform1(string UniformName, int Value); + void EnsureTextureBinding(string UniformName, int Value); - void SetUniform2F(string UniformName, float X, float Y); + void SetFlip(float X, float Y); - void Bind(long Tag); + void Bind(long Key); void BindProgram(); } diff --git a/Ryujinx.Graphics/Gal/IGalTexture.cs b/Ryujinx.Graphics/Gal/IGalTexture.cs index d675854749..6379e73af4 100644 --- a/Ryujinx.Graphics/Gal/IGalTexture.cs +++ b/Ryujinx.Graphics/Gal/IGalTexture.cs @@ -2,11 +2,11 @@ namespace Ryujinx.Graphics.Gal { public interface IGalTexture { - void Create(long Tag, byte[] Data, GalTexture Texture); + void Create(long Key, byte[] Data, GalTexture Texture); - bool TryGetCachedTexture(long Tag, long DataSize, out GalTexture Texture); + bool TryGetCachedTexture(long Key, long DataSize, out GalTexture Texture); - void Bind(long Tag, int Index); + void Bind(long Key, int Index); void SetSampler(GalTextureSampler Sampler); } diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs index 7c7dee5114..4d91ff97ee 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs @@ -76,14 +76,14 @@ namespace Ryujinx.Graphics.Gal.OpenGL Shader = new ShaderProgram(); } - public void Create(long Tag, int Width, int Height) + public void Create(long Key, int Width, int Height) { //TODO: We should either use the original frame buffer size, //or just remove the Width/Height arguments. Width = Window.Width; Height = Window.Height; - if (Fbs.TryGetValue(Tag, out FrameBuffer Fb)) + if (Fbs.TryGetValue(Key, out FrameBuffer Fb)) { if (Fb.Width != Width || Fb.Height != Height) @@ -127,12 +127,12 @@ namespace Ryujinx.Graphics.Gal.OpenGL GL.Viewport(0, 0, Width, Height); - Fbs.Add(Tag, Fb); + Fbs.Add(Key, Fb); } - public void Bind(long Tag) + public void Bind(long Key) { - if (Fbs.TryGetValue(Tag, out FrameBuffer Fb)) + if (Fbs.TryGetValue(Key, out FrameBuffer Fb)) { GL.BindFramebuffer(FramebufferTarget.Framebuffer, Fb.Handle); @@ -140,9 +140,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL } } - public void BindTexture(long Tag, int Index) + public void BindTexture(long Key, int Index) { - if (Fbs.TryGetValue(Tag, out FrameBuffer Fb)) + if (Fbs.TryGetValue(Key, out FrameBuffer Fb)) { GL.ActiveTexture(TextureUnit.Texture0 + Index); @@ -150,9 +150,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL } } - public void Set(long Tag) + public void Set(long Key) { - if (Fbs.TryGetValue(Tag, out FrameBuffer Fb)) + if (Fbs.TryGetValue(Key, out FrameBuffer Fb)) { CurrTexHandle = Fb.TexHandle; } @@ -277,9 +277,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL } } - public void GetBufferData(long Tag, Action Callback) + public void GetBufferData(long Key, Action Callback) { - if (Fbs.TryGetValue(Tag, out FrameBuffer Fb)) + if (Fbs.TryGetValue(Key, out FrameBuffer Fb)) { GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, Fb.Handle); diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs index 7196161d22..bdf22b9c11 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs @@ -74,8 +74,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL { ClearBufferMask Mask = 0; - //OpenGL doesn't support clearing just a single color channel, - //so we can't just clear all channels... + //TODO: Use glColorMask to clear just the specified channels. if (Flags.HasFlag(GalClearBufferFlags.ColorRed) && Flags.HasFlag(GalClearBufferFlags.ColorGreen) && Flags.HasFlag(GalClearBufferFlags.ColorBlue) && @@ -97,45 +96,43 @@ namespace Ryujinx.Graphics.Gal.OpenGL GL.Clear(Mask); } - public bool IsVboCached(long Tag, long DataSize) + public bool IsVboCached(long Key, long DataSize) { - return VboCache.TryGetSize(Tag, out long Size) && Size == DataSize; + return VboCache.TryGetSize(Key, out long Size) && Size == DataSize; } - public bool IsIboCached(long Tag, long DataSize) + public bool IsIboCached(long Key, long DataSize) { - return IboCache.TryGetSize(Tag, out long Size) && Size == DataSize; + return IboCache.TryGetSize(Key, out long Size) && Size == DataSize; } - public void CreateVbo(long Tag, byte[] Buffer) + public void CreateVbo(long Key, byte[] Buffer) { int Handle = GL.GenBuffer(); - VboCache.AddOrUpdate(Tag, Handle, (uint)Buffer.Length); + VboCache.AddOrUpdate(Key, Handle, (uint)Buffer.Length); IntPtr Length = new IntPtr(Buffer.Length); GL.BindBuffer(BufferTarget.ArrayBuffer, Handle); GL.BufferData(BufferTarget.ArrayBuffer, Length, Buffer, BufferUsageHint.StreamDraw); - GL.BindBuffer(BufferTarget.ArrayBuffer, 0); } - public void CreateIbo(long Tag, byte[] Buffer) + public void CreateIbo(long Key, byte[] Buffer) { int Handle = GL.GenBuffer(); - IboCache.AddOrUpdate(Tag, Handle, (uint)Buffer.Length); + IboCache.AddOrUpdate(Key, Handle, (uint)Buffer.Length); IntPtr Length = new IntPtr(Buffer.Length); GL.BindBuffer(BufferTarget.ElementArrayBuffer, Handle); GL.BufferData(BufferTarget.ElementArrayBuffer, Length, Buffer, BufferUsageHint.StreamDraw); - GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0); } - public void SetVertexArray(int VbIndex, int Stride, long VboTag, GalVertexAttrib[] Attribs) + public void SetVertexArray(int VbIndex, int Stride, long VboKey, GalVertexAttrib[] Attribs) { - if (!VboCache.TryGetValue(VboTag, out int VboHandle)) + if (!VboCache.TryGetValue(VboKey, out int VboHandle)) { return; } @@ -178,11 +175,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL GL.VertexAttribPointer(Attrib.Index, Size, Type, Normalize, Stride, Offset); } - - GL.BindVertexArray(0); } - public void SetIndexArray(long Tag, int Size, GalIndexFormat Format) + public void SetIndexArray(long Key, int Size, GalIndexFormat Format) { IndexBuffer.Type = OGLEnumConverter.GetDrawElementsType(Format); @@ -201,9 +196,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL GL.DrawArrays(OGLEnumConverter.GetPrimitiveType(PrimType), First, PrimCount); } - public void DrawElements(long IboTag, int First, GalPrimitiveType PrimType) + public void DrawElements(long IboKey, int First, GalPrimitiveType PrimType) { - if (!IboCache.TryGetValue(IboTag, out int IboHandle)) + if (!IboCache.TryGetValue(IboKey, out int IboHandle)) { return; } diff --git a/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLRenderer.cs similarity index 93% rename from Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs rename to Ryujinx.Graphics/Gal/OpenGL/OGLRenderer.cs index 534e5daed8..ca70d4f666 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLRenderer.cs @@ -3,7 +3,7 @@ using System.Collections.Concurrent; namespace Ryujinx.Graphics.Gal.OpenGL { - public class OpenGLRenderer : IGalRenderer + public class OGLRenderer : IGalRenderer { public IGalBlend Blend { get; private set; } @@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL private ConcurrentQueue ActionsQueue; - public OpenGLRenderer() + public OGLRenderer() { Blend = new OGLBlend(); diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs index 8769cdd05a..5760d172af 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs @@ -84,9 +84,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL Programs = new Dictionary(); } - public void Create(IGalMemory Memory, long Tag, GalShaderType Type) + public void Create(IGalMemory Memory, long Key, GalShaderType Type) { - Stages.GetOrAdd(Tag, (Key) => ShaderStageFactory(Memory, Tag, Type)); + Stages.GetOrAdd(Key, (Stage) => ShaderStageFactory(Memory, Key, Type)); } private ShaderStage ShaderStageFactory(IGalMemory Memory, long Position, GalShaderType Type) @@ -107,9 +107,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL return Decompiler.Decompile(Memory, Position + 0x50, Type); } - public IEnumerable GetTextureUsage(long Tag) + public IEnumerable GetTextureUsage(long Key) { - if (Stages.TryGetValue(Tag, out ShaderStage Stage)) + if (Stages.TryGetValue(Key, out ShaderStage Stage)) { return Stage.TextureUsage; } @@ -117,11 +117,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL return Enumerable.Empty(); } - public void SetConstBuffer(long Tag, int Cbuf, byte[] Data) + public void SetConstBuffer(long Key, int Cbuf, byte[] Data) { BindProgram(); - if (Stages.TryGetValue(Tag, out ShaderStage Stage)) + if (Stages.TryGetValue(Key, out ShaderStage Stage)) { foreach (ShaderDeclInfo DeclInfo in Stage.UniformUsage.Where(x => x.Cbuf == Cbuf)) { @@ -144,7 +144,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL } } - public void SetUniform1(string UniformName, int Value) + public void EnsureTextureBinding(string UniformName, int Value) { BindProgram(); @@ -153,18 +153,18 @@ namespace Ryujinx.Graphics.Gal.OpenGL GL.Uniform1(Location, Value); } - public void SetUniform2F(string UniformName, float X, float Y) + public void SetFlip(float X, float Y) { BindProgram(); - int Location = GL.GetUniformLocation(CurrentProgramHandle, UniformName); + int Location = GL.GetUniformLocation(CurrentProgramHandle, GlslDecl.FlipUniformName); GL.Uniform2(Location, X, Y); } - public void Bind(long Tag) + public void Bind(long Key) { - if (Stages.TryGetValue(Tag, out ShaderStage Stage)) + if (Stages.TryGetValue(Key, out ShaderStage Stage)) { Bind(Stage); } diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs index a304cd8692..c50bdd71b5 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs @@ -31,11 +31,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL GL.DeleteTexture(CachedTexture.Handle); } - public void Create(long Tag, byte[] Data, GalTexture Texture) + public void Create(long Key, byte[] Data, GalTexture Texture) { int Handle = GL.GenTexture(); - TextureCache.AddOrUpdate(Tag, new TCE(Handle, Texture), (uint)Data.Length); + TextureCache.AddOrUpdate(Key, new TCE(Handle, Texture), (uint)Data.Length); GL.BindTexture(TextureTarget.Texture2D, Handle); @@ -146,11 +146,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL throw new ArgumentException(nameof(Format)); } - public bool TryGetCachedTexture(long Tag, long DataSize, out GalTexture Texture) + public bool TryGetCachedTexture(long Key, long DataSize, out GalTexture Texture) { - if (TextureCache.TryGetSize(Tag, out long Size) && Size == DataSize) + if (TextureCache.TryGetSize(Key, out long Size) && Size == DataSize) { - if (TextureCache.TryGetValue(Tag, out TCE CachedTexture)) + if (TextureCache.TryGetValue(Key, out TCE CachedTexture)) { Texture = CachedTexture.Texture; @@ -163,9 +163,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL return false; } - public void Bind(long Tag, int Index) + public void Bind(long Key, int Index) { - if (TextureCache.TryGetValue(Tag, out TCE CachedTexture)) + if (TextureCache.TryGetValue(Key, out TCE CachedTexture)) { GL.ActiveTexture(TextureUnit.Texture0 + Index); diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs index 4002c29a5d..86838ab2e4 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs @@ -26,6 +26,8 @@ namespace Ryujinx.Graphics.Gal.Shader public const string FragmentOutputName = "FragColor"; + public const string FlipUniformName = "flip"; + private string[] StagePrefixes = new string[] { "vp", "tcp", "tep", "gp", "fp" }; private string StagePrefix; diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs index 77f16b81fa..24db303f28 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs @@ -140,7 +140,7 @@ namespace Ryujinx.Graphics.Gal.Shader { if (Decl.ShaderType == GalShaderType.Vertex) { - SB.AppendLine("uniform vec2 " + GalConsts.FlipUniformName + ";"); + SB.AppendLine("uniform vec2 " + GlslDecl.FlipUniformName + ";"); } foreach (ShaderDeclInfo DeclInfo in Decl.Uniforms.Values.OrderBy(DeclKeySelector)) diff --git a/Ryujinx.HLE/Gpu/INvGpuEngine.cs b/Ryujinx.HLE/Gpu/Engines/INvGpuEngine.cs similarity index 67% rename from Ryujinx.HLE/Gpu/INvGpuEngine.cs rename to Ryujinx.HLE/Gpu/Engines/INvGpuEngine.cs index 62307f582d..068878a988 100644 --- a/Ryujinx.HLE/Gpu/INvGpuEngine.cs +++ b/Ryujinx.HLE/Gpu/Engines/INvGpuEngine.cs @@ -1,4 +1,6 @@ -namespace Ryujinx.HLE.Gpu +using Ryujinx.HLE.Gpu.Memory; + +namespace Ryujinx.HLE.Gpu.Engines { interface INvGpuEngine { diff --git a/Ryujinx.HLE/Gpu/MacroInterpreter.cs b/Ryujinx.HLE/Gpu/Engines/MacroInterpreter.cs similarity index 98% rename from Ryujinx.HLE/Gpu/MacroInterpreter.cs rename to Ryujinx.HLE/Gpu/Engines/MacroInterpreter.cs index 4b866a427e..aef2eb4c8a 100644 --- a/Ryujinx.HLE/Gpu/MacroInterpreter.cs +++ b/Ryujinx.HLE/Gpu/Engines/MacroInterpreter.cs @@ -1,7 +1,9 @@ +using Ryujinx.HLE.Gpu.Exceptions; +using Ryujinx.HLE.Gpu.Memory; using System; using System.Collections.Generic; -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Engines { class MacroInterpreter { @@ -419,7 +421,7 @@ namespace Ryujinx.HLE.Gpu //draw calls, this prevents the system from freezing (and throws instead). if (MethAddr == 0x585 && ++CallCount > MaxCallCountPerRun) { - throw new GpuMacroException(GpuMacroExceptionMsgs.CallCountExceeded); + GpuExceptionHelper.ThrowCallCoundExceeded(); } NvGpuPBEntry PBEntry = new NvGpuPBEntry(MethAddr, 0, Value); diff --git a/Ryujinx.HLE/Gpu/NvGpuEngine.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine.cs similarity index 82% rename from Ryujinx.HLE/Gpu/NvGpuEngine.cs rename to Ryujinx.HLE/Gpu/Engines/NvGpuEngine.cs index 41697ed699..f9d6342cf4 100644 --- a/Ryujinx.HLE/Gpu/NvGpuEngine.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Engines { enum NvGpuEngine { diff --git a/Ryujinx.HLE/Gpu/NvGpuEngine2d.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine2d.cs similarity index 93% rename from Ryujinx.HLE/Gpu/NvGpuEngine2d.cs rename to Ryujinx.HLE/Gpu/Engines/NvGpuEngine2d.cs index 53edebeb24..dcfec10fc3 100644 --- a/Ryujinx.HLE/Gpu/NvGpuEngine2d.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine2d.cs @@ -1,7 +1,9 @@ using Ryujinx.Graphics.Gal; +using Ryujinx.HLE.Gpu.Memory; +using Ryujinx.HLE.Gpu.Texture; using System.Collections.Generic; -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Engines { class NvGpuEngine2d : INvGpuEngine { @@ -75,19 +77,19 @@ namespace Ryujinx.HLE.Gpu int DstBlockHeight = 1 << ((DstBlkDim >> 4) & 0xf); - long Tag = Vmm.GetPhysicalAddress(MakeInt64From2xInt32(NvGpuEngine2dReg.SrcAddress)); + long Key = Vmm.GetPhysicalAddress(MakeInt64From2xInt32(NvGpuEngine2dReg.SrcAddress)); long SrcAddress = MakeInt64From2xInt32(NvGpuEngine2dReg.SrcAddress); long DstAddress = MakeInt64From2xInt32(NvGpuEngine2dReg.DstAddress); - bool IsFbTexture = Gpu.Engine3d.IsFrameBufferPosition(Tag); + bool IsFbTexture = Gpu.Engine3d.IsFrameBufferPosition(Key); if (IsFbTexture && DstLinear) { DstSwizzle = TextureSwizzle.BlockLinear; } - Texture DstTexture = new Texture( + TextureInfo DstTexture = new TextureInfo( DstAddress, DstWidth, DstHeight, @@ -103,7 +105,7 @@ namespace Ryujinx.HLE.Gpu SrcWidth = 1280; SrcHeight = 720; - Gpu.Renderer.FrameBuffer.GetBufferData(Tag, (byte[] Buffer) => + Gpu.Renderer.FrameBuffer.GetBufferData(Key, (byte[] Buffer) => { CopyTexture( Vmm, @@ -130,7 +132,7 @@ namespace Ryujinx.HLE.Gpu private void CopyTexture( NvGpuVmm Vmm, - Texture Texture, + TextureInfo Texture, byte[] Buffer, int Width, int Height) diff --git a/Ryujinx.HLE/Gpu/NvGpuEngine2dReg.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine2dReg.cs similarity index 95% rename from Ryujinx.HLE/Gpu/NvGpuEngine2dReg.cs rename to Ryujinx.HLE/Gpu/Engines/NvGpuEngine2dReg.cs index 1039e36804..29d66d463e 100644 --- a/Ryujinx.HLE/Gpu/NvGpuEngine2dReg.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine2dReg.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Engines { enum NvGpuEngine2dReg { diff --git a/Ryujinx.HLE/Gpu/NvGpuEngine3d.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs similarity index 94% rename from Ryujinx.HLE/Gpu/NvGpuEngine3d.cs rename to Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs index 5207263298..02461d5dda 100644 --- a/Ryujinx.HLE/Gpu/NvGpuEngine3d.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs @@ -1,8 +1,10 @@ using Ryujinx.Graphics.Gal; +using Ryujinx.HLE.Gpu.Memory; +using Ryujinx.HLE.Gpu.Texture; using System; using System.Collections.Generic; -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Engines { class NvGpuEngine3d : INvGpuEngine { @@ -73,13 +75,13 @@ namespace Ryujinx.HLE.Gpu { SetFrameBuffer(Vmm, 0); - long[] Tags = UploadShaders(Vmm); + long[] Keys = UploadShaders(Vmm); Gpu.Renderer.Shader.BindProgram(); SetAlphaBlending(); - UploadTextures(Vmm, Tags); + UploadTextures(Vmm, Keys); UploadUniforms(Vmm); UploadVertexArrays(Vmm); } @@ -119,7 +121,7 @@ namespace Ryujinx.HLE.Gpu private long[] UploadShaders(NvGpuVmm Vmm) { - long[] Tags = new long[5]; + long[] Keys = new long[5]; long BasePosition = MakeInt64From2xInt32(NvGpuEngine3dReg.ShaderAddress); @@ -136,14 +138,14 @@ namespace Ryujinx.HLE.Gpu continue; } - long Tag = BasePosition + (uint)Offset; + long Key = BasePosition + (uint)Offset; GalShaderType ShaderType = GetTypeFromProgram(Index); - Tags[(int)ShaderType] = Tag; + Keys[(int)ShaderType] = Key; - Gpu.Renderer.Shader.Create(Vmm, Tag, ShaderType); - Gpu.Renderer.Shader.Bind(Tag); + Gpu.Renderer.Shader.Create(Vmm, Key, ShaderType); + Gpu.Renderer.Shader.Bind(Key); } int RawSX = ReadRegister(NvGpuEngine3dReg.ViewportScaleX); @@ -155,9 +157,9 @@ namespace Ryujinx.HLE.Gpu float SignX = MathF.Sign(SX); float SignY = MathF.Sign(SY); - Gpu.Renderer.Shader.SetUniform2F(GalConsts.FlipUniformName, SignX, SignY); + Gpu.Renderer.Shader.SetFlip(SignX, SignY); - return Tags; + return Keys; } private static GalShaderType GetTypeFromProgram(int Program) @@ -224,7 +226,7 @@ namespace Ryujinx.HLE.Gpu } } - private void UploadTextures(NvGpuVmm Vmm, long[] Tags) + private void UploadTextures(NvGpuVmm Vmm, long[] Keys) { long BaseShPosition = MakeInt64From2xInt32(NvGpuEngine3dReg.ShaderAddress); @@ -234,15 +236,15 @@ namespace Ryujinx.HLE.Gpu //reserved for drawing the frame buffer. int TexIndex = 1; - for (int Index = 0; Index < Tags.Length; Index++) + for (int Index = 0; Index < Keys.Length; Index++) { - foreach (ShaderDeclInfo DeclInfo in Gpu.Renderer.Shader.GetTextureUsage(Tags[Index])) + foreach (ShaderDeclInfo DeclInfo in Gpu.Renderer.Shader.GetTextureUsage(Keys[Index])) { long Position = ConstBuffers[Index][TextureCbIndex].Position; UploadTexture(Vmm, Position, TexIndex, DeclInfo.Index); - Gpu.Renderer.Shader.SetUniform1(DeclInfo.Name, TexIndex); + Gpu.Renderer.Shader.EnsureTextureBinding(DeclInfo.Name, TexIndex); TexIndex++; } @@ -277,7 +279,7 @@ namespace Ryujinx.HLE.Gpu long TextureAddress = Vmm.ReadInt64(TicPosition + 4) & 0xffffffffffff; - long Tag = TextureAddress; + long Key = TextureAddress; TextureAddress = Vmm.GetPhysicalAddress(TextureAddress); @@ -297,11 +299,11 @@ namespace Ryujinx.HLE.Gpu bool HasCachedTexture = false; - if (Gpu.Renderer.Texture.TryGetCachedTexture(Tag, Size, out GalTexture Texture)) + if (Gpu.Renderer.Texture.TryGetCachedTexture(Key, Size, out GalTexture Texture)) { - if (NewTexture.Equals(Texture) && !Vmm.IsRegionModified(Tag, Size, NvGpuBufferType.Texture)) + if (NewTexture.Equals(Texture) && !Vmm.IsRegionModified(Key, Size, NvGpuBufferType.Texture)) { - Gpu.Renderer.Texture.Bind(Tag, TexIndex); + Gpu.Renderer.Texture.Bind(Key, TexIndex); HasCachedTexture = true; } @@ -311,10 +313,10 @@ namespace Ryujinx.HLE.Gpu { byte[] Data = TextureFactory.GetTextureData(Vmm, TicPosition); - Gpu.Renderer.Texture.Create(Tag, Data, NewTexture); + Gpu.Renderer.Texture.Create(Key, Data, NewTexture); } - Gpu.Renderer.Texture.Bind(Tag, TexIndex); + Gpu.Renderer.Texture.Bind(Key, TexIndex); } Gpu.Renderer.Texture.SetSampler(Sampler); diff --git a/Ryujinx.HLE/Gpu/NvGpuEngine3dReg.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3dReg.cs similarity index 98% rename from Ryujinx.HLE/Gpu/NvGpuEngine3dReg.cs rename to Ryujinx.HLE/Gpu/Engines/NvGpuEngine3dReg.cs index e0de4777d7..de2b2eef27 100644 --- a/Ryujinx.HLE/Gpu/NvGpuEngine3dReg.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3dReg.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Engines { enum NvGpuEngine3dReg { diff --git a/Ryujinx.HLE/Gpu/NvGpuEngineDma.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngineDma.cs similarity index 97% rename from Ryujinx.HLE/Gpu/NvGpuEngineDma.cs rename to Ryujinx.HLE/Gpu/Engines/NvGpuEngineDma.cs index ed7819e960..7e355e8de9 100644 --- a/Ryujinx.HLE/Gpu/NvGpuEngineDma.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngineDma.cs @@ -1,6 +1,8 @@ +using Ryujinx.HLE.Gpu.Memory; +using Ryujinx.HLE.Gpu.Texture; using System.Collections.Generic; -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Engines { class NvGpuEngineDma : INvGpuEngine { diff --git a/Ryujinx.HLE/Gpu/NvGpuEngineDmaReg.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngineDmaReg.cs similarity index 93% rename from Ryujinx.HLE/Gpu/NvGpuEngineDmaReg.cs rename to Ryujinx.HLE/Gpu/Engines/NvGpuEngineDmaReg.cs index 55b404c5e4..835a822d16 100644 --- a/Ryujinx.HLE/Gpu/NvGpuEngineDmaReg.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngineDmaReg.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Engines { enum NvGpuEngineDmaReg { diff --git a/Ryujinx.HLE/Gpu/NvGpuFifo.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuFifo.cs similarity index 98% rename from Ryujinx.HLE/Gpu/NvGpuFifo.cs rename to Ryujinx.HLE/Gpu/Engines/NvGpuFifo.cs index cf4e4f5e43..f004709483 100644 --- a/Ryujinx.HLE/Gpu/NvGpuFifo.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuFifo.cs @@ -1,6 +1,7 @@ +using Ryujinx.HLE.Gpu.Memory; using System.Collections.Concurrent; -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Engines { class NvGpuFifo { diff --git a/Ryujinx.HLE/Gpu/NvGpuFifoMeth.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuFifoMeth.cs similarity index 86% rename from Ryujinx.HLE/Gpu/NvGpuFifoMeth.cs rename to Ryujinx.HLE/Gpu/Engines/NvGpuFifoMeth.cs index 247a7bfc45..ffd179f261 100644 --- a/Ryujinx.HLE/Gpu/NvGpuFifoMeth.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuFifoMeth.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Engines { enum NvGpuFifoMeth { diff --git a/Ryujinx.HLE/Gpu/NvGpuMethod.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuMethod.cs similarity index 51% rename from Ryujinx.HLE/Gpu/NvGpuMethod.cs rename to Ryujinx.HLE/Gpu/Engines/NvGpuMethod.cs index f7ff66475c..04c92f2a93 100644 --- a/Ryujinx.HLE/Gpu/NvGpuMethod.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuMethod.cs @@ -1,4 +1,6 @@ -namespace Ryujinx.HLE.Gpu +using Ryujinx.HLE.Gpu.Memory; + +namespace Ryujinx.HLE.Gpu.Engines { delegate void NvGpuMethod(NvGpuVmm Vmm, NvGpuPBEntry PBEntry); } \ No newline at end of file diff --git a/Ryujinx.HLE/Gpu/Exceptions/GpuException.cs b/Ryujinx.HLE/Gpu/Exceptions/GpuException.cs new file mode 100644 index 0000000000..c0bce5a52c --- /dev/null +++ b/Ryujinx.HLE/Gpu/Exceptions/GpuException.cs @@ -0,0 +1,11 @@ +using System; + +namespace Ryujinx.HLE.Gpu.Exceptions +{ + class GpuException : Exception + { + public GpuException() : base() { } + + public GpuException(string ExMsg) : base(ExMsg) { } + } +} \ No newline at end of file diff --git a/Ryujinx.HLE/Gpu/Exceptions/GpuExceptionHelper.cs b/Ryujinx.HLE/Gpu/Exceptions/GpuExceptionHelper.cs new file mode 100644 index 0000000000..aeab9a291a --- /dev/null +++ b/Ryujinx.HLE/Gpu/Exceptions/GpuExceptionHelper.cs @@ -0,0 +1,12 @@ +namespace Ryujinx.HLE.Gpu.Exceptions +{ + static class GpuExceptionHelper + { + private const string CallCountExceeded = "Method call count exceeded the limit allowed per run!"; + + public static void ThrowCallCoundExceeded() + { + throw new GpuException(CallCountExceeded); + } + } +} \ No newline at end of file diff --git a/Ryujinx.HLE/Gpu/GpuMacroException.cs b/Ryujinx.HLE/Gpu/GpuMacroException.cs deleted file mode 100644 index dffc065ec7..0000000000 --- a/Ryujinx.HLE/Gpu/GpuMacroException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace Ryujinx.HLE.Gpu -{ - class GpuMacroException : Exception - { - public GpuMacroException() : base() { } - - public GpuMacroException(string ExMsg) : base(ExMsg) { } - } -} \ No newline at end of file diff --git a/Ryujinx.HLE/Gpu/GpuMacroExceptionMsgs.cs b/Ryujinx.HLE/Gpu/GpuMacroExceptionMsgs.cs deleted file mode 100644 index 795b765d66..0000000000 --- a/Ryujinx.HLE/Gpu/GpuMacroExceptionMsgs.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.HLE.Gpu -{ - static class GpuMacroExceptionMsgs - { - public const string CallCountExceeded = "Method call count exceeded the limit allowed per run!"; - } -} \ No newline at end of file diff --git a/Ryujinx.HLE/Gpu/NvGpuBufferType.cs b/Ryujinx.HLE/Gpu/Memory/NvGpuBufferType.cs similarity index 72% rename from Ryujinx.HLE/Gpu/NvGpuBufferType.cs rename to Ryujinx.HLE/Gpu/Memory/NvGpuBufferType.cs index a44a772dbd..7474aa33fa 100644 --- a/Ryujinx.HLE/Gpu/NvGpuBufferType.cs +++ b/Ryujinx.HLE/Gpu/Memory/NvGpuBufferType.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Memory { enum NvGpuBufferType { diff --git a/Ryujinx.HLE/Gpu/NvGpuPBEntry.cs b/Ryujinx.HLE/Gpu/Memory/NvGpuPBEntry.cs similarity index 94% rename from Ryujinx.HLE/Gpu/NvGpuPBEntry.cs rename to Ryujinx.HLE/Gpu/Memory/NvGpuPBEntry.cs index 2cd663feda..aba89e3c97 100644 --- a/Ryujinx.HLE/Gpu/NvGpuPBEntry.cs +++ b/Ryujinx.HLE/Gpu/Memory/NvGpuPBEntry.cs @@ -1,7 +1,7 @@ using System; using System.Collections.ObjectModel; -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Memory { struct NvGpuPBEntry { diff --git a/Ryujinx.HLE/Gpu/NvGpuPushBuffer.cs b/Ryujinx.HLE/Gpu/Memory/NvGpuPushBuffer.cs similarity index 99% rename from Ryujinx.HLE/Gpu/NvGpuPushBuffer.cs rename to Ryujinx.HLE/Gpu/Memory/NvGpuPushBuffer.cs index 2d4f0c1ac6..6121b3e612 100644 --- a/Ryujinx.HLE/Gpu/NvGpuPushBuffer.cs +++ b/Ryujinx.HLE/Gpu/Memory/NvGpuPushBuffer.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.IO; -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Memory { static class NvGpuPushBuffer { diff --git a/Ryujinx.HLE/Gpu/NvGpuVmm.cs b/Ryujinx.HLE/Gpu/Memory/NvGpuVmm.cs similarity index 99% rename from Ryujinx.HLE/Gpu/NvGpuVmm.cs rename to Ryujinx.HLE/Gpu/Memory/NvGpuVmm.cs index b0ba3e90b4..36f6406a1e 100644 --- a/Ryujinx.HLE/Gpu/NvGpuVmm.cs +++ b/Ryujinx.HLE/Gpu/Memory/NvGpuVmm.cs @@ -2,7 +2,7 @@ using ChocolArm64.Memory; using Ryujinx.Graphics.Gal; using System.Collections.Concurrent; -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Memory { class NvGpuVmm : IAMemory, IGalMemory { diff --git a/Ryujinx.HLE/Gpu/NvGpuVmmCache.cs b/Ryujinx.HLE/Gpu/Memory/NvGpuVmmCache.cs similarity index 99% rename from Ryujinx.HLE/Gpu/NvGpuVmmCache.cs rename to Ryujinx.HLE/Gpu/Memory/NvGpuVmmCache.cs index 38b25e4fca..c7108f00ca 100644 --- a/Ryujinx.HLE/Gpu/NvGpuVmmCache.cs +++ b/Ryujinx.HLE/Gpu/Memory/NvGpuVmmCache.cs @@ -2,7 +2,7 @@ using ChocolArm64.Memory; using System; using System.Collections.Generic; -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Memory { class NvGpuVmmCache { diff --git a/Ryujinx.HLE/Gpu/NvGpu.cs b/Ryujinx.HLE/Gpu/NvGpu.cs index a8b8e9e834..625cb727fe 100644 --- a/Ryujinx.HLE/Gpu/NvGpu.cs +++ b/Ryujinx.HLE/Gpu/NvGpu.cs @@ -1,4 +1,5 @@ using Ryujinx.Graphics.Gal; +using Ryujinx.HLE.Gpu.Engines; namespace Ryujinx.HLE.Gpu { diff --git a/Ryujinx.HLE/Gpu/BlockLinearSwizzle.cs b/Ryujinx.HLE/Gpu/Texture/BlockLinearSwizzle.cs similarity index 97% rename from Ryujinx.HLE/Gpu/BlockLinearSwizzle.cs rename to Ryujinx.HLE/Gpu/Texture/BlockLinearSwizzle.cs index 366f574038..e66d76136a 100644 --- a/Ryujinx.HLE/Gpu/BlockLinearSwizzle.cs +++ b/Ryujinx.HLE/Gpu/Texture/BlockLinearSwizzle.cs @@ -1,6 +1,6 @@ using System; -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Texture { class BlockLinearSwizzle : ISwizzle { diff --git a/Ryujinx.HLE/Gpu/ISwizzle.cs b/Ryujinx.HLE/Gpu/Texture/ISwizzle.cs similarity index 70% rename from Ryujinx.HLE/Gpu/ISwizzle.cs rename to Ryujinx.HLE/Gpu/Texture/ISwizzle.cs index 525707ba77..222aab1630 100644 --- a/Ryujinx.HLE/Gpu/ISwizzle.cs +++ b/Ryujinx.HLE/Gpu/Texture/ISwizzle.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Texture { interface ISwizzle { diff --git a/Ryujinx.HLE/Gpu/LinearSwizzle.cs b/Ryujinx.HLE/Gpu/Texture/LinearSwizzle.cs similarity index 91% rename from Ryujinx.HLE/Gpu/LinearSwizzle.cs rename to Ryujinx.HLE/Gpu/Texture/LinearSwizzle.cs index 995866ad67..720f78322a 100644 --- a/Ryujinx.HLE/Gpu/LinearSwizzle.cs +++ b/Ryujinx.HLE/Gpu/Texture/LinearSwizzle.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Texture { class LinearSwizzle : ISwizzle { diff --git a/Ryujinx.HLE/Gpu/TextureFactory.cs b/Ryujinx.HLE/Gpu/Texture/TextureFactory.cs similarity index 96% rename from Ryujinx.HLE/Gpu/TextureFactory.cs rename to Ryujinx.HLE/Gpu/Texture/TextureFactory.cs index 94c6eb183d..9df0b60002 100644 --- a/Ryujinx.HLE/Gpu/TextureFactory.cs +++ b/Ryujinx.HLE/Gpu/Texture/TextureFactory.cs @@ -1,7 +1,8 @@ using Ryujinx.Graphics.Gal; +using Ryujinx.HLE.Gpu.Memory; using System; -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Texture { static class TextureFactory { @@ -61,7 +62,7 @@ namespace Ryujinx.HLE.Gpu int Width = (Tic[4] & 0xffff) + 1; int Height = (Tic[5] & 0xffff) + 1; - Texture Texture = new Texture( + TextureInfo Texture = new TextureInfo( TextureAddress, Width, Height, diff --git a/Ryujinx.HLE/Gpu/TextureHelper.cs b/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs similarity index 94% rename from Ryujinx.HLE/Gpu/TextureHelper.cs rename to Ryujinx.HLE/Gpu/Texture/TextureHelper.cs index 237d87abca..ac8f75c5f1 100644 --- a/Ryujinx.HLE/Gpu/TextureHelper.cs +++ b/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs @@ -1,12 +1,13 @@ using ChocolArm64.Memory; using Ryujinx.Graphics.Gal; +using Ryujinx.HLE.Gpu.Memory; using System; -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Texture { static class TextureHelper { - public static ISwizzle GetSwizzle(Texture Texture, int Width, int Bpp) + public static ISwizzle GetSwizzle(TextureInfo Texture, int Width, int Bpp) { switch (Texture.Swizzle) { diff --git a/Ryujinx.HLE/Gpu/Texture.cs b/Ryujinx.HLE/Gpu/Texture/TextureInfo.cs similarity index 92% rename from Ryujinx.HLE/Gpu/Texture.cs rename to Ryujinx.HLE/Gpu/Texture/TextureInfo.cs index 1de7f302c6..31784bbc58 100644 --- a/Ryujinx.HLE/Gpu/Texture.cs +++ b/Ryujinx.HLE/Gpu/Texture/TextureInfo.cs @@ -1,8 +1,8 @@ using Ryujinx.Graphics.Gal; -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Texture { - struct Texture + struct TextureInfo { public long Position { get; private set; } @@ -16,7 +16,7 @@ namespace Ryujinx.HLE.Gpu public GalTextureFormat Format { get; private set; } - public Texture( + public TextureInfo( long Position, int Width, int Height) @@ -34,7 +34,7 @@ namespace Ryujinx.HLE.Gpu Format = GalTextureFormat.A8B8G8R8; } - public Texture( + public TextureInfo( long Position, int Width, int Height, diff --git a/Ryujinx.HLE/Gpu/TextureReader.cs b/Ryujinx.HLE/Gpu/Texture/TextureReader.cs similarity index 97% rename from Ryujinx.HLE/Gpu/TextureReader.cs rename to Ryujinx.HLE/Gpu/Texture/TextureReader.cs index 9e9ff78346..48bf1a90fe 100644 --- a/Ryujinx.HLE/Gpu/TextureReader.cs +++ b/Ryujinx.HLE/Gpu/Texture/TextureReader.cs @@ -2,11 +2,11 @@ using ChocolArm64.Memory; using Ryujinx.Graphics.Gal; using System; -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Texture { static class TextureReader { - public static byte[] Read(IAMemory Memory, Texture Texture) + public static byte[] Read(IAMemory Memory, TextureInfo Texture) { switch (Texture.Format) { @@ -31,7 +31,7 @@ namespace Ryujinx.HLE.Gpu throw new NotImplementedException(Texture.Format.ToString()); } - private unsafe static byte[] Read1Bpp(IAMemory Memory, Texture Texture) + private unsafe static byte[] Read1Bpp(IAMemory Memory, TextureInfo Texture) { int Width = Texture.Width; int Height = Texture.Height; @@ -64,7 +64,7 @@ namespace Ryujinx.HLE.Gpu return Output; } - private unsafe static byte[] Read5551(IAMemory Memory, Texture Texture) + private unsafe static byte[] Read5551(IAMemory Memory, TextureInfo Texture) { int Width = Texture.Width; int Height = Texture.Height; @@ -102,7 +102,7 @@ namespace Ryujinx.HLE.Gpu return Output; } - private unsafe static byte[] Read565(IAMemory Memory, Texture Texture) + private unsafe static byte[] Read565(IAMemory Memory, TextureInfo Texture) { int Width = Texture.Width; int Height = Texture.Height; @@ -139,7 +139,7 @@ namespace Ryujinx.HLE.Gpu return Output; } - private unsafe static byte[] Read2Bpp(IAMemory Memory, Texture Texture) + private unsafe static byte[] Read2Bpp(IAMemory Memory, TextureInfo Texture) { int Width = Texture.Width; int Height = Texture.Height; @@ -172,7 +172,7 @@ namespace Ryujinx.HLE.Gpu return Output; } - private unsafe static byte[] Read4Bpp(IAMemory Memory, Texture Texture) + private unsafe static byte[] Read4Bpp(IAMemory Memory, TextureInfo Texture) { int Width = Texture.Width; int Height = Texture.Height; @@ -205,7 +205,7 @@ namespace Ryujinx.HLE.Gpu return Output; } - private unsafe static byte[] Read8Bpp(IAMemory Memory, Texture Texture) + private unsafe static byte[] Read8Bpp(IAMemory Memory, TextureInfo Texture) { int Width = Texture.Width; int Height = Texture.Height; @@ -238,7 +238,7 @@ namespace Ryujinx.HLE.Gpu return Output; } - private unsafe static byte[] Read16Bpp(IAMemory Memory, Texture Texture) + private unsafe static byte[] Read16Bpp(IAMemory Memory, TextureInfo Texture) { int Width = Texture.Width; int Height = Texture.Height; @@ -273,7 +273,7 @@ namespace Ryujinx.HLE.Gpu return Output; } - private unsafe static byte[] Read8Bpt4x4(IAMemory Memory, Texture Texture) + private unsafe static byte[] Read8Bpt4x4(IAMemory Memory, TextureInfo Texture) { int Width = (Texture.Width + 3) / 4; int Height = (Texture.Height + 3) / 4; @@ -306,7 +306,7 @@ namespace Ryujinx.HLE.Gpu return Output; } - private unsafe static byte[] Read16Bpt4x4(IAMemory Memory, Texture Texture) + private unsafe static byte[] Read16Bpt4x4(IAMemory Memory, TextureInfo Texture) { int Width = (Texture.Width + 3) / 4; int Height = (Texture.Height + 3) / 4; diff --git a/Ryujinx.HLE/Gpu/TextureSwizzle.cs b/Ryujinx.HLE/Gpu/Texture/TextureSwizzle.cs similarity index 85% rename from Ryujinx.HLE/Gpu/TextureSwizzle.cs rename to Ryujinx.HLE/Gpu/Texture/TextureSwizzle.cs index 5e32f4c753..076df97ab5 100644 --- a/Ryujinx.HLE/Gpu/TextureSwizzle.cs +++ b/Ryujinx.HLE/Gpu/Texture/TextureSwizzle.cs @@ -1,4 +1,4 @@ -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Texture { enum TextureSwizzle { diff --git a/Ryujinx.HLE/Gpu/TextureWriter.cs b/Ryujinx.HLE/Gpu/Texture/TextureWriter.cs similarity index 77% rename from Ryujinx.HLE/Gpu/TextureWriter.cs rename to Ryujinx.HLE/Gpu/Texture/TextureWriter.cs index ad92961c65..b64302a5ab 100644 --- a/Ryujinx.HLE/Gpu/TextureWriter.cs +++ b/Ryujinx.HLE/Gpu/Texture/TextureWriter.cs @@ -2,16 +2,16 @@ using ChocolArm64.Memory; using Ryujinx.Graphics.Gal; using System; -namespace Ryujinx.HLE.Gpu +namespace Ryujinx.HLE.Gpu.Texture { static class TextureWriter { public static void Write( - IAMemory Memory, - Texture Texture, - byte[] Data, - int Width, - int Height) + IAMemory Memory, + TextureInfo Texture, + byte[] Data, + int Width, + int Height) { switch (Texture.Format) { @@ -22,11 +22,11 @@ namespace Ryujinx.HLE.Gpu } private unsafe static void Write4Bpp( - IAMemory Memory, - Texture Texture, - byte[] Data, - int Width, - int Height) + IAMemory Memory, + TextureInfo Texture, + byte[] Data, + int Width, + int Height) { ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 4); diff --git a/Ryujinx.HLE/OsHle/Services/Nv/NvGpuAS/NvGpuASIoctl.cs b/Ryujinx.HLE/OsHle/Services/Nv/NvGpuAS/NvGpuASIoctl.cs index c96c04c866..fcc478a417 100644 --- a/Ryujinx.HLE/OsHle/Services/Nv/NvGpuAS/NvGpuASIoctl.cs +++ b/Ryujinx.HLE/OsHle/Services/Nv/NvGpuAS/NvGpuASIoctl.cs @@ -1,5 +1,5 @@ using ChocolArm64.Memory; -using Ryujinx.HLE.Gpu; +using Ryujinx.HLE.Gpu.Memory; using Ryujinx.HLE.Logging; using Ryujinx.HLE.OsHle.Services.Nv.NvMap; using System; diff --git a/Ryujinx.HLE/OsHle/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs b/Ryujinx.HLE/OsHle/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs index c461fa282c..8f3d3cd7d6 100644 --- a/Ryujinx.HLE/OsHle/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs +++ b/Ryujinx.HLE/OsHle/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs @@ -1,5 +1,5 @@ using ChocolArm64.Memory; -using Ryujinx.HLE.Gpu; +using Ryujinx.HLE.Gpu.Memory; using Ryujinx.HLE.Logging; using Ryujinx.HLE.OsHle.Services.Nv.NvGpuAS; using System; diff --git a/Ryujinx.HLE/OsHle/Services/Nv/NvMap/NvMapIoctl.cs b/Ryujinx.HLE/OsHle/Services/Nv/NvMap/NvMapIoctl.cs index 43de4edb19..ec10a37588 100644 --- a/Ryujinx.HLE/OsHle/Services/Nv/NvMap/NvMapIoctl.cs +++ b/Ryujinx.HLE/OsHle/Services/Nv/NvMap/NvMapIoctl.cs @@ -1,5 +1,5 @@ using ChocolArm64.Memory; -using Ryujinx.HLE.Gpu; +using Ryujinx.HLE.Gpu.Memory; using Ryujinx.HLE.Logging; using Ryujinx.HLE.OsHle.Utilities; using System.Collections.Concurrent; diff --git a/Ryujinx.HLE/OsHle/Services/Vi/NvFlinger.cs b/Ryujinx.HLE/OsHle/Services/Vi/NvFlinger.cs index a285d0b142..a3ed3ab51c 100644 --- a/Ryujinx.HLE/OsHle/Services/Vi/NvFlinger.cs +++ b/Ryujinx.HLE/OsHle/Services/Vi/NvFlinger.cs @@ -1,5 +1,5 @@ using Ryujinx.Graphics.Gal; -using Ryujinx.HLE.Gpu; +using Ryujinx.HLE.Gpu.Texture; using Ryujinx.HLE.Logging; using Ryujinx.HLE.OsHle.Handles; using Ryujinx.HLE.OsHle.Services.Nv.NvMap; @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.IO; using System.Text; using System.Threading; + using static Ryujinx.HLE.OsHle.Services.Android.Parcel; namespace Ryujinx.HLE.OsHle.Services.Android @@ -353,7 +354,7 @@ namespace Ryujinx.HLE.OsHle.Services.Android { //Frame buffer is not set on the GPU registers, in this case //assume that the app is manually writing to it. - Texture Texture = new Texture(FbAddr, FbWidth, FbHeight); + TextureInfo Texture = new TextureInfo(FbAddr, FbWidth, FbHeight); byte[] Data = TextureReader.Read(Context.Memory, Texture); diff --git a/Ryujinx/Ui/Program.cs b/Ryujinx/Ui/Program.cs index 3bb16faf29..936a28d2e1 100644 --- a/Ryujinx/Ui/Program.cs +++ b/Ryujinx/Ui/Program.cs @@ -14,7 +14,7 @@ namespace Ryujinx { Console.Title = "Ryujinx Console"; - IGalRenderer Renderer = new OpenGLRenderer(); + IGalRenderer Renderer = new OGLRenderer(); IAalOutput AudioOut = new OpenALAudioOut();