コード例 #1
0
        protected override int init(AnalyzeWrap wrap, ShaderAnalyzeParams param)
        {
            ShaderAnalyzerUtil.ChangeIDEToBridge();

            ShaderCompilerPlatform platform = ShaderCompilerPlatform.GLES3x;

            switch (param.APIType)
            {
            case EAPIType.OpenGLES:
                platform = ShaderCompilerPlatform.GLES3x;
                break;

            case EAPIType.Vulkan:
                platform = ShaderCompilerPlatform.Vulkan;
                break;
            }

            ShaderAnalyzerUtil.OpenCompiledShader.Invoke(null, new object[] { param.Shader, 3, 1 << (int)platform, !param.SkipUnusedVariant });

            ShaderAnalyzerUtil.RevertIDESettings();

            Thread thread = new Thread(new ThreadStart(supervisor));

            thread.Start();

            return(InitUnknown);
        }
コード例 #2
0
        protected override int init(AnalyzeWrap wrap, ShaderAnalyzeParams param)
        {
            m_CompiledShaderPath   = ShaderAnalyzerUtil.GetCompiledShaderPath(param);
            m_AnalyzedDataFilePath = ShaderAnalyzerUtil.GetChacheFileName(param);
            m_MD5 = ShaderAnalyzerUtil.GenerateMD5(m_CompiledShaderPath);

            if (!Directory.Exists(Constant.CacheFolder))
            {
                Directory.CreateDirectory(Constant.CacheFolder);
                return(create());
            }
            else
            {
                if (!File.Exists(m_AnalyzedDataFilePath))
                {
                    return(create());
                }
                else
                {
                    CacheHead head = ShaderAnalyzerUtil.GetHeadFromCache(m_AnalyzedDataFilePath);
                    if (head == null || Constant.Version != head.Version || head.MD5 != m_MD5)
                    {
                        return(create());
                    }
                    else
                    {
                        return(loadFromCache(head));
                    }
                }
            }
        }
コード例 #3
0
        protected override int init(AnalyzeWrap wrap, ShaderAnalyzeParams param)
        {
            createFolder(Constant.SAWorkSpace);
            for (int i = 0; i < wrap.Subshaders.Count; i++)
            {
                AnalyzedSubshaderData subshader = wrap.Subshaders[i];

                string subshaderFolder = Constant.SAWorkSpace + "/Subshader_" + i.ToString();

                createFolder(subshaderFolder);
                for (int j = 0; j < subshader.Passes.Count; j++)
                {
                    AnalyzedPassData pass = subshader.Passes[j];

                    string passFolder = subshaderFolder + "/Pass_" + j.ToString();

                    createFolder(passFolder);

                    for (int k = 0; k < pass.Variants.Count; k++)
                    {
                        AnalyzedVariantData variant = pass.Variants[k];

                        string variantFolder = passFolder + "/" + ShaderAnalyzerUtil.ReplaceBadCharOfFileName(variant.VariantName);

                        createFolder(variantFolder);

                        wrap.VariantDirectory.Add(variant, variantFolder);
                    }
                }
            }

            return(wrap.Variants.Count);
        }
コード例 #4
0
        protected override EAnalyzeStageStatus execute(int index)
        {
            AnalyzedVariantData variant = m_AnalyzeWrap.Variants[index];

            foreach (var item in variant.ShaderSourceCodes)
            {
                string path;
                if (m_AnalyzeWrap.VariantDirectory.TryGetValue(variant, out path))
                {
                    File.WriteAllText(path + "/shader" + ShaderAnalyzerUtil.GetFileExtensionByShaderType(item.Key), item.Value);
                }
            }

            //TODO 这里要处理IO异常

            return(EAnalyzeStageStatus.Success);
        }
コード例 #5
0
        protected override EAnalyzeStageStatus execute(int index)
        {
            AnalyzedVariantData avd = m_AnalyzeWrap.Variants[index];

            foreach (var item in avd.ShaderSourceCodes)
            {
                string path;
                if (m_AnalyzeWrap.VariantDirectory.TryGetValue(avd, out path))
                {
                    List <string> lines = new List <string>(32);

                    ProcessStartInfo psi = new ProcessStartInfo(UnityEngine.Application.dataPath + "/../Tools/mali_offline_compiler/malioc.exe", "\"" + path + "/shader" + ShaderAnalyzerUtil.GetFileExtensionByShaderType(item.Key) + "\"");
                    psi.RedirectStandardOutput = true;
                    psi.CreateNoWindow         = true;
                    psi.UseShellExecute        = false;

                    Process process = Process.Start(psi);
                    process.EnableRaisingEvents = true;
                    process.OutputDataReceived += new DataReceivedEventHandler(
                        (object o, DataReceivedEventArgs e) =>
                    {
                        lines.Add(e.Data);
                    }
                        );
                    process.BeginOutputReadLine();
                    process.Exited += new EventHandler(
                        (object o, EventArgs args) =>
                    {
                        avd.CompileResult.Add(item.Key, lines.ToArray());
                    }
                        );
                    process.WaitForExit();

                    process.Dispose();
                }
            }

            //TODO 这里要处理进程异常

            return(EAnalyzeStageStatus.Success);
        }
コード例 #6
0
 /// <summary>
 /// 构造函数,有传入的版本号以及MD5计算缓存文件头字符串
 /// </summary>
 /// <param name="version">版本号</param>
 /// <param name="md5">MD5</param>
 public CacheHead(string version, string md5)
 {
     Version = version;
     MD5     = md5;
     Head    = ShaderAnalyzerUtil.GetCacheHead(Version, MD5);
 }