Example #1
0
            public GLSLangResultSet(GLSlang.IShader shader)
            {
                m_Results.ReadOnly   = true;
                m_Results.Dock       = DockStyle.Fill;
                m_Results.Multiline  = true;
                m_Results.ScrollBars = ScrollBars.Both;
                m_Results.WordWrap   = false;

                SPIRV.IProgram spirv = shader.CompileSPIRV();
                if (spirv != null)
                {
                    m_Results.Text = spirv.Disassemble();
                }
                else
                {
                    m_Results.Text = shader.InfoLog.Replace("\n", Environment.NewLine);
                }
            }
Example #2
0
 public GLSLangResultSet(GLSlang.IShader shader)
 {
     m_Results = new GLSlangResultsPanel(shader, shader.CompileSPIRV());
 }
Example #3
0
        public IResultSet Compile(IShader shader, IBackendOptions options)
        {
            if (!(options is RGABackendOptions))
            {
                return(null);
            }
            if (!(shader is HLSLShader || shader is GLSLShader))
            {
                return(null);
            }

            RGABackendOptions backendOptions = options as RGABackendOptions;

            string tmpFile = Path.Combine(m_TempPath, "PYRAMID_amdrga");

            // pass the shader through GLSLang's hlsl front end
            GLSlang.IShader glShader = CompileShader(shader);
            if (glShader.HasErrors)
            {
                return(new GenericTextResultSet(this.Name, glShader.InfoLog));
            }

            string sType = GetRGAShaderType(glShader.ShaderType);

            // get the SPIR-V
            SPIRV.IProgram spirv = glShader.CompileSPIRV();
            if (spirv == null)
            {
                return(new GenericTextResultSet(this.Name, "Error generating SPIR-V"));
            }

            // dump the SPIR-V to disk
            try
            {
                File.WriteAllBytes(tmpFile, spirv.GetBytes());
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "uh-oh, couldn't create temp file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            // send the SPIR-V to RGA
            string CommandLine = String.Format(" -s vulkan-spv {0}", tmpFile);


            string isaPath      = Path.Combine(m_TempPath, "pyramid.isa");
            string analysisPath = Path.Combine(m_TempPath, "pyramid.analysis");
            string ilPath       = Path.Combine(m_TempPath, "pyramid.il");
            string liveRegPath  = Path.Combine(m_TempPath, "pyramid.livereg");

            CommandLine = String.Concat(CommandLine, String.Format(" --isa \"{0}\" ", isaPath));
            CommandLine = String.Concat(CommandLine, String.Format(" -a \"{0}\" ", analysisPath));
            CommandLine = String.Concat(CommandLine, String.Format(" --il \"{0}\" ", ilPath));
            CommandLine = String.Concat(CommandLine, String.Format(" --livereg \"{0}\" ", liveRegPath));

            List <string> asicsToCompile = new List <String>();

            foreach (string asic in m_SupportedAsics)
            {
                if (backendOptions.ShouldCompileForAsic(asic))
                {
                    asicsToCompile.Add(asic);
                    CommandLine = String.Concat(CommandLine, " -c ", asic, " ");
                }
            }

            if (asicsToCompile.Count == 0)
            {
                return(null);
            }

            string defaultAsic = asicsToCompile[0];


            ProcessStartInfo pi = new ProcessStartInfo();

            pi.RedirectStandardOutput = true;
            pi.RedirectStandardInput  = true;
            pi.RedirectStandardError  = false;
            pi.CreateNoWindow         = true;
            pi.Arguments       = CommandLine;
            pi.FileName        = m_RGAPath;
            pi.UseShellExecute = false;

            string output;

            try
            {
                Process p = Process.Start(pi);
                output = p.StandardOutput.ReadToEnd();

                int TIMEOUT = 60000;
                p.WaitForExit(TIMEOUT);

                p.Close();
                File.Delete(tmpFile);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "uh-oh, couldn't run CodeXL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            output = String.Format(@"Arguments:
                                    ----------
                                    {0}
                                    Output:
                                    -------
                                    {1}", CommandLine, output);

            // Compile results are emitted in one set of files per asic
            RGAResultSet results = new RGAResultSet(this.Name, output);

            foreach (string asic in asicsToCompile)
            {
                string path = Path.Combine(m_TempPath, String.Format("{0}_{1}_pyramid", asic, sType));

                try
                {
                    RGAResult result = new RGAResult(asic, path);
                    results.AddCompileResult(result);
                }
                catch (Exception ex)
                {
                    // may occur on compile error
                }
            }


            if (results.ResultCount > 0)
            {
                results.DisplayAsic(defaultAsic);
                return(results);
            }
            else
            {
                return(null);
            }
        }