private void RefreshRegisterDump() { var drawCall = GetSelectedDrawCall(); if (_ColoredRegItems == null) { _ColoredRegItems = new List <ListViewItem>(); } foreach (var listItem in _ColoredRegItems) { listItem.ForeColor = Color.Black; } _ColoredRegItems.Clear(); if (drawCall != null) { listAllRegs.BeginUpdate(); for (UInt32 i = 0; i < _RegInfos._Info.Count; ++i) { var item = _RegInfos._Info[(int)i]; var incomingValue = drawCall.CapturedState.Reg(item.Index); if (incomingValue != _RegCurrentValues[i]) { _RegCurrentValues[i] = incomingValue; var listItem = listAllRegs.Items[(int)i]; if (item.Type == GPURegisterValueType.DataDWord) { listItem.SubItems[2].Text = incomingValue.ToString(); listItem.SubItems[3].Text = String.Format("0x{0:X8}", incomingValue); } else { listItem.SubItems[3].Text = String.Format("0x{0:X8}", incomingValue); listItem.SubItems[4].Text = GPUExecutor.ToFloat(incomingValue).ToString(); } listItem.ForeColor = Color.Red; _ColoredRegItems.Add(listItem); } } listAllRegs.EndUpdate(); } }
private void RefreshUsedConsts(GPUShader shader, GPUStateCapture state, ListView view) { view.BeginUpdate(); view.Items.Clear(); foreach (UInt32 baseRegIndex in shader.UsedRegisters) { var item = new ListViewItem(); item.Text = baseRegIndex.ToString(); var stateRegOffset = baseRegIndex + (shader.PixelShader ? 256U : 0); var stateRegIndex = (UInt32)GPURegisterName.SHADER_CONSTANT_000_X + (4 * stateRegOffset); var varR = GPUExecutor.ToFloat(state.Reg(stateRegIndex + 0)); var varG = GPUExecutor.ToFloat(state.Reg(stateRegIndex + 1)); var varB = GPUExecutor.ToFloat(state.Reg(stateRegIndex + 2)); var varA = GPUExecutor.ToFloat(state.Reg(stateRegIndex + 3)); item.SubItems.Add(varR.ToString()); item.SubItems.Add(varG.ToString()); item.SubItems.Add(varB.ToString()); item.SubItems.Add(varA.ToString()); if (((varR >= 0.0f) && (varR <= 1.0f)) && ((varG >= 0.0f) && (varG <= 1.0f)) && ((varB >= 0.0f) && (varB <= 1.0f)) && ((varA >= 0.0f) && (varA <= 1.0f))) { string txt = String.Format("0x{0:X2}{1:X2}{2:X2}{3:X2}", (int)(varR * 255.0f), (int)(varG * 255.0f), (int)(varB * 255.0f), (int)(varA * 255.0f)); item.SubItems.Add(txt); var colorItem = item.SubItems.Add(" "); colorItem.BackColor = Color.FromArgb((int)(varR * 255.0f), (int)(varG * 255.0f), (int)(varB * 255.0f)); item.UseItemStyleForSubItems = false; } else { item.SubItems.Add("-"); item.SubItems.Add("-"); } view.Items.Add(item); } view.EndUpdate(); view.Refresh(); }
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); }