LCOV - code coverage report
Current view: directory - gfx/angle/src/compiler - BuiltInFunctionEmulator.h (source / functions) Found Hit Coverage
Test: app.info Lines: 1 0 0.0 %
Date: 2012-06-02 Functions: 1 0 0.0 %

       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 COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_
       8                 : #define COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_
       9                 : 
      10                 : #include "GLSLANG/ShaderLang.h"
      11                 : 
      12                 : #include "compiler/InfoSink.h"
      13                 : #include "compiler/intermediate.h"
      14                 : 
      15                 : //
      16                 : // This class decides which built-in functions need to be replaced with the
      17                 : // emulated ones.
      18                 : // It's only a workaround for OpenGL driver bugs, and isn't needed in general.
      19                 : //
      20               0 : class BuiltInFunctionEmulator {
      21                 : public:
      22                 :     BuiltInFunctionEmulator(ShShaderType shaderType);
      23                 :     // Records that a function is called by the shader and might needs to be
      24                 :     // emulated.  If the function's group is not in mFunctionGroupFilter, this
      25                 :     // becomes an no-op.
      26                 :     // Returns true if the function call needs to be replaced with an emulated
      27                 :     // one.
      28                 :     bool SetFunctionCalled(TOperator op, const TType& param);
      29                 :     bool SetFunctionCalled(
      30                 :         TOperator op, const TType& param1, const TType& param2);
      31                 : 
      32                 :     // Output function emulation definition.  This should be before any other
      33                 :     // shader source.
      34                 :     void OutputEmulatedFunctionDefinition(TInfoSinkBase& out, bool withPrecision) const;
      35                 : 
      36                 :     void MarkBuiltInFunctionsForEmulation(TIntermNode* root);
      37                 : 
      38                 :     void Cleanup();
      39                 : 
      40                 :     // "name(" becomes "webgl_name_emu(".
      41                 :     static TString GetEmulatedFunctionName(const TString& name);
      42                 : 
      43                 : private:
      44                 :     //
      45                 :     // Built-in functions.
      46                 :     //
      47                 :     enum TBuiltInFunction {
      48                 :         TFunctionAtan1_1 = 0,  // float atan(float, float);
      49                 :         TFunctionAtan2_2,  // vec2 atan(vec2, vec2);
      50                 :         TFunctionAtan3_3,  // vec3 atan(vec3, vec2);
      51                 :         TFunctionAtan4_4,  // vec4 atan(vec4, vec2);
      52                 : 
      53                 :         TFunctionCos1,  // float cos(float);
      54                 :         TFunctionCos2,  // vec2 cos(vec2);
      55                 :         TFunctionCos3,  // vec3 cos(vec3);
      56                 :         TFunctionCos4,  // vec4 cos(vec4);
      57                 : 
      58                 :         TFunctionDistance1_1,  // float distance(float, float);
      59                 :         TFunctionDistance2_2,  // vec2 distance(vec2, vec2);
      60                 :         TFunctionDistance3_3,  // vec3 distance(vec3, vec3);
      61                 :         TFunctionDistance4_4,  // vec4 distance(vec4, vec4);
      62                 : 
      63                 :         TFunctionDot1_1,  // float dot(float, float);
      64                 :         TFunctionDot2_2,  // vec2 dot(vec2, vec2);
      65                 :         TFunctionDot3_3,  // vec3 dot(vec3, vec3);
      66                 :         TFunctionDot4_4,  // vec4 dot(vec4, vec4);
      67                 : 
      68                 :         TFunctionLength1,  // float length(float);
      69                 :         TFunctionLength2,  // float length(vec2);
      70                 :         TFunctionLength3,  // float length(vec3);
      71                 :         TFunctionLength4,  // float length(vec4);
      72                 : 
      73                 :         TFunctionMod1_1,  // float mod(float, float);
      74                 :         TFunctionMod2_2,  // vec2 mod(vec2, vec2);
      75                 :         TFunctionMod3_3,  // vec3 mod(vec3, vec3);
      76                 :         TFunctionMod4_4,  // vec4 mod(vec4, vec4);
      77                 : 
      78                 :         TFunctionNormalize1,  // float normalize(float);
      79                 :         TFunctionNormalize2,  // vec2 normalize(vec2);
      80                 :         TFunctionNormalize3,  // vec3 normalize(vec3);
      81                 :         TFunctionNormalize4,  // vec4 normalize(vec4);
      82                 : 
      83                 :         TFunctionReflect1_1,  // float reflect(float, float);
      84                 :         TFunctionReflect2_2,  // vec2 reflect(vec2, vec2);
      85                 :         TFunctionReflect3_3,  // vec3 reflect(vec3, vec3);
      86                 :         TFunctionReflect4_4,  // vec4 reflect(vec4, vec4);
      87                 : 
      88                 :         TFunctionUnknown
      89                 :     };
      90                 : 
      91                 :     TBuiltInFunction IdentifyFunction(TOperator op, const TType& param);
      92                 :     TBuiltInFunction IdentifyFunction(
      93                 :         TOperator op, const TType& param1, const TType& param2);
      94                 : 
      95                 :     bool SetFunctionCalled(TBuiltInFunction function);
      96                 : 
      97                 :     std::vector<TBuiltInFunction> mFunctions;
      98                 : 
      99                 :     const bool* mFunctionMask;  // a boolean flag for each function.
     100                 :     const char** mFunctionSource;
     101                 : };
     102                 : 
     103                 : #endif  // COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_

Generated by: LCOV version 1.7