public TreeNode_DrawGroup(ParsedDrawGroup drawGroup) { Text = drawGroup.ToString(); _DrawGroup = drawGroup; foreach (var drawCall in drawGroup.DrawCalls) { this.Nodes.Add(new TreeNode_DrawCall(drawCall)); } }
static public ParsedData Parse(RawDumpData raw) { ParsedData ret = new ParsedData(); var packetsMap = new Dictionary <RawPacket, ParsedPacket>(); // create drawcall list ret._ShaderCache = new GPUShaderCache(); ret._DrawCalls = new List <ParsedDrawCall>(); ret._DrawGroups = new List <ParsedDrawGroup>(); // prepare GPU state for the duration of parsing GPUState parseState = new GPUState(ret._ShaderCache); GPUExecutor parseExec = new GPUExecutor(parseState); // parse all packets int packedIndex = 1; int drawCallIndex = 1; int drawGroupIndex = 1; ParsedDrawCall drawCall = null; ParsedDrawGroup drawGroup = null; foreach (var rawPacket in raw.Packets) { // start new drawcall if (drawCall == null) { drawCall = new ParsedDrawCall(drawCallIndex); ret._DrawCalls.Add(drawCall); drawCallIndex += 1; } // execute packet GPUCommandOutput executeOutput = new GPUCommandOutput(); var executionResult = parseExec.ExecutePacket(rawPacket, executeOutput); if (executionResult != GPUExecutorResult.Invalid) { // add data packetsMap[rawPacket] = ParsedPacket.Parse(rawPacket, packedIndex, drawCall, executeOutput); ++packedIndex; } // restart after each drawcall if (packetsMap[rawPacket].Output.IsDraw()) { // capture final state at each drawcall if (drawCall != null) { drawCall.CapturedState = new GPUStateCapture(parseState); // extract the viewport/render target settings for the draw call - required to match it to the draw group var stateRenderTargets = new GPUStateRenderTargets(drawCall.CapturedState); var stateViewport = new GPUStateCaptureViewport(drawCall.CapturedState); // determine if we should add this draw call to current draw group if ((drawGroup != null) && drawGroup.Compatible(stateViewport, stateRenderTargets)) { drawGroup.AddDrawCall(drawCall); } else { drawGroup = new ParsedDrawGroup(drawGroupIndex++, stateViewport, stateRenderTargets); drawGroup.AddDrawCall(drawCall); ret._DrawGroups.Add(drawGroup); } } // reset drawCall = null; } } return(ret); }