Home | History | Annotate | Download | only in compiler
      1 //
      2 // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
      3 // Use of this source code is governed by a BSD-style license that can be
      4 // found in the LICENSE file.
      5 //
      6 // Contains analysis utilities for dealing with HLSL's lack of support for
      7 // the use of intrinsic functions which (implicitly or explicitly) compute
      8 // gradients of functions with discontinuities.
      9 //
     10 
     11 #ifndef COMPILER_DETECTDISCONTINUITY_H_
     12 #define COMPILER_DETECTDISCONTINUITY_H_
     13 
     14 #include "compiler/intermediate.h"
     15 
     16 namespace sh
     17 {
     18 // Checks whether a loop can run for a variable number of iterations
     19 class DetectLoopDiscontinuity : public TIntermTraverser
     20 {
     21   public:
     22     bool traverse(TIntermNode *node);
     23 
     24   protected:
     25     bool visitBranch(Visit visit, TIntermBranch *node);
     26     bool visitLoop(Visit visit, TIntermLoop *loop);
     27     bool visitAggregate(Visit visit, TIntermAggregate *node);
     28 
     29     int mLoopDepth;
     30     bool mLoopDiscontinuity;
     31 };
     32 
     33 bool containsLoopDiscontinuity(TIntermNode *node);
     34 
     35 // Checks for intrinsic functions which compute gradients
     36 class DetectGradientOperation : public TIntermTraverser
     37 {
     38   public:
     39     bool traverse(TIntermNode *node);
     40 
     41   protected:
     42     bool visitUnary(Visit visit, TIntermUnary *node);
     43     bool visitAggregate(Visit visit, TIntermAggregate *node);
     44 
     45     bool mGradientOperation;
     46 };
     47 
     48 bool containsGradientOperation(TIntermNode *node);
     49 
     50 }
     51 
     52 #endif   // COMPILER_DETECTDISCONTINUITY_H_
     53