private void RecompileEffect(EffectUpdateInfos updateInfos) { var compilerParameters = new CompilerParameters(); updateInfos.Effect.CompilationParameters.CopyTo(compilerParameters); var effectName = updateInfos.Effect.Name; string subEffect; var compilerResult = GetCompilerResults(effectName, compilerParameters, out subEffect); // If there are any errors when recompiling return immediately if (compilerResult.HasErrors) { Log.Error("Effect {0} failed to reompile: {0}", compilerResult.ToText()); return; } // update information updateInfos.CompilerResults = compilerResult; updateInfos.EffectName = effectName; updateInfos.SubEffectName = subEffect; lock (effectsToUpdate) { effectsToUpdate.Add(updateInfos); } }
private void UpdateEffect(EffectUpdateInfos updateInfos) { EffectBytecode bytecode; try { bytecode = updateInfos.CompilerResults.Bytecodes[updateInfos.SubEffectName]; } catch (KeyNotFoundException) { Log.Error("The sub-effect {0} wasn't found in the compiler results.", updateInfos.SubEffectName); return; } ShaderMixinParameters parameters; try { parameters = updateInfos.CompilerResults.UsedParameters[updateInfos.SubEffectName]; } catch (KeyNotFoundException) { Log.Error("The sub-effect {0} parameters weren't found in the compiler results.", updateInfos.SubEffectName); return; } bytecode.Name = updateInfos.EffectName; updateInfos.Effect.Initialize(GraphicsDevice, bytecode, parameters); updatedEffects.Add(updateInfos.Effect); lock (cachedEffects) { cachedEffects.Remove(updateInfos.OldBytecode); Effect newEffect; if (!cachedEffects.TryGetValue(bytecode, out newEffect)) { cachedEffects.Add(bytecode, updateInfos.Effect); } } }