Esempio n. 1
0
        private static void PreCompile(string source, List <ShaderMacro> macros, MyShadersDefines.Profiles profile, string descriptor, string vertexLayoutString, float progress, OnShaderCacheProgressDelegate onShaderCacheProgress)
        {
            var    macrosArray = macros.ToArray();
            bool   wasCached;
            string compileLog;

            if (onShaderCacheProgress != null)
            {
                onShaderCacheProgress(progress, descriptor, MyShadersDefines.ProfileToString(profile), vertexLayoutString, macrosArray.GetString(), "", false);
            }
            var compiled = MyShaders.Compile(source, macrosArray, profile, descriptor, true, false, out wasCached, out compileLog);

            if (onShaderCacheProgress != null)
            {
                string message = "";
                if (wasCached)
                {
                    onShaderCacheProgress(progress, descriptor + vertexLayoutString, MyShadersDefines.ProfileToString(profile), vertexLayoutString, macrosArray.GetString(), "skipped", false);
                }
                else if (compileLog != null)
                {
                    onShaderCacheProgress(progress, descriptor + vertexLayoutString, MyShadersDefines.ProfileToString(profile), vertexLayoutString, macrosArray.GetString(),
                                          (compiled == null ? "errors:\n" : "warnings:\n") + compileLog, compiled == null);
                }
            }
        }