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; } }
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); } } }
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); } } }
public FXCResultSet(string error, IDXShaderBlob blob) { m_Panel = new FXCResultsPanel(error, blob); }
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); } } }