public void Compile(ProgramGraph graph, CompilerOutputInfo info) { if (!(info is ShaderOutputInfo)) return; ShaderOutputInfo outputInfo = info as ShaderOutputInfo; RegisterDict = new Dictionary<string, int>(); for(int i = 0; i < graph.getMaxDepth(); i++) { foreach (Vertex v in graph.getVerticesForLayer(i)) { foreach (NodeItem outputItem in v.Data.Items.Where(item => item.Output.Enabled)) { if(outputItem.OutputData is ShaderTypes.sampler2D) { ShaderTypes.sampler2D Sampler = (ShaderTypes.sampler2D)outputItem.OutputData; if (!RegisterDict.ContainsKey(Sampler.path)) RegisterDict.Add(Sampler.path, RegisterDict.Count); } } } } mCompiler = new HLSLCompiler(new Dictionary<object, string>(), RegisterDict); WritePostFxScript(outputInfo); if (mCompiler == null) return; mCompiler.Compile(graph, outputInfo); }
public void Compile(ProgramGraph graph, CompilerOutputInfo info) { currentDepth = 0; List<Vertex> inputVertices = graph.getVerticesForLayer(0); Vertex main = GetMainInput(inputVertices); if (main == null) return; InputDict = new Dictionary<object, string>(); outStream = new StreamWriter(info.outputPath + info.outputFilename + ".hlsl"); WriteInputHeaders(inputVertices); WriteFunctionHeader(main); for (int i = 0; i <= graph.getMaxDepth(); i++) { WriteLayer(graph.getVerticesForLayer(i)); } currentDepth--; WriteLine("}", IndentType.Decrease); outStream.Close(); }