Esempio n. 1
0
        public void Render(List <DX11Node> windownodes)
        {
            foreach (DX11Node windownode in windownodes)
            {
                this.ProcessNode(windownode);
            }

            if (this.DoNotDestroy == false)
            {
                //Call destroy on any pin which has not being used
                foreach (DX11OutputPin unused in this.lastframepins)
                {
                    //Check here, at end of render the com objects are already dead
                    try
                    {
                        //In case node has been deleted, we already called dispose
                        if (this.graph.Nodes.Contains(unused.ParentNode))
                        {
                            IDX11ResourceProvider provider = unused.ParentNode.Instance <IDX11ResourceProvider>();
                            provider.Destroy(unused.PluginIO, this.context, false);
                        }
                    }
                    catch (Exception ex)
                    {
                        this.logger.Log(ex);
                    }
                }

                //Swap pin buffers for next frame
                List <DX11OutputPin> temp = this.thisframepins;
                this.thisframepins = this.lastframepins;
                this.lastframepins = temp;
            }
        }
Esempio n. 2
0
 public DX11NodeInterfaces(IInternalPluginHost hoster)
 {
     this.hoster                = hoster;
     this.resourceProvider      = this.IsAssignable <IDX11ResourceProvider>() ? this.Instance <IDX11ResourceProvider>() : null;
     this.rendererProvider      = this.IsAssignable <IDX11RendererProvider>() ? this.Instance <IDX11RendererProvider>() : null;
     this.renderWindow          = this.IsAssignable <IDX11RenderWindow>() ? this.Instance <IDX11RenderWindow>() : null;
     this.multiResourceProvider = this.IsAssignable <IDX11MultiResourceProvider>() ? this.Instance <IDX11MultiResourceProvider>() : null;
     this.layerProvider         = this.IsAssignable <IDX11LayerProvider>() ? this.Instance <IDX11LayerProvider>() : null;
     this.dataRetriever         = this.IsAssignable <IDX11ResourceDataRetriever>() ? this.Instance <IDX11ResourceDataRetriever>() : null;
     this.updateBlocker         = this.IsAssignable <IDX11UpdateBlocker>() ? this.Instance <IDX11UpdateBlocker>() : null;
 }
Esempio n. 3
0
        public void Dispose()
        {
            foreach (DX11Node node in this.graph.Nodes)
            {
                foreach (DX11OutputPin outpin in node.OutputPins)
                {
                    //Call destroy
                    IDX11ResourceProvider provider = outpin.ParentNode.Instance <IDX11ResourceProvider>();

                    try
                    {
                        provider.Destroy(outpin.PluginIO, this.context, true);
                    }
                    catch (Exception ex)
                    {
                        logger.Log(ex);
                    }
                }
            }
        }
Esempio n. 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);
        }