Improve shader sending method to GAL, use a memory interface instead of reading a fixed array size and sending every time
This commit is contained in:
parent
84996ccd36
commit
79e0070363
12 changed files with 72 additions and 63 deletions
26
Ryushader/Memory.cs
Normal file
26
Ryushader/Memory.cs
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
||||
Console.WriteLine(Program.Code);
|
||||
}
|
||||
|
||||
GlslProgram Program = Decompiler.Decompile(Code, ShaderType);
|
||||
|
||||
Console.WriteLine(Program.Code);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue