public void ProcessAndVerify(Shader shader, Dictionary<string, Param> _params) { // validate lines foreach (ShaderLine line in lines) { line.ProcessAndVerify(shader, _params); } }
public void ProcessAndVerify(Shader shader, Dictionary<string, Param> _params) { // parse line for dependancies int idx = 0; // inputs List<Input> inRefs = new List<Input>(); MatchCollection matches = Regex.Matches(rawData, @"(IN.)([a-zA-Z0-9]*)"); foreach (Match match in matches) { if (match.Success) { string value = match.Groups[2].Value; // validate reference Input input; if (!shader.inputs.TryGetValue(value, out input)) throw new Exception(); inRefs.Add(input); } } inputDependancies = inRefs.ToArray(); inRefs.Clear(); // outputs // params List<Param> pRefs = new List<Param>(); matches = Regex.Matches(rawData, @"(PARAM.)([a-zA-Z0-9]*)"); foreach (Match match in matches) { if (match.Success) { string value = match.Groups[2].Value; // validate reference Param param; if (!_params.TryGetValue(value, out param)) throw new Exception(); pRefs.Add(param); } } paramDependancies = pRefs.ToArray(); pRefs.Clear(); }
protected static void ParseXml(XmlElement el, Shader shader) { shader.id = el.Attributes["id"].InnerText; // parse inputs XmlNodeList inputEls = el.SelectNodes("input"); shader.inputs = new Dictionary<string,Input>(inputEls.Count); for (int i = 0; i < inputEls.Count; i++) { Input input = Input.ParseXmlElement((XmlElement)inputEls[i]); shader.inputs.Add(input.Name, input); } // parse processes XmlNodeList processEls = el.SelectNodes("process"); shader.processes = new ShaderProcess[processEls.Count]; for (int i = 0; i < processEls.Count; i++) { shader.processes[i] = ShaderProcess.ParseXmlElement((XmlElement)processEls[i]); } }