Esempio n. 1
0
        public static DebugConstantTable Parse(DebugBytecodeReader reader)
        {
            var result = new DebugConstantTable();

            var ctabReader         = reader.CopyAtCurrentPosition("CTabReader", reader);
            var ctabSize           = ctabReader.ReadUInt32("CtabSize");
            var creatorOffset      = ctabReader.ReadInt32("CreatorPosition");
            var minorVersion       = ctabReader.ReadByte("MinorVersion");
            var majorVersion       = ctabReader.ReadByte("MajorVersion");
            var shaderType         = ctabReader.ReadEnum16 <ShaderType>("ShaderType");
            var numConstants       = ctabReader.ReadInt32("NumConstants");
            var constantInfoOffset = ctabReader.ReadInt32("ConstantInfoOffset");
            var shaderFlags        = ctabReader.ReadEnum32 <ShaderFlags>("ShaderFlags");
            var shaderModelOffset  = ctabReader.ReadInt32("ShaderModelOffset");

            for (int i = 0; i < numConstants; i++)
            {
                var decReader = ctabReader.CopyAtOffset($"Declaration {i}", ctabReader, constantInfoOffset + i * 20);
                DebugConstantDeclaration declaration = DebugConstantDeclaration.Parse(ctabReader, decReader);
                result.ConstantDeclarations.Add(declaration);
            }

            var shaderModelReader = ctabReader.CopyAtOffset("ShaderModelReader", ctabReader, shaderModelOffset);
            var shaderModel       = shaderModelReader.ReadString("ShaderModel");

            var creatorReader = ctabReader.CopyAtOffset("CreaterReader", ctabReader, creatorOffset);
            var creatorString = creatorReader.ReadString("CreatorString");

            return(result);
        }
Esempio n. 2
0
        bool ReadCommentToken(DebugBytecodeReader reader)
        {
            var fourCC = reader.PeakUInt32Ahead(4);

            if (KnownCommentTypes.ContainsKey(fourCC))
            {
                reader.AddIndent(KnownCommentTypes[fourCC].ToString());
            }
            else
            {
                return(false);
            }
            var    instructionToken = reader.ReadUInt32("Token");
            var    startPosition    = reader._reader.BaseStream.Position;
            var    entry            = reader.Members.Last();
            Opcode opcode           = (Opcode)(instructionToken & 0xffff);

            entry.AddNote("TokenOpcode", opcode.ToString());
            var size = (int)((instructionToken >> 16) & 0x7FFF);

            entry.AddNote("TokenSize", size.ToString());
            reader.ReadBytes("FourCC", 4);

            switch (KnownCommentTypes[fourCC])
            {
            case CommentType.CTAB:
                ConstantTable = DebugConstantTable.Parse(reader);
                break;

            case CommentType.C**T:
                Cli = DebugCliToken.Parse(reader);
                break;

            case CommentType.FXLC:
                Fxlc = DebugFxlc.Parse(reader, (uint)size * 4);
                break;

            case CommentType.PRES:
                Preshader = DebugPreshader.Parse(reader);
                break;

            case CommentType.PRSI:
                Prsi = DebugPrsiToken.Parse(reader, (uint)size);
                break;

            default:
                return(false);
            }
            reader.RemoveIndent();
            reader._reader.BaseStream.Position = startPosition + size * 4;
            return(true);
        }