static void Main(string[] args) { if (args.Length == 2) { GlslDecompiler Decompiler = new GlslDecompiler(MaxUboSize); 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; } using (FileStream FS = new FileStream(args[1], FileMode.Open, FileAccess.Read)) { Memory Mem = new Memory(FS); GlslProgram Program = Decompiler.Decompile(Mem, 0, ShaderType); Console.WriteLine(Program.Code); } } else { Console.WriteLine("Usage: Ryujinx.ShaderTools [v|tc|te|g|f] shader.bin"); } }
private static ShaderProgram Translate(Operation[] ops, ShaderConfig config, int size) { BasicBlock[] blocks = ControlFlowGraph.MakeCfg(ops); if (blocks.Length > 0) { Dominance.FindDominators(blocks[0], blocks.Length); Dominance.FindDominanceFrontiers(blocks); Ssa.Rename(blocks); Optimizer.RunPass(blocks, config); Lowering.RunPass(blocks, config); } StructuredProgramInfo sInfo = StructuredProgram.MakeStructuredProgram(blocks, config); GlslProgram program = GlslGenerator.Generate(sInfo, config); ShaderProgramInfo spInfo = new ShaderProgramInfo( program.CBufferDescriptors, program.SBufferDescriptors, program.TextureDescriptors, program.ImageDescriptors, sInfo.UsesInstanceId); string glslCode = program.Code; return(new ShaderProgram(spInfo, config.Stage, glslCode, size)); }
static void Main(string[] args) { if (args.Length == 2) { GlslDecompiler Decompiler = new GlslDecompiler(); 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; } byte[] Binary = File.ReadAllBytes(args[1]); GlslProgram Program = Decompiler.Decompile(Binary, ShaderType); Console.WriteLine(Program.Code); } else { Console.WriteLine("Usage: Ryujinx.ShaderTools [v|tc|te|g|f] shader.bin"); } }
private ShaderStage ShaderStageFactory(GalShaderType Type, byte[] Data) { GlslProgram Program = GetGlslProgram(Data, Type); return(new ShaderStage( Type, Program.Code, Program.Textures, Program.Uniforms)); }
private ShaderStage ShaderStageFactory(IGalMemory Memory, long Position, GalShaderType Type) { GlslProgram Program = GetGlslProgram(Memory, Position, Type); return(new ShaderStage( Type, Program.Code, Program.Textures, Program.Uniforms)); }
static void Main(string[] args) { if (args.Length == 2) { GlslDecompiler Decompiler = new GlslDecompiler(); 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; } byte[] Data = File.ReadAllBytes(args[1]); int[] Code = new int[Data.Length / 4]; for (int Offset = 0; Offset + 4 <= Data.Length; Offset += 4) { int Value = BitConverter.ToInt32(Data, Offset); Code[Offset >> 2] = Value; } GlslProgram Program = Decompiler.Decompile(Code, ShaderType); Console.WriteLine(Program.Code); } else { Console.WriteLine("Usage: Ryushader [v|tc|te|g|f] shader.bin"); } }
public static ShaderProgram Translate( IGalMemory memory, ulong address, ulong addressB, ShaderConfig config) { Operation[] shaderOps = DecodeShader(memory, address, config.Type); if (addressB != 0) { // Dual vertex shader. Operation[] shaderOpsB = DecodeShader(memory, addressB, config.Type); shaderOps = Combine(shaderOps, shaderOpsB); } BasicBlock[] irBlocks = ControlFlowGraph.MakeCfg(shaderOps); Dominance.FindDominators(irBlocks[0], irBlocks.Length); Dominance.FindDominanceFrontiers(irBlocks); Ssa.Rename(irBlocks); Optimizer.Optimize(irBlocks); StructuredProgramInfo sInfo = StructuredProgram.MakeStructuredProgram(irBlocks); GlslProgram program = GlslGenerator.Generate(sInfo, config); ShaderProgramInfo spInfo = new ShaderProgramInfo( program.CBufferDescriptors, program.TextureDescriptors); return(new ShaderProgram(spInfo, program.Code)); }
internal static ShaderProgram Translate(FunctionCode[] functions, ShaderConfig config, out ShaderProgramInfo shaderProgramInfo, int sizeA = 0) { var cfgs = new ControlFlowGraph[functions.Length]; var frus = new RegisterUsage.FunctionRegisterUsage[functions.Length]; for (int i = 0; i < functions.Length; i++) { cfgs[i] = ControlFlowGraph.Create(functions[i].Code); if (i != 0) { frus[i] = RegisterUsage.RunPass(cfgs[i]); } } Function[] funcs = new Function[functions.Length]; for (int i = 0; i < functions.Length; i++) { var cfg = cfgs[i]; int inArgumentsCount = 0; int outArgumentsCount = 0; if (i != 0) { var fru = frus[i]; inArgumentsCount = fru.InArguments.Length; outArgumentsCount = fru.OutArguments.Length; } if (cfg.Blocks.Length != 0) { RegisterUsage.FixupCalls(cfg.Blocks, frus); Dominance.FindDominators(cfg); Dominance.FindDominanceFrontiers(cfg.Blocks); Ssa.Rename(cfg.Blocks); Optimizer.RunPass(cfg.Blocks, config); Rewriter.RunPass(cfg.Blocks, config); } funcs[i] = new Function(cfg.Blocks, $"fun{i}", false, inArgumentsCount, outArgumentsCount); } StructuredProgramInfo sInfo = StructuredProgram.MakeStructuredProgram(funcs, config); GlslProgram program = GlslGenerator.Generate(sInfo, config); shaderProgramInfo = new ShaderProgramInfo( program.CBufferDescriptors, program.SBufferDescriptors, program.TextureDescriptors, program.ImageDescriptors, sInfo.UsesInstanceId); string glslCode = program.Code; return(new ShaderProgram(config.Stage, glslCode, config.Size, sizeA)); }