Example #1
0
        public static ParsedPacket Parse(RawPacket raw, int packetIndex, ParsedDrawCall drawcall, GPUCommandOutput commandOutput)
        {
            ParsedPacket ret = new ParsedPacket();

            ret._Raw       = raw;
            ret._Index     = packetIndex;
            ret._DrawCall  = drawcall;
            ret._CmdOutput = commandOutput;

            if (drawcall != null)
            {
                drawcall.Linkup(ret);
            }


            return(ret);
        }
Example #2
0
 public TreeNode_DrawCall(ParsedDrawCall drawCall)
 {
     Text      = drawCall.ToString();
     _DrawCall = drawCall;
 }
Example #3
0
 public void AddDrawCall(ParsedDrawCall dc)
 {
     _DrawCalls.Add(dc);
 }
Example #4
0
        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);
        }