Ejemplo n.º 1
0
        public IResultSet Compile(IShader sh, IBackendOptions options)
        {
            if (sh.Language != Languages.GLSL)
            {
                return(null);
            }

            GLSLShader   glShader = (GLSLShader)sh;
            IGLSLOptions glOpts   = glShader.CompileOptions;
            string       shader   = glShader.Code;

            string shaderType = "";

            switch (glOpts.ShaderType)
            {
            case GLSLShaderType.VERTEX:   shaderType = "--vertex";   break;

            case GLSLShaderType.FRAGMENT: shaderType = "--fragment"; break;

            case GLSLShaderType.COMPUTE:  shaderType = "--compute";  break;

            default:
                return(null);
            }

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

            try
            {
                StreamWriter stream = File.CreateText(tmpFile);
                stream.Write(shader);
                stream.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "uh-oh, couldn't create temp file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            MaliSCResultSet rs = new MaliSCResultSet();

            try
            {
                foreach (string asic in m_Asics)
                {
                    string           commandline = String.Format("-V {0} -c {1} {2}", shaderType, asic, tmpFile);
                    ProcessStartInfo pi          = new ProcessStartInfo();
                    pi.RedirectStandardOutput = true;
                    pi.RedirectStandardInput  = true;
                    pi.RedirectStandardError  = true;
                    pi.EnvironmentVariables.Add("MALICM_LOCATION", m_MaliRoot);
                    pi.CreateNoWindow  = true;
                    pi.Arguments       = commandline;
                    pi.FileName        = Path.Combine(m_MaliRoot, "malisc.exe");
                    pi.UseShellExecute = false;

                    Process p = Process.Start(pi);
                    p.WaitForExit();

                    string output = p.StandardOutput.ReadToEnd();
                    rs.Add(asic, output);
                }
            }
            catch (System.Exception e)
            {
                MessageBox.Show(e.Message, "uh-oh, couldn't run MaliSC", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            File.Delete(tmpFile);

            return(rs);
        }
Ejemplo n.º 2
0
        public IResultSet Compile(string shader, ICompileOptions opts)
        {
            if (opts.Language != Languages.GLSL)
                return null;

            IGLSLOptions glOpts = opts as IGLSLOptions;
            string shaderType = "";
            switch( glOpts.ShaderType )
            {
            case GLSLShaderType.VERTEX:   shaderType = "--vertex";   break;
            case GLSLShaderType.FRAGMENT: shaderType = "--fragment"; break;
            case GLSLShaderType.COMPUTE:  shaderType = "--compute";  break;
            default:
                return null;
            }

            string tmpFile         = Path.Combine(m_TempPath, "PYRAMID_mali");
            try
            {
                StreamWriter stream = File.CreateText(tmpFile);
                stream.Write(shader);
                stream.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "uh-oh, couldn't create temp file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }

            MaliSCResultSet rs = new MaliSCResultSet();
            try
            {
                foreach (string asic in m_Asics)
                {
                    string commandline = String.Format("-V {0} -c {1} {2}", shaderType, asic, tmpFile);
                    ProcessStartInfo pi = new ProcessStartInfo();
                    pi.RedirectStandardOutput = true;
                    pi.RedirectStandardInput = true;
                    pi.RedirectStandardError = true;
                    pi.EnvironmentVariables.Add("MALICM_LOCATION", m_MaliRoot);
                    pi.CreateNoWindow = true;
                    pi.Arguments = commandline;
                    pi.FileName = Path.Combine(m_MaliRoot, "malisc.exe");
                    pi.UseShellExecute = false;

                    Process p = Process.Start(pi);
                    p.WaitForExit();

                    string output = p.StandardOutput.ReadToEnd();
                    rs.Add(asic, output);
                }
            }
            catch (System.Exception e)
            {
                MessageBox.Show(e.Message, "uh-oh, couldn't run MaliSC", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            File.Delete(tmpFile);

            return rs;
        }