public static async System.Threading.Tasks.Task LoadAllShaders(CRenderContext rc) { var sm = CRenderContext.ShaderModelString; var shaderPath = CEngine.Instance.FileManager.DDCDirectory + sm + "/"; var shaders = CEngine.Instance.FileManager.GetFiles(shaderPath, "*.shader"); Profiler.Log.WriteLine(Profiler.ELogTag.Info, "LoadShaders", $"Begin LoadShaders Number = {shaders.Count}"); var t1 = Support.Time.HighPrecision_GetTickCount(); var smp = Thread.ASyncSemaphore.CreateSemaphore(shaders.Count); foreach (var i in shaders) { if (MultiThreadCompile) { CEngine.Instance.EventPoster.RunOn(async() => { var fileName = CEngine.Instance.FileManager.GetPureFileFromFullName(i, false); Hash64 hash = Hash64.TryParse(fileName); var effect = new CGfxEffect(); if (await effect.LoadFromXndAsync(rc, hash) == 0) { CEngine.Instance.EffectManager.RegEffect(hash, effect); } else { CEngine.Instance.FileManager.DeleteFile(shaderPath + hash.ToString() + ".shader"); } smp.Release(); return(true); }, Thread.Async.EAsyncTarget.TPools); } else { var fileName = CEngine.Instance.FileManager.GetPureFileFromFullName(i, false); Hash64 hash = Hash64.TryParse(fileName); var effect = new CGfxEffect(); if (await effect.LoadFromXndAsync(rc, hash) == 0) { CEngine.Instance.EffectManager.RegEffect(hash, effect); } else { CEngine.Instance.FileManager.DeleteFile(shaderPath + hash.ToString() + ".shader"); } smp.Release(); } } await smp.Await(); var t2 = Support.Time.HighPrecision_GetTickCount(); Profiler.Log.WriteLine(Profiler.ELogTag.Info, "LoadShaders", $"End LoadShaders, Times = {(t2 - t1) / 1000} ms"); }