private void UpdateNode(DX11Node node) { try { if (node.Interfaces.IsResourceHost) { node.Interfaces.ResourceHost.Update(this.context); if (this.DoNotDestroy == false) { //Mark all output pins as processed foreach (DX11OutputPin outpin in node.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(LogType.Error, "Exception node name :" + node.HdeNode2.Name); this.logger.Log(ex); this.logger.Log(LogType.Message, "Stack Trace"); this.logger.Log(LogType.Message, ex.StackTrace); } }
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); } }
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); } }
public void AddNode(DX11Node node) { this.nodes.Add(node); if (node.Interfaces.IsRenderWindow) { this.renderwindows.Add(node); } }
public void Render(IDX11ResourceDataRetriever sender, IPluginHost host) { //Assign device to sender sender.AssignedContext = this.context; //Called by stuff like info DX11Node node = this.graph.FindNode(host); this.ProcessNode(node); }
private void PresentWindow(DX11Node window) { try { window.Interfaces.RenderStartPoint.Present(); } catch (Exception ex) { this.logger.Log(LogType.Error, "Failed to present render window"); this.logger.Log(ex); } }
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); } }
protected override bool ProcessRemovedPin(IPin2 pin) { DX11Node vn = this.graph.FindNode(pin.ParentNode); if (vn != null) { vn.RemovePin(pin.InternalCOMInterf.Name, pin.InternalCOMInterf.Direction); if (reg.pinconnections.ContainsKey(pin.InternalCOMInterf)) { reg.pinconnections.Remove(pin.InternalCOMInterf); } } return(false); }
protected override bool ProcessRemovedNode(INode2 node) { DX11Node vn = this.graph.FindNode(node); if (vn != null) { foreach (IPin2 pin in node.Pins) { this.ProcessRemovedPin(pin); } this.graph.Nodes.Remove(vn); return(true); } return(false); }
protected override bool ProcessAddedPin(IPin2 pin, bool immediate) { DX11Node vn = this.graph.FindNode(pin.ParentNode); if (vn != null) { if (immediate) { this.AddPin(pin); } else { this.pendingpins.Add(pin); } } return(false); }
private void RemoveAdditionalConnection(IPin sink) { if (sink as IPluginIO == null) { return; } DX11Node sinknode = this.graph.FindNode(sink.ParentNode); if (sinknode != null) { DX11VirtualConnection connection = sinknode.GetVirtualConnection(sink); if (connection != null) { sinknode.VirtualConnections.Remove(connection); } } }
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; } } //Recurse upper nodes and virtual connctions 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); } //Node should be ready, now update this.UpdateNode(node); this.RenderNode(node); //Node fully processed this.processed.Add(node); }
private void RenderNode(DX11Node node) { //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(LogType.Error, "Node name :" + node.HdeNode2.Name); this.logger.Log(ex); this.logger.Log(LogType.Message, "Stack Trace"); this.logger.Log(LogType.Message, ex.StackTrace); } } }
private void CreateAdditionalConnection(IPin sink, IPin source) { if (sink as IPluginIO == null || source as IPluginIO == null) { return; } DX11Node sinknode = this.graph.FindNode(sink.ParentNode); DX11Node sourcenode = this.graph.FindNode(source.ParentNode); if (sinknode != null && sourcenode != null) { DX11VirtualConnection existing = sinknode.GetVirtualConnection(sink); if (existing != null) { sinknode.VirtualConnections.Remove(existing); } DX11VirtualConnection connection = new DX11VirtualConnection(sink, source, sourcenode); sinknode.VirtualConnections.Add(connection); } }
protected override bool ProcessAddedNode(INode2 node) { if (node.IsNodeAssignableFrom <N>() || node.IsNodeAssignableFrom <IDX11ResourceDataRetriever>()) { DX11Node vn = new DX11Node(node.InternalCOMInterf); this.graph.Nodes.Add(vn); //If force updater, register event if (node.IsNodeAssignableFrom <IDX11ResourceDataRetriever>()) { IDX11ResourceDataRetriever updater = vn.Instance <IDX11ResourceDataRetriever>(); updater.RenderRequest += OnRenderRequest; } foreach (IPin2 p in node.Pins) { this.ProcessAddedPin(p, true); } return(true); } return(false); }
public void RemoveNode(DX11Node node) { this.nodes.Remove(node); this.renderwindows.Remove(node); }
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; } } //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.Interfaces.ResourceProvider; try { provider.Update(parent.PluginIO, this.context); if (source.Interfaces.IsMultiResourceProvider) { 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.Interfaces.IsRendererProvider) { try { IDX11RendererProvider provider = node.Interfaces.RendererProvider; 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); }
public DX11InputPin(DX11Node parentnode) : base(parentnode) { this.ParentNode.InputPins.Add(this); }
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>()) { //Mark all output pins as processed foreach (DX11OutputPin outpin in source.OutputPins) { this.thisframepins.Add(outpin); } } else { //Mark output pin as used this frame this.thisframepins.Add(parent); } } catch (Exception ex) { this.logger.Log(ex); //Log } //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(ex); } } //Node fully processed this.processed.Add(node); }
public DX11Pin(DX11Node parentnode) { this.ParentNode = parentnode; }
public DX11OutputPin(DX11Node parentnode) : base(parentnode) { this.ChildrenPins = new List<DX11InputPin>(); this.ParentNode.OutputPins.Add(this); }
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); }
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); }