2018-05-17 18:25:42 +00:00
|
|
|
|
using Ryujinx.Graphics.Gal;
|
|
|
|
|
using Ryujinx.Graphics.Gal.Shader;
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
2018-06-11 00:46:42 +00:00
|
|
|
|
namespace Ryujinx.ShaderTools
|
2018-05-17 18:25:42 +00:00
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
2018-12-18 00:32:12 +00:00
|
|
|
|
private static readonly int MaxUboSize = 65536;
|
|
|
|
|
|
2018-05-17 18:25:42 +00:00
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Length == 2)
|
|
|
|
|
{
|
2018-12-18 00:32:12 +00:00
|
|
|
|
GlslDecompiler Decompiler = new GlslDecompiler(MaxUboSize);
|
2018-05-17 18:25:42 +00:00
|
|
|
|
|
|
|
|
|
GalShaderType ShaderType = GalShaderType.Vertex;
|
|
|
|
|
|
|
|
|
|
switch (args[0].ToLower())
|
|
|
|
|
{
|
|
|
|
|
case "v": ShaderType = GalShaderType.Vertex; break;
|
|
|
|
|
case "tc": ShaderType = GalShaderType.TessControl; break;
|
|
|
|
|
case "te": ShaderType = GalShaderType.TessEvaluation; break;
|
|
|
|
|
case "g": ShaderType = GalShaderType.Geometry; break;
|
|
|
|
|
case "f": ShaderType = GalShaderType.Fragment; break;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-23 01:43:31 +00:00
|
|
|
|
using (FileStream FS = new FileStream(args[1], FileMode.Open, FileAccess.Read))
|
2018-05-17 18:25:42 +00:00
|
|
|
|
{
|
2018-05-23 01:43:31 +00:00
|
|
|
|
Memory Mem = new Memory(FS);
|
2018-05-17 18:25:42 +00:00
|
|
|
|
|
2018-05-23 01:43:31 +00:00
|
|
|
|
GlslProgram Program = Decompiler.Decompile(Mem, 0, ShaderType);
|
2018-05-17 18:25:42 +00:00
|
|
|
|
|
2018-05-23 01:43:31 +00:00
|
|
|
|
Console.WriteLine(Program.Code);
|
|
|
|
|
}
|
2018-05-17 18:25:42 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-06-11 00:46:42 +00:00
|
|
|
|
Console.WriteLine("Usage: Ryujinx.ShaderTools [v|tc|te|g|f] shader.bin");
|
2018-05-17 18:25:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|