Exemplo n.º 1
0
        public bool Compile(ID3DCompiler compiler, IDXILCompiler dxil)
        {
            if (CompileOptions.Target.ToString()[3] == '6')
            {
                if (dxil == null)
                {
                    return(false);
                }

                IDXILShaderBlob blob;
                string          msg;
                HasError     = !dxil.Compile(this.Code, this.CompileOptions, this.SourceFilePath, out blob, out msg);
                WasCompiled  = true;
                Messages     = msg;
                CompiledBlob = blob;
            }
            else
            {
                if (compiler == null)
                {
                    return(false);
                }

                IDXBCShaderBlob blob;
                string          msg;
                HasError     = !compiler.Compile(this.Code, this.CompileOptions, this.SourceFilePath, out blob, out msg);
                WasCompiled  = true;
                Messages     = msg;
                CompiledBlob = blob;
            }

            // check for embedded root signature and pull it out if there is one
            if (CompiledBlob != null)
            {
                IDXBlob rs = CompiledBlob.ExtractRootSignature();
                if (rs != null)
                {
                    RootSigWasCompiled = true;
                    RootSigHasError    = false;
                    CompiledRootSig    = rs;
                }
            }

            return(!HasError);
        }
Exemplo n.º 2
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);
                }
            }
        }