private void PrintBlockScope(
            ShaderIrBlock Block,
            ShaderIrBlock EndBlock,
            ShaderIrBlock LoopBlock,
            string ScopeName,
            string Identation,
            bool IsDoWhile = false)
        {
            string UpIdent = Identation.Substring(0, Identation.Length - IdentationStr.Length);

            if (IsDoWhile)
            {
                SB.AppendLine(UpIdent + "do {");
            }
            else
            {
                SB.AppendLine(UpIdent + ScopeName + " {");
            }

            while (Block != null && Block != EndBlock)
            {
                ShaderIrNode[] Nodes = Block.GetNodes();

                Block = PrintNodes(Block, EndBlock, LoopBlock, Identation, Nodes);
            }

            if (IsDoWhile)
            {
                SB.AppendLine(UpIdent + "} " + ScopeName + ";");
            }
            else
            {
                SB.AppendLine(UpIdent + "}");
            }
        }
Beispiel #2
0
        public GlslProgram Decompile(int[] Code, GalShaderType ShaderType)
        {
            ShaderIrBlock Block = ShaderDecoder.DecodeBasicBlock(Code, 0);

            ShaderIrNode[] Nodes = Block.GetNodes();

            Decl = new GlslDecl(Nodes, ShaderType);

            SB = new StringBuilder();

            SB.AppendLine("#version 410 core");

            PrintDeclTextures();
            PrintDeclUniforms();
            PrintDeclInAttributes();
            PrintDeclOutAttributes();
            PrintDeclGprs();
            PrintDeclPreds();

            PrintBlockScope("void main()", 1, Nodes);

            string GlslCode = SB.ToString();

            return(new GlslProgram(
                       GlslCode,
                       Decl.Textures.Values,
                       Decl.Uniforms.Values));
        }