diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2018-05-22 22:43:31 -0300 |
|---|---|---|
| committer | gdkchan <gab.dark.100@gmail.com> | 2018-05-22 22:43:31 -0300 |
| commit | 79e007036383b11cd53c2563fbb7f139a02c90ec (patch) | |
| tree | c7ddfc097282b98afd16f08cc5042636f9283224 /Ryushader | |
| parent | 84996ccd36a5fa13892c1f02acb1c79031c35aa5 (diff) | |
Improve shader sending method to GAL, use a memory interface instead of reading a fixed array size and sending every time
Diffstat (limited to 'Ryushader')
| -rw-r--r-- | Ryushader/Memory.cs | 26 | ||||
| -rw-r--r-- | Ryushader/Program.cs | 16 |
2 files changed, 31 insertions, 11 deletions
diff --git a/Ryushader/Memory.cs b/Ryushader/Memory.cs new file mode 100644 index 00000000..ae336e72 --- /dev/null +++ b/Ryushader/Memory.cs @@ -0,0 +1,26 @@ +using Ryujinx.Graphics.Gal; +using System.IO; + +namespace Ryushader +{ + class Memory : IGalMemory + { + private Stream BaseStream; + + private BinaryReader Reader; + + public Memory(Stream BaseStream) + { + this.BaseStream = BaseStream; + + Reader = new BinaryReader(BaseStream); + } + + public int ReadInt32(long Position) + { + BaseStream.Seek(Position, SeekOrigin.Begin); + + return Reader.ReadInt32(); + } + } +} diff --git a/Ryushader/Program.cs b/Ryushader/Program.cs index 6fec744d..9444be6d 100644 --- a/Ryushader/Program.cs +++ b/Ryushader/Program.cs @@ -24,20 +24,14 @@ namespace Ryushader case "f": ShaderType = GalShaderType.Fragment; break; } - byte[] Data = File.ReadAllBytes(args[1]); - - int[] Code = new int[Data.Length / 4]; - - for (int Offset = 0; Offset + 4 <= Data.Length; Offset += 4) + using (FileStream FS = new FileStream(args[1], FileMode.Open, FileAccess.Read)) { - int Value = BitConverter.ToInt32(Data, Offset); + Memory Mem = new Memory(FS); - Code[Offset >> 2] = Value; - } + GlslProgram Program = Decompiler.Decompile(Mem, 0, ShaderType); - GlslProgram Program = Decompiler.Decompile(Code, ShaderType); - - Console.WriteLine(Program.Code); + Console.WriteLine(Program.Code); + } } else { |
