private void SelectInstruction(IInstruction op) { InstructionWidget widget = m_InstructionWidgets[op]; m_SelectedOps.Add(widget); widget.Selected = true; widget.Refresh(); }
public void AddInstructionToPanel(InstructionWidget widget, IInstruction op) { m_InstructionIndexMap.Add(op, m_InstructionWidgets.Count); m_InstructionWidgets.Add(op, widget); widget.Click += delegate(object s, EventArgs e) { this.OnInstructionClick(widget, e as MouseEventArgs); }; // change format on all selected instructions whenever one of them is changed widget.TexelFormatChanged += delegate(ITextureInstruction inst) { if (!widget.Selected) { return; } foreach (InstructionWidget s in m_SelectedOps) { ITextureInstruction tx = s.Instruction as ITextureInstruction; if (tx != null && tx != inst) { tx.Format = inst.Format; } s.RefreshInstruction(); } }; // change filter on all selected instructions whenever one of them is changed widget.FilterChanged += delegate(ISamplingInstruction inst) { if (!widget.Selected) { return; } foreach (InstructionWidget s in m_SelectedOps) { ISamplingInstruction tx = s.Instruction as ISamplingInstruction; if (tx != null && tx != inst) { tx.Filter = inst.Filter; } s.RefreshInstruction(); } }; panel1.Controls.Add(widget); }
public ScrutinizerForm( IAMDShader sh ) { InitializeComponent(); try { Wrapper w = new Wrapper(); m_Backend = sh.CreateScrutinizer(); List<IInstruction> Ops = m_Backend.BuildProgram(); m_Ops = Ops; m_Blocks = Algorithms.BuildBasicBlocks(Ops); if (!Algorithms.IsCFGReducible(m_Blocks)) { MessageBox.Show("Non-reducible flow-graph detected. Can't analyze this."); return; } Algorithms.FindDominators(m_Blocks); m_Loops = Algorithms.FindLoops(m_Blocks); Algorithms.ClassifyBranches(m_Ops); int Y = 0; foreach (BasicBlock b in m_Blocks) { foreach (IInstruction op in b.Instructions) { InstructionWidget widget = new InstructionWidget(op); m_Instructions.Add(op, widget); panel1.Controls.Add(widget); widget.Top = Y; widget.Left = 0; Y += widget.Height; } Y += 15; } cfgWidget1.SetProgram(m_Loops, m_Blocks); } catch( System.Exception ex ) { MessageBox.Show(ex.Message); } }
private void OnInstructionClick(InstructionWidget w, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (Form.ModifierKeys == Keys.Control) { // ctrl+click: toggle state of one widget w.Selected = !w.Selected; w.Refresh(); if (w.Selected) { m_SelectedOps.Add(w); } else { m_SelectedOps.Remove(w); } } else if (Form.ModifierKeys == Keys.Shift && m_LastClicked != null) { // shift+click: select everything between last clicked widget // and current widget int i = m_InstructionIndexMap[m_LastClicked.Instruction]; int j = m_InstructionIndexMap[w.Instruction]; int first = Math.Min(i, j); int last = Math.Max(i, j); for (int x = first; x <= last; x++) { SelectInstruction(m_Ops[x]); } } else { // unmodified click. Select only the clicked widget ClearSelectedInstructions(); SelectInstruction(w.Instruction); } m_LastClicked = w; } else if (e.Button == MouseButtons.Right) { // de-select everything on a right click ClearSelectedInstructions(); } }
private void OnInstructionClick( InstructionWidget w, MouseEventArgs e ) { if (e.Button == MouseButtons.Left) { if (Form.ModifierKeys == Keys.Control) { // ctrl+click: toggle state of one widget w.Selected = !w.Selected; w.Refresh(); if (w.Selected) m_SelectedOps.Add(w); else m_SelectedOps.Remove(w); } else if( Form.ModifierKeys == Keys.Shift && m_LastClicked != null ) { // shift+click: select everything between last clicked widget // and current widget int i = m_InstructionIndexMap[m_LastClicked.Instruction]; int j = m_InstructionIndexMap[w.Instruction]; int first = Math.Min(i, j); int last = Math.Max(i, j); for (int x = first; x <= last; x++) SelectInstruction(m_Ops[x]); } else { // unmodified click. Select only the clicked widget ClearSelectedInstructions(); SelectInstruction(w.Instruction); } m_LastClicked = w; } else if (e.Button == MouseButtons.Right) { // de-select everything on a right click ClearSelectedInstructions(); } }
public ScrutinizerForm( IAMDShader sh, IDXShaderReflection reflection) { InitializeComponent(); m_Reflection = reflection; switch( reflection.GetShaderType() ) { case HLSLShaderType.VERTEX: txtACMR.Enabled = true; txtPixels.Enabled = false; break; case HLSLShaderType.PIXEL: txtACMR.Enabled = false; txtPixels.Enabled = true; break; } try { Wrapper w = new Wrapper(); m_Backend = sh.CreateScrutinizer(); txtOccupancy.Text = m_Backend.GetDefaultOccupancy().ToString(); List<IInstruction> Ops = m_Backend.BuildProgram(); m_Ops = Ops; m_Blocks = Algorithms.BuildBasicBlocks(Ops); if (!Algorithms.IsCFGReducible(m_Blocks)) { MessageBox.Show("Non-reducible flow-graph detected. Can't analyze this."); return; } Algorithms.FindDominators(m_Blocks); m_Loops = Algorithms.FindLoops(m_Blocks); Algorithms.ClassifyBranches(m_Ops); Algorithms.AssignLabels(m_Ops); int Y = 0; if( reflection.GetShaderType() == HLSLShaderType.VERTEX ) { m_FetchShader = m_Backend.BuildDXFetchShader(reflection); Label l0 = new Label(); Label l1 = new Label(); l0.AutoSize = true; l1.AutoSize = true; l0.Text = "*** INSTRUCTIONS BELOW ARE AN APPROXIMATION TO THE FETCH SHADER***"; l1.Text = "******************************************************************"; l0.Left = 128; l1.Left = 128; panel1.Controls.Add(l0); Y = l0.Height; foreach( IInstruction op in m_FetchShader ) { InstructionWidget widget = new InstructionWidget(op); AddInstructionToPanel(widget, op); widget.Top = Y; widget.Left = 0; Y += widget.Height; } l1.Top = Y; panel1.Controls.Add(l1); Y += l1.Height; } foreach (BasicBlock b in m_Blocks) { foreach (IInstruction op in b.Instructions) { if( !String.IsNullOrEmpty(op.Label)) { Label l = new Label(); l.Font = new Font("Lucida Console", 8); l.AutoSize = true; l.Text = op.Label; l.Left = 100; l.Top = Y; panel1.Controls.Add(l); Y += l.Height; } InstructionWidget widget = new InstructionWidget(op); AddInstructionToPanel(widget, op); widget.Top = Y; widget.Left = 0; Y += widget.Height; } Y += 15; } cfgWidget1.SetProgram(m_Loops, m_Blocks); MarkExecutedInstructions(); } catch( System.Exception ex ) { MessageBox.Show(ex.Message); } }
public void AddInstructionToPanel( InstructionWidget widget, IInstruction op ) { m_InstructionIndexMap.Add(op, m_InstructionWidgets.Count); m_InstructionWidgets.Add(op, widget); widget.Click += delegate(object s, EventArgs e) { this.OnInstructionClick(widget, e as MouseEventArgs); }; // change format on all selected instructions whenever one of them is changed widget.TexelFormatChanged += delegate(ITextureInstruction inst ) { if (!widget.Selected) return; foreach( InstructionWidget s in m_SelectedOps ) { ITextureInstruction tx = s.Instruction as ITextureInstruction; if( tx != null && tx != inst ) tx.Format = inst.Format; s.RefreshInstruction(); } }; // change filter on all selected instructions whenever one of them is changed widget.FilterChanged += delegate(ISamplingInstruction inst) { if (!widget.Selected) return; foreach (InstructionWidget s in m_SelectedOps) { ISamplingInstruction tx = s.Instruction as ISamplingInstruction; if (tx != null && tx != inst) tx.Filter = inst.Filter; s.RefreshInstruction(); } }; panel1.Controls.Add(widget); }
public ScrutinizerForm(List <IInstruction> FetchShader, List <IInstruction> Shader, IScrutinizer backend) { InitializeComponent(); m_Backend = backend; m_FetchShader = FetchShader; m_Ops = Shader; try { Wrapper w = new Wrapper(); List <IInstruction> Ops = m_Backend.BuildProgram(); m_Ops = Ops; m_Blocks = Algorithms.BuildBasicBlocks(Ops); if (!Algorithms.IsCFGReducible(m_Blocks)) { MessageBox.Show("Non-reducible flow-graph detected. Can't analyze this."); return; } Algorithms.FindDominators(m_Blocks); m_Loops = Algorithms.FindLoops(m_Blocks); Algorithms.ClassifyBranches(m_Ops); Algorithms.AssignLabels(m_Ops); int Y = 0; if (m_FetchShader.Count > 0) { Label l0 = new Label(); Label l1 = new Label(); l0.AutoSize = true; l1.AutoSize = true; l0.Text = "*** INSTRUCTIONS BELOW ARE AN APPROXIMATION TO THE FETCH SHADER***"; l1.Text = "******************************************************************"; l0.Left = 128; l1.Left = 128; panel1.Controls.Add(l0); Y = l0.Height; foreach (IInstruction op in m_FetchShader) { InstructionWidget widget = new InstructionWidget(op); AddInstructionToPanel(widget, op); widget.Top = Y; widget.Left = 0; Y += widget.Height; } l1.Top = Y; panel1.Controls.Add(l1); Y += l1.Height; } foreach (BasicBlock b in m_Blocks) { foreach (IInstruction op in b.Instructions) { if (!String.IsNullOrEmpty(op.Label)) { Label l = new Label(); l.Font = new Font("Lucida Console", 8); l.AutoSize = true; l.Text = op.Label; l.Left = 100; l.Top = Y; panel1.Controls.Add(l); Y += l.Height; } InstructionWidget widget = new InstructionWidget(op); AddInstructionToPanel(widget, op); widget.Top = Y; widget.Left = 0; Y += widget.Height; } Y += 15; } cfgWidget1.SetProgram(m_Loops, m_Blocks); parameterWidget1.BuildUI(m_Backend.SimulationParameters); MarkExecutedInstructions(); } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
public ScrutinizerForm( List<IInstruction> FetchShader, List<IInstruction> Shader, IScrutinizer backend ) { InitializeComponent(); m_Backend = backend; m_FetchShader = FetchShader; m_Ops = Shader; try { Wrapper w = new Wrapper(); List<IInstruction> Ops = m_Backend.BuildProgram(); m_Ops = Ops; m_Blocks = Algorithms.BuildBasicBlocks(Ops); if (!Algorithms.IsCFGReducible(m_Blocks)) { MessageBox.Show("Non-reducible flow-graph detected. Can't analyze this."); return; } Algorithms.FindDominators(m_Blocks); m_Loops = Algorithms.FindLoops(m_Blocks); Algorithms.ClassifyBranches(m_Ops); Algorithms.AssignLabels(m_Ops); int Y = 0; if( m_FetchShader.Count > 0 ) { Label l0 = new Label(); Label l1 = new Label(); l0.AutoSize = true; l1.AutoSize = true; l0.Text = "*** INSTRUCTIONS BELOW ARE AN APPROXIMATION TO THE FETCH SHADER***"; l1.Text = "******************************************************************"; l0.Left = 128; l1.Left = 128; panel1.Controls.Add(l0); Y = l0.Height; foreach( IInstruction op in m_FetchShader ) { InstructionWidget widget = new InstructionWidget(op); AddInstructionToPanel(widget, op); widget.Top = Y; widget.Left = 0; Y += widget.Height; } l1.Top = Y; panel1.Controls.Add(l1); Y += l1.Height; } foreach (BasicBlock b in m_Blocks) { foreach (IInstruction op in b.Instructions) { if( !String.IsNullOrEmpty(op.Label)) { Label l = new Label(); l.Font = new Font("Lucida Console", 8); l.AutoSize = true; l.Text = op.Label; l.Left = 100; l.Top = Y; panel1.Controls.Add(l); Y += l.Height; } InstructionWidget widget = new InstructionWidget(op); AddInstructionToPanel(widget, op); widget.Top = Y; widget.Left = 0; Y += widget.Height; } Y += 15; } cfgWidget1.SetProgram(m_Loops, m_Blocks); parameterWidget1.BuildUI(m_Backend.SimulationParameters); MarkExecutedInstructions(); } catch( System.Exception ex ) { MessageBox.Show(ex.Message); } }