예제 #1
0
        private bool SetLink(IPin sink, IPin source, bool frompending)
        {
            DX11Node sinknode   = this.graph.FindNode(sink.ParentNode);
            DX11Node sourcenode = this.graph.FindNode(source.ParentNode);

            if (sinknode != null && sourcenode != null)
            {
                DX11InputPin  sinkpin   = sinknode.GetInput(sink.Name);
                DX11OutputPin sourcepin = sourcenode.GetOutput(source.Name);
                sinkpin.Connect(sourcepin);

                //Since we managed to connect, check if it exists in pending list and remove

                if (!frompending)
                {
                    if (this.pendinglinks.ContainsKey(sink))
                    {
                        this.pendinglinks.Remove(sink);
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        private void AddPin(IPin2 pin)
        {
            DX11Node vn = this.graph.FindNode(pin.ParentNode);

            IPluginIO io = pin.InternalCOMInterf as IPluginIO;

            if (pin.Direction == PinDirection.Input && io != null && pin.Type.StartsWith("DX11Resource"))
            {
                DX11InputPin vop = new DX11InputPin(vn, pin.InternalCOMInterf, io);

                //We only register event on input pin (more than enough to build graph)
                pin.Connected    += pin_Connected;
                pin.Disconnected += pin_Disconnected;

                IPin src = this.GetSource(pin.InternalCOMInterf);

                if (src != null)
                {
                    if (this.CanProcessPin(pin.InternalCOMInterf, src))
                    {
                        if (!this.SetLink(pin.InternalCOMInterf, src, false))
                        {
                            //Add projected pending link
                            HdeLink link = new HdeLink(pin.InternalCOMInterf, src);
                            this.pendinglinks.Add(pin.InternalCOMInterf, link);
                        }
                    }
                }
            }

            if (pin.Direction == PinDirection.Output && io != null && pin.Type.StartsWith("DX11Resource"))
            {
                DX11OutputPin vop = new DX11OutputPin(vn, pin.InternalCOMInterf, io);
            }
        }
예제 #3
0
        private void UnSetLink(IPin sink, IPin source)
        {
            DX11Node sinknode   = this.graph.FindNode(sink.ParentNode);
            DX11Node sourcenode = this.graph.FindNode(source.ParentNode);

            if (sinknode != null && sourcenode != null)
            {
                DX11InputPin  sinkpin   = sinknode.GetInput(sink.Name);
                DX11OutputPin sourcepin = sourcenode.GetOutput(source.Name);

                sinkpin.Disconnect(sourcepin);
            }
        }
예제 #4
0
        private void ProcessNode(DX11Node node)
        {
            //Node already processed
            if (this.processed.Contains(node))
            {
                return;
            }

            //Node can block processing and do early graph cut
            if (node.IsAssignable <IDX11UpdateBlocker>())
            {
                if (!node.Instance <IDX11UpdateBlocker>().Enabled)
                {
                    //Add to processed list and early exit on branch.
                    this.processed.Add(node);
                    return;
                }
            }

            //Got to all parents recursively (eg: make sure all is updated)
            foreach (DX11InputPin ip in node.InputPins)
            {
                if (ip.IsConnected && (ip.ParentPin.IsFeedBackPin == false))
                {
                    this.ProcessNode(ip.ParentPin.ParentNode);
                }
            }

            //Call Update
            foreach (DX11InputPin ip in node.InputPins)
            {
                if (ip.IsConnected)
                {
                    DX11OutputPin parent = ip.ParentPin;

                    if (!this.thisframepins.Contains(parent))
                    {
                        DX11Node source = parent.ParentNode;

                        IDX11ResourceProvider provider = source.Instance <IDX11ResourceProvider>();

                        try
                        {
                            provider.Update(parent.PluginIO, this.context);

                            if (source.IsAssignable <IDX11MultiResourceProvider>())
                            {
                                if (this.DoNotDestroy == false)
                                {
                                    //Mark all output pins as processed
                                    foreach (DX11OutputPin outpin in source.OutputPins)
                                    {
                                        this.thisframepins.Add(outpin);
                                    }
                                }
                            }
                            else
                            {
                                if (this.DoNotDestroy == false)
                                {
                                    //Mark output pin as used this frame
                                    this.thisframepins.Add(parent);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            this.logger.Log(LogType.Error, "Exception caused by node during update :" + node.HdeNode.GetNodePath(false));
                            this.logger.Log(ex);
                            this.logger.Log(LogType.Message, "Stack Trace");
                            this.logger.Log(LogType.Message, ex.StackTrace);
                        }

                        if (this.DoNotDestroy == false)
                        {
                            //Remove from old cache if applicable
                            if (this.lastframepins.Contains(parent))
                            {
                                this.lastframepins.Remove(parent);
                            }
                        }
                    }
                }
            }

            //Render if renderer
            if (node.IsAssignable <IDX11RendererProvider>())
            {
                try
                {
                    IDX11RendererProvider provider = node.Instance <IDX11RendererProvider>();
                    provider.Render(this.context);
                }
                catch (Exception ex)
                {
                    this.logger.Log(LogType.Error, "Exception caused by node during render :" + node.HdeNode.GetNodePath(false));
                    this.logger.Log(ex);
                    this.logger.Log(LogType.Message, "Stack Trace");
                    this.logger.Log(LogType.Message, ex.StackTrace);
                }
            }

            //Node fully processed
            this.processed.Add(node);
        }
예제 #5
0
        private void ProcessNode(DX11Node node)
        {
            //Node already processed
            if (this.processed.Contains(node))
            {
                return;
            }

            //Node can block processing and do early graph cut
            if (node.Interfaces.IsUpdateBlocker)
            {
                if (!node.Interfaces.UpdateBlocker.Enabled)
                {
                    //Add to processed list and early exit on branch.
                    this.processed.Add(node);
                    return;
                }
            }

            for (int i = 0; i < node.InputPins.Count; i++)
            {
                DX11InputPin ip = node.InputPins[i];
                if (ip.IsConnected && (ip.ParentPin.IsFeedBackPin == false))
                {
                    this.ProcessNode(ip.ParentPin.ParentNode);
                }
            }
            for (int i = 0; i < node.VirtualConnections.Count; i++)
            {
                this.ProcessNode(node.VirtualConnections[i].sourceNode);
            }


            //Call Update
            for (int i = 0; i < node.InputPins.Count; i++)
            {
                DX11InputPin ip = node.InputPins[i];
                if (ip.IsConnected)
                {
                    DX11OutputPin parent = ip.ParentPin;

                    if (!this.thisframepins.Contains(parent))
                    {
                        DX11Node source = parent.ParentNode;

                        try
                        {
                            if (source.Interfaces.IsResourceHost)
                            {
                                source.Interfaces.ResourceHost.Update(this.context);
                                if (this.DoNotDestroy == false)
                                {
                                    //Mark all output pins as processed
                                    foreach (DX11OutputPin outpin in source.OutputPins)
                                    {
                                        this.thisframepins.Add(outpin);

                                        //Remove from old cache if applicable
                                        if (this.lastframepins.Contains(outpin))
                                        {
                                            this.lastframepins.Remove(outpin);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            this.logger.Log(LogType.Error, "Exception caused by node during update :" + node.HdeNode.GetNodePath(false));
                            this.logger.Log(ex);
                            this.logger.Log(LogType.Message, "Stack Trace");
                            this.logger.Log(LogType.Message, ex.StackTrace);
                        }
                    }
                }
            }

            //Render if renderer
            if (node.Interfaces.IsRendererHost)
            {
                try
                {
                    if (node.Interfaces.IsRendererHost)
                    {
                        node.Interfaces.RendererHost.Render(this.context);
                    }
                }
                catch (Exception ex)
                {
                    this.logger.Log(LogType.Error, "Exception caused by node during render :" + node.HdeNode.GetNodePath(false));
                    this.logger.Log(ex);
                    this.logger.Log(LogType.Message, "Stack Trace");
                    this.logger.Log(LogType.Message, ex.StackTrace);
                }
            }

            //Node fully processed
            this.processed.Add(node);
        }