LCOV - code coverage report
Current view: top level - gfx/angle/src/compiler/translator - BuiltInFunctionEmulator.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 1 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //
       2             : // Copyright (c) 2011 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             : 
       7             : #ifndef COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATOR_H_
       8             : #define COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATOR_H_
       9             : 
      10             : #include "compiler/translator/InfoSink.h"
      11             : #include "compiler/translator/IntermNode.h"
      12             : 
      13             : namespace sh
      14             : {
      15             : 
      16             : //
      17             : // This class decides which built-in functions need to be replaced with the
      18             : // emulated ones.
      19             : // It can be used to work around driver bugs or implement functions that are
      20             : // not natively implemented on a specific platform.
      21             : //
      22           0 : class BuiltInFunctionEmulator
      23             : {
      24             :   public:
      25             :     BuiltInFunctionEmulator();
      26             : 
      27             :     void MarkBuiltInFunctionsForEmulation(TIntermNode *root);
      28             : 
      29             :     void Cleanup();
      30             : 
      31             :     // "name(" becomes "webgl_name_emu(".
      32             :     static TString GetEmulatedFunctionName(const TString &name);
      33             : 
      34             :     bool IsOutputEmpty() const;
      35             : 
      36             :     // Output function emulation definition. This should be before any other
      37             :     // shader source.
      38             :     void OutputEmulatedFunctions(TInfoSinkBase &out) const;
      39             : 
      40             :     // Add functions that need to be emulated.
      41             :     void addEmulatedFunction(TOperator op, const TType *param, const char *emulatedFunctionDefinition);
      42             :     void addEmulatedFunction(TOperator op, const TType *param1, const TType *param2,
      43             :                              const char *emulatedFunctionDefinition);
      44             :     void addEmulatedFunction(TOperator op, const TType *param1, const TType *param2, const TType *param3,
      45             :                              const char *emulatedFunctionDefinition);
      46             : 
      47             :   private:
      48             :     class BuiltInFunctionEmulationMarker;
      49             : 
      50             :     // Records that a function is called by the shader and might need to be
      51             :     // emulated. If the function is not in mEmulatedFunctions, this becomes a
      52             :     // no-op. Returns true if the function call needs to be replaced with an
      53             :     // emulated one.
      54             :     bool SetFunctionCalled(TOperator op, const TType &param);
      55             :     bool SetFunctionCalled(TOperator op, const TType &param1, const TType &param2);
      56             :     bool SetFunctionCalled(TOperator op, const TType &param1, const TType &param2, const TType &param3);
      57             : 
      58             :     class FunctionId {
      59             :       public:
      60             :         FunctionId(TOperator op, const TType *param);
      61             :         FunctionId(TOperator op, const TType *param1, const TType *param2);
      62             :         FunctionId(TOperator op, const TType *param1, const TType *param2, const TType *param3);
      63             : 
      64             :         bool operator==(const FunctionId &other) const;
      65             :         bool operator<(const FunctionId &other) const;
      66             : 
      67             :         FunctionId getCopy() const;
      68             :       private:
      69             :         TOperator mOp;
      70             : 
      71             :         // The memory that these TType objects use is freed by PoolAllocator. The BuiltInFunctionEmulator's lifetime
      72             :         // can extend until after the memory pool is freed, but that's not an issue since this class never destructs
      73             :         // these objects.
      74             :         const TType *mParam1;
      75             :         const TType *mParam2;
      76             :         const TType *mParam3;
      77             :     };
      78             : 
      79             :     bool SetFunctionCalled(const FunctionId &functionId);
      80             : 
      81             :     // Map from function id to emulated function definition
      82             :     std::map<FunctionId, std::string> mEmulatedFunctions;
      83             : 
      84             :     // Called function ids
      85             :     std::vector<FunctionId> mFunctions;
      86             : };
      87             : 
      88             : }  // namespace sh
      89             : 
      90             : #endif  // COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATOR_H_

Generated by: LCOV version 1.13