public ShaderViewer(Core core, bool custom, string entry, Dictionary<string, string> files, SaveMethod saveCallback, CloseMethod closeCallback) { InitializeComponent(); constantRegs.Font = variableRegs.Font = watchRegs.Font = inSig.Font = outSig.Font = core.Config.PreferredFont; Icon = global::renderdocui.Properties.Resources.icon; this.SuspendLayout(); mainLayout.Dock = DockStyle.Fill; snippetDropDown.Visible = custom; debuggingStrip.Visible = false; inSigBox.Visible = false; outSigBox.Visible = false; m_Core = core; m_SaveCallback = saveCallback; m_CloseCallback = closeCallback; if (m_Core.LogLoaded) pointLinearSamplersToolStripMenuItem.Visible = (m_Core.APIProps.pipelineType == APIPipelineStateType.D3D11); DockContent sel = null; foreach (var f in files) { var name = f.Key; ScintillaNET.Scintilla scintilla1 = MakeEditor("scintilla" + name, f.Value, true); scintilla1.IsReadOnly = false; scintilla1.Tag = name; scintilla1.PreviewKeyDown += new PreviewKeyDownEventHandler(scintilla1_PreviewKeyDown); scintilla1.KeyDown += new KeyEventHandler(editScintilla_KeyDown); m_Scintillas.Add(scintilla1); var w = Helpers.WrapDockContent(dockPanel, scintilla1, name); w.CloseButton = false; w.CloseButtonVisible = false; w.Show(dockPanel); if (f.Value.Contains(entry)) sel = w; Text = string.Format("{0} - Edit ({1})", entry, f.Key); } m_FindAll = new FindAllDialog(FindAllFiles); m_FindAll.Hide(); if (files.Count > 3) AddFileList(); if (sel != null) sel.Show(); ShowConstants(); ShowVariables(); ShowWatch(); ShowErrors(); { m_ConstantsDock.Hide(); m_VariablesDock.Hide(); m_WatchDock.Hide(); } this.ResumeLayout(false); }
public ShaderViewer(Core core, ShaderReflection shader, ShaderStageType stage, ShaderDebugTrace trace, string debugContext) { InitializeComponent(); constantRegs.Font = variableRegs.Font = watchRegs.Font = inSig.Font = outSig.Font = core.Config.PreferredFont; Icon = global::renderdocui.Properties.Resources.icon; this.SuspendLayout(); mainLayout.Dock = DockStyle.Fill; constantRegs.Font = variableRegs.Font = watchRegs.Font = inSig.Font = outSig.Font = core.Config.PreferredFont; m_Core = core; m_ShaderDetails = shader; m_Trace = trace; m_Stage = null; switch (stage) { case ShaderStageType.Vertex: m_Stage = m_Core.CurD3D11PipelineState.m_VS; break; case ShaderStageType.Domain: m_Stage = m_Core.CurD3D11PipelineState.m_DS; break; case ShaderStageType.Hull: m_Stage = m_Core.CurD3D11PipelineState.m_HS; break; case ShaderStageType.Geometry: m_Stage = m_Core.CurD3D11PipelineState.m_GS; break; case ShaderStageType.Pixel: m_Stage = m_Core.CurD3D11PipelineState.m_PS; break; case ShaderStageType.Compute: m_Stage = m_Core.CurD3D11PipelineState.m_CS; break; } if (trace != null) Text = String.Format("Debugging {0} - {1}", m_Core.CurPipelineState.GetShaderName(stage), debugContext); else Text = m_Core.CurPipelineState.GetShaderName(stage); var disasm = shader.Disassembly; if (m_Core.Config.ShaderViewer_FriendlyNaming) { for (int i = 0; i < m_ShaderDetails.ConstantBlocks.Length; i++) { var stem = string.Format("cb{0}", i); var cbuf = m_ShaderDetails.ConstantBlocks[i]; if (cbuf.variables.Length == 0) continue; disasm = FriendlyName(disasm, stem, "", cbuf.variables); } foreach (var r in m_ShaderDetails.Resources) { if (r.IsSRV) { var needle = string.Format(", t{0}([^0-9])", r.bindPoint); var replacement = string.Format(", {0}$1", r.name); Regex rgx = new Regex(needle); disasm = rgx.Replace(disasm, replacement); } if (r.IsSampler) { var needle = string.Format(", s{0}([^0-9])", r.bindPoint); var replacement = string.Format(", {0}$1", r.name); Regex rgx = new Regex(needle); disasm = rgx.Replace(disasm, replacement); } if (r.IsReadWrite) { var needle = string.Format(", u{0}([^0-9])", r.bindPoint); var replacement = string.Format(", {0}$1", r.name); Regex rgx = new Regex(needle); disasm = rgx.Replace(disasm, replacement); } } } { m_DisassemblyView = MakeEditor("scintillaDisassem", disasm, false); m_DisassemblyView.IsReadOnly = true; m_DisassemblyView.TabIndex = 0; m_DisassemblyView.KeyDown += new KeyEventHandler(m_DisassemblyView_KeyDown); m_DisassemblyView.KeyDown += new KeyEventHandler(readonlyScintilla_KeyDown); m_DisassemblyView.Markers[CURRENT_MARKER].BackColor = System.Drawing.Color.LightCoral; m_DisassemblyView.Markers[CURRENT_MARKER].Symbol = ScintillaNET.MarkerSymbol.Background; m_DisassemblyView.Markers[CURRENT_MARKER+1].BackColor = System.Drawing.Color.LightCoral; m_DisassemblyView.Markers[CURRENT_MARKER+1].Symbol = ScintillaNET.MarkerSymbol.ShortArrow; CurrentLineMarkers.Add(CURRENT_MARKER); CurrentLineMarkers.Add(CURRENT_MARKER+1); m_DisassemblyView.Markers[FINISHED_MARKER].BackColor = System.Drawing.Color.LightSlateGray; m_DisassemblyView.Markers[FINISHED_MARKER].Symbol = ScintillaNET.MarkerSymbol.Background; m_DisassemblyView.Markers[FINISHED_MARKER + 1].BackColor = System.Drawing.Color.LightSlateGray; m_DisassemblyView.Markers[FINISHED_MARKER + 1].Symbol = ScintillaNET.MarkerSymbol.RoundRectangle; FinishedMarkers.Add(FINISHED_MARKER); FinishedMarkers.Add(FINISHED_MARKER + 1); m_DisassemblyView.Markers[BREAKPOINT_MARKER].BackColor = System.Drawing.Color.Red; m_DisassemblyView.Markers[BREAKPOINT_MARKER].Symbol = ScintillaNET.MarkerSymbol.Background; m_DisassemblyView.Markers[BREAKPOINT_MARKER+1].BackColor = System.Drawing.Color.Red; m_DisassemblyView.Markers[BREAKPOINT_MARKER+1].Symbol = ScintillaNET.MarkerSymbol.Circle; BreakpointMarkers.Add(BREAKPOINT_MARKER); BreakpointMarkers.Add(BREAKPOINT_MARKER + 1); if (trace != null) { m_DisassemblyView.ContextMenu = AssemblyContextMenu(); m_DisassemblyView.MouseDown += new MouseEventHandler(contextMouseDown); } m_Scintillas.Add(m_DisassemblyView); var w = Helpers.WrapDockContent(dockPanel, m_DisassemblyView, "Disassembly"); w.DockState = DockState.Document; w.Show(); w.CloseButton = false; w.CloseButtonVisible = false; } if (shader.DebugInfo.entryFunc.Length > 0 && shader.DebugInfo.files.Length > 0) { if(trace != null) Text = String.Format("Debug {0}() - {1}", shader.DebugInfo.entryFunc, debugContext); else Text = String.Format("{0}()", shader.DebugInfo.entryFunc); int fileIdx = 0; DockContent sel = null; foreach (var f in shader.DebugInfo.files) { var name = f.BaseFilename; ScintillaNET.Scintilla scintilla1 = MakeEditor("scintilla" + name, f.filetext, true); scintilla1.IsReadOnly = true; scintilla1.Tag = name; scintilla1.KeyDown += new KeyEventHandler(readonlyScintilla_KeyDown); var w = Helpers.WrapDockContent(dockPanel, scintilla1, name); w.CloseButton = false; w.CloseButtonVisible = false; w.Show(dockPanel); m_Scintillas.Add(scintilla1); if (shader.DebugInfo.entryFile >= 0 && shader.DebugInfo.entryFile < shader.DebugInfo.files.Length) { if (fileIdx == shader.DebugInfo.entryFile) sel = w; } else if (f.filetext.Contains(shader.DebugInfo.entryFunc)) { sel = w; } fileIdx++; } if (shader.DebugInfo.files.Length > 2) AddFileList(); if (trace != null || sel == null) sel = (DockContent)m_DisassemblyView.Parent; sel.Show(); } m_FindAll = new FindAllDialog(FindAllFiles); m_FindAll.Hide(); ShowConstants(); ShowVariables(); ShowWatch(); ShowErrors(); editStrip.Visible = false; m_ErrorsDock.Hide(); if (trace == null) { debuggingStrip.Visible = false; m_ConstantsDock.Hide(); m_VariablesDock.Hide(); m_WatchDock.Hide(); var insig = Helpers.WrapDockContent(dockPanel, inSigBox); insig.CloseButton = insig.CloseButtonVisible = false; var outsig = Helpers.WrapDockContent(dockPanel, outSigBox); outsig.CloseButton = outsig.CloseButtonVisible = false; insig.Show(dockPanel, DockState.DockBottom); outsig.Show(insig.Pane, DockAlignment.Right, 0.5); foreach (var s in m_ShaderDetails.InputSig) { string name = s.varName.Length == 0 ? s.semanticName : String.Format("{0} ({1})", s.varName, s.semanticName); if (s.semanticName.Length == 0) name = s.varName; inSig.Nodes.Add(new object[] { name, s.semanticIndex, s.regIndex, s.TypeString, s.systemValue.ToString(), SigParameter.GetComponentString(s.regChannelMask), SigParameter.GetComponentString(s.channelUsedMask) }); } bool multipleStreams = false; for (int i = 0; i < m_ShaderDetails.OutputSig.Length; i++) { if (m_ShaderDetails.OutputSig[i].stream > 0) { multipleStreams = true; break; } } foreach (var s in m_ShaderDetails.OutputSig) { string name = s.varName.Length == 0 ? s.semanticName : String.Format("{0} ({1})", s.varName, s.semanticName); if (s.semanticName.Length == 0) name = s.varName; if(multipleStreams) name = String.Format("Stream {0} : {1}", s.stream, name); outSig.Nodes.Add(new object[] { name, s.semanticIndex, s.regIndex, s.TypeString, s.systemValue.ToString(), SigParameter.GetComponentString(s.regChannelMask), SigParameter.GetComponentString(s.channelUsedMask) }); } } else { inSigBox.Visible = false; outSigBox.Visible = false; m_DisassemblyView.Margins.Margin1.Width = 20; m_DisassemblyView.Margins.Margin2.Width = 0; m_DisassemblyView.Margins.Margin3.Width = 20; m_DisassemblyView.Margins.Margin3.IsMarkerMargin = true; m_DisassemblyView.Margins.Margin3.IsFoldMargin = false; m_DisassemblyView.Margins.Margin3.Type = ScintillaNET.MarginType.Symbol; m_DisassemblyView.Margins.Margin1.Mask = (int)m_DisassemblyView.Markers[BREAKPOINT_MARKER + 1].Mask; m_DisassemblyView.Margins.Margin3.Mask &= ~((int)m_DisassemblyView.Markers[BREAKPOINT_MARKER + 1].Mask); m_DisassemblyView.MouseMove += new MouseEventHandler(scintilla1_MouseMove); m_DisassemblyView.Leave += new EventHandler(scintilla1_Leave); m_DisassemblyView.KeyDown += new KeyEventHandler(scintilla1_DebuggingKeyDown); watchRegs.Items.Add(new ListViewItem(new string[] { "", "", "" })); } CurrentStep = 0; this.ResumeLayout(false); }