Exemplo n.º 1
0
        private void btnExportCPP_Click(object sender, EventArgs e)
        {
            SaveFileDialog save = new SaveFileDialog();

            if (save.ShowDialog() != DialogResult.Cancel)
            {
                StringBuilder str = new StringBuilder();

                if (m_Shader != null)
                {
                    str.Append("#if 0");
                    str.AppendLine();
                    str.Append(m_Shader.Disassemble());
                    str.AppendLine();
                    str.Append("#endif");
                    str.AppendLine();

                    byte[] byteCode = m_Shader.ReadBytes();
                    DeclareByteArray(str, byteCode, "Bytecode");
                }

                if (m_RootSignature != null)
                {
                    byte[] byteCode = m_RootSignature.ReadBytes();
                    DeclareByteArray(str, byteCode, "RootSig");
                }

                File.WriteAllText(save.FileName, str.ToString());
            }
        }
Exemplo n.º 2
0
        public FXCResultsPanel( string error, IDXShaderBlob blob )
        {
            InitializeComponent();
            txtMessages.Text = error;

            if (blob == null)
            {
                tabControl1.TabPages.Remove(hexPage);
                tabControl1.TabPages.Remove(asmPage);
            }
            else
            {
                txtASM.Text = blob.Disassemble();

                // generate a blob dump
                try
                {
                    IDXShaderBlob strip = blob.Strip();
                    IDXShaderBlob sig   = strip.GetSignatureBlob();

                    byte[] rawBytes = blob.ReadBytes();
                    byte[] stripBytes = strip.ReadBytes();
                    byte[] sigBytes = sig.ReadBytes();

                    StringBuilder str = new StringBuilder();
                    str.AppendFormat("Blob size is {0} ({1:X}) bytes", rawBytes.Length, rawBytes.Length);
                    str.AppendLine();
                    HexBumpBlob(str, rawBytes);

                    str.AppendFormat("Stripped blob size is {0} ({1:x}) bytes", stripBytes.Length, stripBytes.Length);
                    str.AppendLine();
                    HexBumpBlob(str, stripBytes);

                    str.AppendFormat("Signature blob size is {0} ({1:x}) bytes", sigBytes.Length, sigBytes.Length);
                    str.AppendLine();
                    HexBumpBlob(str, sigBytes);

                    txtHex.Text = str.ToString();
                }
                catch( Exception ex )
                {
                    txtHex.Text = String.Format("EXCEPTION while generating hex dump: {0}", ex.Message);
                }

            }
        }
Exemplo n.º 3
0
        public FXCResultsPanel(string error, IDXShaderBlob blob)
        {
            InitializeComponent();
            txtMessages.Text = error;

            if (blob == null)
            {
                tabControl1.TabPages.Remove(hexPage);
                tabControl1.TabPages.Remove(asmPage);
            }
            else
            {
                txtASM.Text = blob.Disassemble();

                // generate a blob dump
                try
                {
                    IDXShaderBlob strip = blob.Strip();
                    IDXShaderBlob sig   = strip.GetSignatureBlob();

                    byte[] rawBytes   = blob.ReadBytes();
                    byte[] stripBytes = strip.ReadBytes();
                    byte[] sigBytes   = sig.ReadBytes();

                    StringBuilder str = new StringBuilder();
                    str.AppendFormat("Blob size is {0} ({1:X}) bytes", rawBytes.Length, rawBytes.Length);
                    str.AppendLine();
                    HexBumpBlob(str, rawBytes);

                    str.AppendFormat("Stripped blob size is {0} ({1:x}) bytes", stripBytes.Length, stripBytes.Length);
                    str.AppendLine();
                    HexBumpBlob(str, stripBytes);

                    str.AppendFormat("Signature blob size is {0} ({1:x}) bytes", sigBytes.Length, sigBytes.Length);
                    str.AppendLine();
                    HexBumpBlob(str, sigBytes);

                    txtHex.Text = str.ToString();
                }
                catch (Exception ex)
                {
                    txtHex.Text = String.Format("EXCEPTION while generating hex dump: {0}", ex.Message);
                }
            }
        }
Exemplo n.º 4
0
        public FXCResultsPanel(HLSLShader shader)
        {
            string        error = shader.Messages;
            IDXShaderBlob blob  = shader.CompiledBlob;

            m_Shader = blob;
            InitializeComponent();
            txtMessages.Text = error;

            if (blob == null)
            {
                tabControl1.TabPages.Remove(hexPage);
                tabControl1.TabPages.Remove(asmPage);
            }
            else
            {
                txtASM.Text = blob.Disassemble();

                // generate a blob dump
                try
                {
                    byte[] rawBytes = blob.ReadBytes();

                    StringBuilder str = new StringBuilder();
                    str.AppendFormat("Blob size is {0} ({1:X}) bytes", rawBytes.Length, rawBytes.Length);
                    str.AppendLine();
                    HexBumpBlob(str, rawBytes);

                    if (blob is IDXBCShaderBlob)
                    {
                        IDXBCShaderBlob blobDXBC = blob as IDXBCShaderBlob;
                        IDXBCShaderBlob strip    = blobDXBC.Strip();
                        IDXBCShaderBlob sig      = strip.GetSignatureBlob();

                        byte[] stripBytes = strip.ReadBytes();
                        byte[] sigBytes   = sig.ReadBytes();

                        str.AppendFormat("Stripped blob size is {0} ({1:x}) bytes", stripBytes.Length, stripBytes.Length);
                        str.AppendLine();
                        HexBumpBlob(str, stripBytes);

                        str.AppendFormat("Signature blob size is {0} ({1:x}) bytes", sigBytes.Length, sigBytes.Length);
                        str.AppendLine();
                        HexBumpBlob(str, sigBytes);
                    }

                    txtHex.Text = str.ToString();
                }
                catch (Exception ex)
                {
                    txtHex.Text = String.Format("EXCEPTION while generating hex dump: {0}", ex.Message);
                }
            }

            IDXBlob rsBlob = shader.CompiledRootSig;

            m_RootSignature  = rsBlob;
            txtMessages.Text = String.Concat(txtMessages.Text, shader.RootSigMessages);

            if (rsBlob == null)
            {
                tabControl1.TabPages.Remove(rootSigPage);
            }
            else
            {
                try
                {
                    byte[] rawBytes = rsBlob.ReadBytes();

                    StringBuilder str = new StringBuilder();
                    str.AppendFormat("RootSig blob size is {0} ({1:X}) bytes", rawBytes.Length, rawBytes.Length);
                    str.AppendLine();

                    HexBumpBlob(str, rawBytes);

                    txtRootSig.Text = str.ToString();
                }
                catch (Exception ex)
                {
                    txtRootSig.Text = String.Format("EXCEPTION while generating rootsig dump: {0}", ex.Message);
                }
            }
        }