Esempio n. 1
0
 public void AddResult(IAMDShader shader)
 {
     m_Shaders.Add(shader);
     cmbAsic.Items.Add(shader.Asic.Name);
     if (cmbAsic.Items.Count == 1)
         cmbAsic.SelectedIndex = 0;
 }
Esempio n. 2
0
        private string HexDump( IAMDShader sh )
        {
            byte[] bytes = sh.ReadISABytes();
            int nBytes = bytes.Length;
            StringBuilder str = new StringBuilder();

            if (nBytes % 4 == 0)
            {
                for (int i = 0; i < nBytes; i += 4)
                {
                    int n = bytes[i] |
                             bytes[i + 1] << 8 |
                             bytes[i + 2] << 16 |
                             bytes[i + 3] << 24;
                    str.AppendFormat("{0:X8} ", n);
                    str.AppendLine();
                }
            }
            else
            {
                for (int i = 0; i < nBytes; i++)
                {
                    if (i % 8 == 0)
                        str.AppendLine();
                    str.AppendFormat("{0:X2} ", bytes[i]);
                }
            }
            str.AppendLine();
            return str.ToString();
        }
Esempio n. 3
0
        private string HexDump(IAMDShader sh)
        {
            byte[]        bytes  = sh.ReadISABytes();
            int           nBytes = bytes.Length;
            StringBuilder str    = new StringBuilder();

            if (nBytes % 4 == 0)
            {
                for (int i = 0; i < nBytes; i += 4)
                {
                    int n = bytes[i] |
                            bytes[i + 1] << 8 |
                            bytes[i + 2] << 16 |
                            bytes[i + 3] << 24;
                    str.AppendFormat("{0:X8} ", n);
                    str.AppendLine();
                }
            }
            else
            {
                for (int i = 0; i < nBytes; i++)
                {
                    if (i % 8 == 0)
                    {
                        str.AppendLine();
                    }
                    str.AppendFormat("{0:X2} ", bytes[i]);
                }
            }
            str.AppendLine();
            return(str.ToString());
        }
Esempio n. 4
0
 public void AddResult(IAMDShader shader)
 {
     m_Shaders.Add(shader);
     cmbAsic.Items.Add(shader.Asic.Name);
     if (cmbAsic.Items.Count == 1)
     {
         cmbAsic.SelectedIndex = 0;
     }
 }
Esempio n. 5
0
        public IResultSet Compile(IShader shaderObj, IBackendOptions options)
        {
            if ( !(shaderObj is HLSLShader ) )
                return null;

            HLSLShader shaderHLSL = shaderObj as HLSLShader;
            IHLSLOptions hlslOpts = shaderHLSL.CompileOptions;
            AMDDriverBackendOptions backendOptions = options as AMDDriverBackendOptions;
            string shader = shaderObj.Code;

            if (shaderHLSL.WasCompiledWithErrors)
                return null;

            try
            {
                // compile here if we must.  Recycle existing blob if we can
                IDXShaderBlob blob = shaderHLSL.CompiledBlob;
                if ( blob == null )
                {
                    if (!shaderHLSL.Compile(m_FXC))
                        return null;
                    blob = shaderHLSL.CompiledBlob;
                }

                IDXShaderReflection reflect = blob.Reflect();

                IDXShaderBlob exe = blob.GetExecutableBlob();
                if (exe == null)
                    return null;

                byte[] bytes = exe.ReadBytes();

                AMDDriverResultSet rs = new AMDDriverResultSet(reflect );

                foreach (IAMDAsic a in m_Driver.Asics)
                {
                    if (CompileForAsic(backendOptions.Asics, a.Name))
                    {
                        IAMDShader sh = m_Driver.CompileDXBlob(a, bytes, reflect);
                        rs.Add(sh);
                    }
                }

                return rs;
            }
            catch( System.Exception ex )
            {
                MessageBox.Show(ex.Message);
                return null;
            }
        }
Esempio n. 6
0
        private void btnScrutinize_Click(object sender, EventArgs e)
        {
            int i = cmbAsic.SelectedIndex;

            if (i >= 0 && i < m_Shaders.Count)
            {
                IAMDShader sh = m_Shaders[cmbAsic.SelectedIndex];

                Scrutinizer.IScrutinizer        backend = sh.CreateScrutinizer();
                List <Scrutinizer.IInstruction> Ops     = backend.BuildProgram();
                List <Scrutinizer.IInstruction> Fetch   = backend.BuildDXFetchShader(m_DXReflection);

                Scrutinizer.UI.ScrutinizerForm f = new Scrutinizer.UI.ScrutinizerForm(Fetch, Ops, backend);
                f.ShowDialog();
            }
        }
Esempio n. 7
0
        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);
            }
        }
Esempio n. 8
0
 public void Add( IAMDShader sh )
 {
     m_Results.AddResult(sh);
 }
Esempio n. 9
0
 public void Add(IAMDShader sh)
 {
     m_Results.AddResult(sh);
 }
Esempio n. 10
0
        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);
            }
        }