Пример #1
0
		public void PipelineGraphCanDetectCycles()
		{
			// create graph
			AnonymousNode node0 = new AnonymousNode() { Name = "node0" };
			AnonymousNode node1 = new AnonymousNode(node0) { Name = "node1" };
			AnonymousNode node2 = new AnonymousNode(node1) { Name = "node2" };
			AnonymousNode node3 = new AnonymousNode(node2) { Name = "node3" };
			PipelineGraph graph = new PipelineGraph { Nodes = { node0, node1, node2, node3 } };

			Assert.Equal(false, graph.AddEdge(node3.Outputs[0], node1.Inputs[0]));
			Assert.Equal(true, graph.AddEdge(node2.Outputs[0], node3.Inputs[0]));
		}
Пример #2
0
		public void DfsFindsCorrectNodes()
		{
			// create graph
			AnonymousNode node0 = new AnonymousNode() { Name = "node0" };
			AnonymousNode node1 = new AnonymousNode() { Name = "node1" };
			AnonymousNode node2 = new AnonymousNode(node0) { Name = "node2" };
			AnonymousNode node3 = new AnonymousNode(node0, node1) { Name = "node3" };
			AnonymousNode node4 = new AnonymousNode(node3) { Name = "node4" };
			PipelineGraph graph = new PipelineGraph {
				Nodes = { node0, node1, node2, node3, node4 }
			};

			Assert.Contains<Node>(node0, graph.DepthFirstSearch(node4));
			Assert.Contains<Node>(node1, graph.DepthFirstSearch(node4));
			Assert.DoesNotContain<Node>(node2, graph.DepthFirstSearch(node4));
			Assert.DoesNotContain<Node>(node4, graph.DepthFirstSearch(node3));
		}
Пример #3
0
 public PipelineState()
 {
     Graph  = new PipelineGraph();
     Driver = new PipelineDriver();
     Speed  = 30;
 }
Пример #4
0
		public void TestAddNode()
		{
			// create some nodes and initialize graph
			BlurNode blur0 = new BlurNode();
			BlurNode blur1 = new BlurNode();
			BlurNode blur2 = new BlurNode();
			BlurNode blur3 = new BlurNode();
			BlurNode blur4 = new BlurNode();
			NoiseInputNode noise0 = new NoiseInputNode();
			NoiseInputNode noise1 = new NoiseInputNode();
			PipelineGraph graph = new PipelineGraph();

			graph.AddNode(blur0);
			graph.AddNode(blur1);
			graph.AddNode(noise0);
			graph.AddNode(blur2);
			graph.AddNode(noise1);

			Assert.Equal("Blur", blur0.Name);
			Assert.Equal("Blur 2", blur1.Name);
			Assert.Equal("Blur 3", blur2.Name);
			Assert.Equal("Noise", noise0.Name);
			Assert.Equal("Noise 2", noise1.Name);

			graph.RemoveNode(blur1);
			graph.AddNode(blur3);
			graph.AddNode(blur4);

			Assert.Equal("Blur 2", blur3.Name);
			Assert.Equal("Blur 4", blur4.Name);
		}
Пример #5
0
		public void TestRemoveNode()
		{
			// create graph
			AnonymousNode node0 = new AnonymousNode() { Name = "node0" };
			AnonymousNode node1 = new AnonymousNode() { Name = "node1" };
			AnonymousNode node2 = new AnonymousNode(node0, node1) { Name = "node2" };
			AnonymousNode node3 = new AnonymousNode(node2) { Name = "node3" };
			AnonymousNode node4 = new AnonymousNode(node2) { Name = "node4" };
			PipelineGraph graph = new PipelineGraph {
				Nodes = { node0, node1, node2, node3, node4 }
			};

			graph.RemoveNode(node2);

			foreach (Node.Input input in node3.Inputs) {
				Assert.Equal(null, input.Source);
			}

			foreach (Node.Input input in node4.Inputs) {
				Assert.Equal(null, input.Source);
			}
		}
Пример #6
0
		public void TestReturnNumberOfFramesToPrecompute()
		{
			// create graph
			AnonymousNode node0 = new AnonymousNode() { Name = "node0" };
			AnonymousNode node1 = new AnonymousNode() { Name = "node1" };
			AnonymousNode node2 = new AnonymousNode(node0) { Name = "node2" };
			AnonymousNode node3 = new AnonymousNode(node0, node1) { Name = "node3" };
			AnonymousNode node4 = new AnonymousNode(node3) { Name = "node4" };
			PipelineGraph graph = new PipelineGraph {
				Nodes = { node0, node1, node2, node3, node4 }
			};
			//set number of frames to precompute in the graph's nodes
			node0.SettableNumberOfFramesToPrecompute = 0;
			node1.SettableNumberOfFramesToPrecompute = 1;
			node2.SettableNumberOfFramesToPrecompute = 2;
			node3.SettableNumberOfFramesToPrecompute = 4;
			node4.SettableNumberOfFramesToPrecompute = 8;

			List<AnonymousNode> nodeList = new List<AnonymousNode>();
			nodeList.Add(node0);
			Assert.Equal(0, graph.NumberOfTicksToPrecompute(nodeList));
			nodeList.Add(node1);
			Assert.Equal(1, graph.NumberOfTicksToPrecompute(nodeList));
			nodeList.Add(node2);
			Assert.Equal(2, graph.NumberOfTicksToPrecompute(nodeList));
			nodeList.Add(node3);
			Assert.Equal(5, graph.NumberOfTicksToPrecompute(nodeList));
			nodeList.Add(node4);
			Assert.Equal(13, graph.NumberOfTicksToPrecompute(nodeList));
		}