Exemplo n.º 1
0
        private ShaderStage ShaderStageFactory(
            IGalMemory Memory,
            long Position,
            long PositionB,
            bool IsDualVp,
            GalShaderType Type)
        {
            GlslProgram Program;

            GlslDecompiler Decompiler = new GlslDecompiler();

            if (IsDualVp)
            {
                ShaderDumper.Dump(Memory, Position, Type, "a");
                ShaderDumper.Dump(Memory, PositionB, Type, "b");

                Program = Decompiler.Decompile(
                    Memory,
                    Position,
                    PositionB,
                    Type);
            }
            else
            {
                ShaderDumper.Dump(Memory, Position, Type);

                Program = Decompiler.Decompile(Memory, Position, Type);
            }

            return(new ShaderStage(
                       Type,
                       Program.Code,
                       Program.Textures,
                       Program.Uniforms));
        }
Exemplo n.º 2
0
        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");
            }
        }
Exemplo n.º 3
0
        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");
            }
        }
Exemplo n.º 4
0
        private OglShaderStage ShaderStageFactory(
            IGalMemory memory,
            long position,
            long positionB,
            bool isDualVp,
            GalShaderType type)
        {
            GlslProgram program;

            GlslDecompiler decompiler = new GlslDecompiler(OglLimit.MaxUboSize, OglExtension.NvidiaDriver);

            int shaderDumpIndex = ShaderDumper.DumpIndex;

            if (isDualVp)
            {
                ShaderDumper.Dump(memory, position, type, "a");
                ShaderDumper.Dump(memory, positionB, type, "b");

                program = decompiler.Decompile(memory, position, positionB, type);
            }
            else
            {
                ShaderDumper.Dump(memory, position, type);

                program = decompiler.Decompile(memory, position, type);
            }

            string code = program.Code;

            if (ShaderDumper.IsDumpEnabled())
            {
                code = "//Shader " + shaderDumpIndex + Environment.NewLine + code;
            }

            return(new OglShaderStage(type, code, program.Uniforms, program.Textures));
        }
Exemplo n.º 5
0
        private OGLShaderStage ShaderStageFactory(
            IGalMemory Memory,
            long Position,
            long PositionB,
            bool IsDualVp,
            GalShaderType Type)
        {
            GlslProgram Program;

            GlslDecompiler Decompiler = new GlslDecompiler(OGLLimit.MaxUboSize);

            int ShaderDumpIndex = ShaderDumper.DumpIndex;

            if (IsDualVp)
            {
                ShaderDumper.Dump(Memory, Position, Type, "a");
                ShaderDumper.Dump(Memory, PositionB, Type, "b");

                Program = Decompiler.Decompile(Memory, Position, PositionB, Type);
            }
            else
            {
                ShaderDumper.Dump(Memory, Position, Type);

                Program = Decompiler.Decompile(Memory, Position, Type);
            }

            string Code = Program.Code;

            if (ShaderDumper.IsDumpEnabled())
            {
                Code = "//Shader " + ShaderDumpIndex + Environment.NewLine + Code;
            }

            return(new OGLShaderStage(Type, Code, Program.Uniforms, Program.Textures));
        }
Exemplo n.º 6
0
        private GlslProgram GetGlslProgram(byte[] Data, GalShaderType Type)
        {
            int[] Code = new int[(Data.Length - 0x50) >> 2];

            using (MemoryStream MS = new MemoryStream(Data))
            {
                MS.Seek(0x50, SeekOrigin.Begin);

                BinaryReader Reader = new BinaryReader(MS);

                for (int Index = 0; Index < Code.Length; Index++)
                {
                    Code[Index] = Reader.ReadInt32();
                }
            }

            GlslDecompiler Decompiler = new GlslDecompiler();

            return(Decompiler.Decompile(Code, Type));
        }
Exemplo n.º 7
0
        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");
            }
        }
Exemplo n.º 8
0
        private GlslProgram GetGlslProgram(IGalMemory Memory, long Position, GalShaderType Type)
        {
            GlslDecompiler Decompiler = new GlslDecompiler();

            return(Decompiler.Decompile(Memory, Position + 0x50, Type));
        }
Exemplo n.º 9
0
        public void Create(
            long KeyA,
            long KeyB,
            byte[]        BinaryA,
            byte[]        BinaryB,
            GalShaderType Type)
        {
            long Key = KeyB;

            if (Stages.TryGetValue(Key, out List <OGLShaderStage> Cache))
            {
                OGLShaderStage CachedStage = Cache.Find((OGLShaderStage Stage) => Stage.EqualsBinary(BinaryA, BinaryB));

                if (CachedStage != null)
                {
                    TopStages[Key] = CachedStage;

                    return;
                }
            }
            else
            {
                Cache = new List <OGLShaderStage>();

                Stages.Add(Key, Cache);
            }

            GlslProgram Program;

            GlslDecompiler Decompiler = new GlslDecompiler();

            if (BinaryA != null)
            {
                ShaderHelper.Dump(BinaryA, Type, "a");
                ShaderHelper.Dump(BinaryB, Type, "b");

                Program = Decompiler.Decompile(BinaryA, BinaryB, Type);
            }
            else
            {
                ShaderHelper.Dump(BinaryB, Type);

                Program = Decompiler.Decompile(BinaryB, Type);
            }

            OGLShaderStage NewStage = new OGLShaderStage(
                Type,
                BinaryA,
                BinaryB,
                Program.Code,
                Program.Uniforms,
                Program.Textures);

            Cache.Add(NewStage);

            TopStages[Key] = NewStage;

            if (BinaryA != null)
            {
                TopStageSizes[KeyA] = BinaryA.Length;
            }

            TopStageSizes[KeyB] = BinaryB.Length;
        }