コード例 #1
0
        bool ReadCommentToken(DebugBytecodeReader reader)
        {
            var fourCC = reader.PeekUInt32Ahead(4);

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

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

            reader.AddNote("TokenSize", size);
            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);
        }
コード例 #2
0
        public static DebugBytecodeChunk Parse(DebugBytecodeReader reader, uint chunkSize)
        {
            var size  = chunkSize / sizeof(uint);
            var magic = reader.PeekUInt32Ahead(8);

            if (magic == "DXIL".ToFourCc())
            {
                return(Dxil.DebugDxilReflectionChunk.Parse(reader, chunkSize));
            }
            var result = new DebugStatisticsChunk
            {
                InstructionCount            = reader.ReadUInt32("InstructionCount"),
                TempRegisterCount           = reader.ReadUInt32("TempRegisterCount"),
                DefineCount                 = reader.ReadUInt32("DefineCount"),
                DeclarationCount            = reader.ReadUInt32("DeclarationCount"),
                FloatInstructionCount       = reader.ReadUInt32("FloatInstructionCount"),
                IntInstructionCount         = reader.ReadUInt32("IntInstructionCount"),
                UIntInstructionCount        = reader.ReadUInt32("UIntInstructionCount"),
                StaticFlowControlCount      = reader.ReadUInt32("StaticFlowControlCount"),
                DynamicFlowControlCount     = reader.ReadUInt32("DynamicFlowControlCount"),
                MacroInstructionCount       = reader.ReadUInt32("MacroInstructionCount"),           // Guessed
                TempArrayCount              = reader.ReadUInt32("TempArrayCount"),
                ArrayInstructionCount       = reader.ReadUInt32("ArrayInstructionCount"),
                CutInstructionCount         = reader.ReadUInt32("CutInstructionCount"),
                EmitInstructionCount        = reader.ReadUInt32("EmitInstructionCount"),
                TextureNormalInstructions   = reader.ReadUInt32("TextureNormalInstructions"),
                TextureLoadInstructions     = reader.ReadUInt32("TextureLoadInstructions"),
                TextureCompInstructions     = reader.ReadUInt32("TextureCompInstructions"),
                TextureBiasInstructions     = reader.ReadUInt32("TextureBiasInstructions"),
                TextureGradientInstructions = reader.ReadUInt32("TextureGradientInstructions"),
                MovInstructionCount         = reader.ReadUInt32("MovInstructionCount"),
                MovCInstructionCount        = reader.ReadUInt32("MovCInstructionCount"),
                ConversionInstructionCount  = reader.ReadUInt32("ConversionInstructionCount")
            };

            //TODO
            var unknown0 = reader.ReadUInt32("StatisticsChunkUnknown0");

            result.InputPrimitive = (Primitive)reader.ReadUInt32("InputPrimitive");
            result.GeometryShaderOutputTopology       = reader.ReadEnum32 <PrimitiveTopology>("GeometryShaderOutputTopology");
            result.GeometryShaderMaxOutputVertexCount = reader.ReadUInt32("GeometryShaderMaxOutputVertexCount");

            var unknown1 = reader.ReadUInt32("StatisticsChunkUnknown1");
            //if (unknown1 == 0 || unknown1 == 1 || unknown1 == 3) throw new System.Exception($"unknown1 is {unknown1}");
            //TODO: CheckAccessFullyMapped textures have large unknown1
            //Texture_Texture2D, Texture_Texture2DArray, Texture_TextureCube, Texture_TextureCubeArray

            var unknown2 = reader.ReadUInt32("StatisticsChunkUnknown2");

            //if (unknown2 != 0 && unknown2 != 2) throw new System.Exception($"unknown2 is {unknown2}");

            result.IsSampleFrequencyShader = (reader.ReadUInt32("IsSampleFrequencyShader") == 1);

            // DX10 stat size
            if (size == 29)
            {
                return(result);
            }

            result.GeometryShaderInstanceCount = reader.ReadUInt32("GeometryShaderInstanceCount");
            result.ControlPoints             = reader.ReadUInt32("ControlPoints");
            result.HullShaderOutputPrimitive = reader.ReadEnum32 <TessellatorOutputPrimitive>("HullShaderOutputPrimitive");
            result.HullShaderPartitioning    = reader.ReadEnum32 <TessellatorPartitioning>("HullShaderPartitioning");
            result.TessellatorDomain         = reader.ReadEnum32 <TessellatorDomain>("TessellatorDomain");

            result.BarrierInstructions      = reader.ReadUInt32("BarrierInstructions");
            result.InterlockedInstructions  = reader.ReadUInt32("InterlockedInstructions");
            result.TextureStoreInstructions = reader.ReadUInt32("TextureStoreInstructions");

            // DX11 stat size.
            if (size == 37)
            {
                return(result);
            }

            throw new ParseException("Unhandled stat size: " + chunkSize);
        }