예제 #1
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));
        }
예제 #2
0
        public IResultSet Compile(IShader shader, IBackendOptions options)
        {
            if (!(shader is GLSLShader))
            {
                return(null);
            }

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

            if (glOpts.OptimizerOptions == null)
            {
                return(null);
            }

            GLSLOptimizer.IOptimizer optimizer = m_Optimizers[glOpts.OptimizerTarget];
            return(new GLSLOptimizerResultSet(optimizer.Optimize(sh.Code, glOpts.OptimizerOptions)));
        }
예제 #3
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);
            }
        }
예제 #4
0
 public GLSLShader(string code, IGLSLOptions opts)
 {
     CompileOptions = opts;
     Code           = code;
 }
예제 #5
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);
        }
예제 #6
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 shaderSwitch = "";

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

            case GLSLShaderType.FRAGMENT: shaderSwitch = "-f"; break;

            case GLSLShaderType.COMPUTE:  shaderSwitch = "-c"; break;

            default:
                return(null);
            }

            string tmpFile         = Path.Combine(m_TempPath, "PYRAMID_pvr");
            string dummyOutputFile = Path.Combine(m_TempPath, "PYRAMID_pvr.out");
            string disasmFile      = Path.Combine(m_TempPath, "PYRAMID_pvr.disasm");

            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);
            }

            string args = String.Format("{0} {1} {2} -disasm", tmpFile, dummyOutputFile, shaderSwitch);


            PVRResultSet rs = new PVRResultSet();

            foreach (string s in m_Compilers)
            {
                ProcessStartInfo pi = new ProcessStartInfo();
                pi.RedirectStandardOutput = true;
                pi.RedirectStandardInput  = true;
                pi.RedirectStandardError  = true;
                pi.CreateNoWindow         = true;
                pi.Arguments       = args;
                pi.FileName        = s;
                pi.UseShellExecute = false;

                try
                {
                    Process p = Process.Start(pi);

                    string asm      = "No Output";
                    string output   = p.StandardError.ReadToEnd();
                    string compiler = Path.GetFileNameWithoutExtension(s);

                    p.WaitForExit();

                    if (File.Exists(disasmFile))
                    {
                        asm = File.ReadAllText(disasmFile);
                        File.Delete(disasmFile);
                    }

                    rs.PVRResultsPanel.AddResult(compiler, output, asm);
                }
                catch (System.Exception)
                {
                    continue;
                }
            }

            File.Delete(tmpFile);

            return(rs);
        }
예제 #7
0
 public GLSLShader(string code, IGLSLOptions opts, string path)
 {
     CompileOptions = opts;
     Code           = code;
     SourceFilePath = path;
 }
예제 #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);
            }
        }
예제 #9
0
 public GLSLShader(string code, IGLSLOptions opts)
 {
     CompileOptions = opts;
     Code = code;
 }