Exemple #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;
     m_Results.Text       = shader.InfoLog.Replace("\n", Environment.NewLine);
 }
Exemple #2
0
        public IResultSet Compile(IShader shader, IBackendOptions options)
        {
            if (!(shader is GLSLShader))
            {
                return(null);
            }

            GLSLShader   sh     = (GLSLShader)shader;
            IGLSLOptions glOpts = sh.CompileOptions;

            GLSlangOptions slangOpts = new GLSlangOptions();

            slangOpts.ShaderType = glOpts.ShaderType;
            slangOpts.Config     = m_Config;
            GLSlang.IShader result = m_Compiler.Compile(sh.Code, slangOpts);
            return(new GLSLangResultSet(result));
        }
        public GLSlangResultsPanel(GLSlang.IShader shader, SPIRV.IProgram spirv)
        {
            InitializeComponent();

            m_Shader = shader;
            m_SPIRV  = spirv;
            if (spirv != null)
            {
                textBox1.Text   = spirv.Disassemble();
                button1.Enabled = true;
            }
            else
            {
                textBox1.Text   = shader.InfoLog.Replace("\n", Environment.NewLine);
                button1.Enabled = false;
            }
        }
Exemple #4
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);
                }
            }
Exemple #5
0
        public IResultSet Compile(IShader shader, IBackendOptions options)
        {
            if (shader is GLSLShader)
            {
                GLSLShader   sh     = (GLSLShader)shader;
                IGLSLOptions glOpts = sh.CompileOptions;

                GLSlang.IShader result = m_Compiler.Compile(sh.Code, glOpts.ShaderType, m_Config, shader.SourceFilePath);
                return(new GLSLangResultSet(result));
            }
            else if (shader is HLSLShader)
            {
                HLSLShader   sh       = (HLSLShader)shader;
                IHLSLOptions hlslOpts = sh.CompileOptions;

                GLSlang.IShader result = m_Compiler.CompileHLSL(sh.Code, hlslOpts, m_Config, shader.SourceFilePath);
                return(new GLSLangResultSet(result));
            }
            else
            {
                return(null);
            }
        }
Exemple #6
0
 public GLSLangResultSet(GLSlang.IShader shader)
 {
     m_Results = new GLSlangResultsPanel(shader, shader.CompileSPIRV());
 }
Exemple #7
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);
            }
        }
Exemple #8
0
        public IResultSet Compile(IShader shader, IBackendOptions options)
        {
            if (shader is GLSLShader)
            {
                GLSLShader   sh     = (GLSLShader)shader;
                IGLSLOptions glOpts = sh.CompileOptions;

                GLSlangOptions slangOpts = new GLSlangOptions();
                slangOpts.ShaderType = glOpts.ShaderType;
                slangOpts.Config     = m_Config;
                GLSlang.IShader result = m_Compiler.Compile(sh.Code, slangOpts);
                return(new GLSLangResultSet(result));
            }
            else if (shader is HLSLShader)
            {
                HLSLShader   sh       = (HLSLShader)shader;
                IHLSLOptions hlslOpts = sh.CompileOptions;

                // turn HLSL shader profile into GLSL shader type
                GLSLShaderType eShaderType;
                string         profile = hlslOpts.Target.ToString();
                if (profile.StartsWith("vs"))
                {
                    eShaderType = GLSLShaderType.VERTEX;
                }
                else if (profile.StartsWith("ps"))
                {
                    eShaderType = GLSLShaderType.FRAGMENT;
                }
                else if (profile.StartsWith("gs"))
                {
                    eShaderType = GLSLShaderType.GEOMETRY;
                }
                else if (profile.StartsWith("hs"))
                {
                    eShaderType = GLSLShaderType.TESS_CONTROL;
                }
                else if (profile.StartsWith("ds"))
                {
                    eShaderType = GLSLShaderType.TESS_EVALUATION;
                }
                else if (profile.StartsWith("cs"))
                {
                    eShaderType = GLSLShaderType.COMPUTE;
                }
                else
                {
                    throw new System.Exception("Don't know what this shader profile is");
                }

                string EntryPoint = hlslOpts.EntryPoint;

                GLSlangOptions slangOpts = new GLSlangOptions();
                slangOpts.ShaderType = eShaderType;
                slangOpts.Config     = m_Config;
                GLSlang.IShader result = m_Compiler.CompileHLSL(sh.Code, slangOpts, EntryPoint);
                return(new GLSLangResultSet(result));
            }
            else
            {
                return(null);
            }
        }