/// <summary> /// Interprets the specified effect technique and adds an /// <see cref="EffectTechniqueDescription"/> to the collection. /// </summary> /// <param name="effect">The effect.</param> /// <param name="technique">The technique.</param> /// <param name="interpreters">The effect interpreters.</param> private void InterpretTechnique(Effect effect, EffectTechnique technique, EffectInterpreterCollection interpreters) { foreach (var interpreter in interpreters) { var description = interpreter.GetDescription(effect, technique); if (description != null) { Add(description); return; } } // No description found. Set default description. Add(new EffectTechniqueDescription(effect, technique)); }
/// <summary> /// Interprets the specified effect parameter and adds an /// <see cref="EffectParameterDescription"/> to the collection. /// </summary> /// <param name="effect">The effect.</param> /// <param name="parameter">The effect parameter.</param> /// <param name="interpreters">The effect interpreters.</param> private void InterpretParameter(Effect effect, EffectParameter parameter, EffectInterpreterCollection interpreters) { Debug.Assert(!Contains(parameter), "Effect binding already contains a description for the given effect parameter."); // Try all interpreters to find a description. foreach (var interpreter in interpreters) { var description = interpreter.GetDescription(effect, parameter); if (description != null) { Add(description); return; } } // No description found. If the parameter is a struct or array of structs // we check the structure members. if (parameter.ParameterClass == EffectParameterClass.Struct) { if (parameter.Elements.Count > 0) { // Effect parameter is an array of structs. foreach (EffectParameter element in parameter.Elements) { foreach (EffectParameter member in element.StructureMembers) { InterpretParameter(effect, member, interpreters); } } } else { // Effect parameter is a struct. foreach (EffectParameter member in parameter.StructureMembers) { InterpretParameter(effect, member, interpreters); } } } else { // No description found and this parameter is no struct. // Try to get hint from annotations and create default description (= "Unknown usage"). var hint = EffectHelper.GetHintFromAnnotations(parameter) ?? EffectParameterHint.Material; Add(new EffectParameterDescription(parameter, null, 0, hint)); } }