Exemplo n.º 1
0
 public TemplateMatcher(NodeGrouper nodeGrouper)
 {
     _templates = new List <INodeTemplate>
     {
         new AddConstantsTemplate(this),
         new AddNegateTemplate(),
         new AddNegativeTemplate(this),
         new AddSelfTemplate(),
         new AddZeroTemplate(this),
         new MoveTemplate(),
         new MultiplyAddTemplate(),
         new MultiplyConstantsTemplate(this),
         new MultiplyConstantTemplate(this),
         new MultiplyNegativeOneTemplate(this),
         new MultiplyOneTemplate(this),
         new MultiplyReciprocalDivisionTemplate(this),
         new MultiplyZeroTemplate(this),
         new NegateConstantTemplate(this),
         new NegateNegateTemplate(),
         new ReciprocalReciprocalSquareRootTemplate(this),
         new ReciprocalSquareRootTemplate(),
         new SubtractNegateTemplate(),
         new SubtractZeroTemplate(this)
     };
     _groupTemplates = new List <IGroupTemplate>
     {
         new DotProduct2Template(this),
         new DotProduct3Template(this),
         new DotProduct4Template(this),
         new LengthTemplate()
     };
     _nodeGrouper = nodeGrouper;
 }
Exemplo n.º 2
0
 public IGroupContext Match(HlslTreeNode node)
 {
     if (node is SquareRootOperation sqrt && sqrt.Value is DotProductOperation dot)
     {
         if (NodeGrouper.AreNodesEquivalent(dot.X, dot.Y))
         {
             return(new LengthContext(new GroupNode(new List <HlslTreeNode>(dot.X.Inputs).ToArray())));
         }
     }
     return(null);
 }
Exemplo n.º 3
0
        public HlslTreeNode[] TryGetLengthContext(HlslTreeNode node)
        {
            if (!(node is SquareRootOperation squareRoot))
            {
                return(null);
            }

            DotProductContext dotProduct = _nodeGrouper.DotProductGrouper.TryGetDotProductGroup(squareRoot.Value);

            if (dotProduct == null)
            {
                return(null);
            }

            if (NodeGrouper.IsVectorEquivalent(dotProduct.Value1, dotProduct.Value2) == false)
            {
                return(null);
            }

            return(dotProduct.Value1);
        }
Exemplo n.º 4
0
 public NodeGroup(string name, NodeGrouper grouper)
     : this(name, grouper, null)
 {
 }
Exemplo n.º 5
0
 public NodeGroup(string name, object extra, NodeGrouper grouper)
 {
     this.groupName = name;
     this.grouper   = grouper;
     this.extra     = extra;
 }
Exemplo n.º 6
0
 public LengthGrouper(NodeGrouper nodeGrouper)
 {
     _nodeGrouper = nodeGrouper;
 }