gfx/angle/src/compiler/BuiltInFunctionEmulator.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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 //
     7 #ifndef COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_
     8 #define COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_
    10 #include "GLSLANG/ShaderLang.h"
    12 #include "compiler/InfoSink.h"
    13 #include "compiler/intermediate.h"
    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 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     bool SetFunctionCalled(
    32         TOperator op, const TType& param1, const TType& param2, const TType& param3);
    34     // Output function emulation definition.  This should be before any other
    35     // shader source.
    36     void OutputEmulatedFunctionDefinition(TInfoSinkBase& out, bool withPrecision) const;
    38     void MarkBuiltInFunctionsForEmulation(TIntermNode* root);
    40     void Cleanup();
    42     // "name(" becomes "webgl_name_emu(".
    43     static TString GetEmulatedFunctionName(const TString& name);
    45 private:
    46     //
    47     // Built-in functions.
    48     //
    49     enum TBuiltInFunction {
    50         TFunctionCos1 = 0,  // float cos(float);
    51         TFunctionCos2,  // vec2 cos(vec2);
    52         TFunctionCos3,  // vec3 cos(vec3);
    53         TFunctionCos4,  // vec4 cos(vec4);
    55         TFunctionDistance1_1,  // float distance(float, float);
    56         TFunctionDistance2_2,  // vec2 distance(vec2, vec2);
    57         TFunctionDistance3_3,  // vec3 distance(vec3, vec3);
    58         TFunctionDistance4_4,  // vec4 distance(vec4, vec4);
    60         TFunctionDot1_1,  // float dot(float, float);
    61         TFunctionDot2_2,  // vec2 dot(vec2, vec2);
    62         TFunctionDot3_3,  // vec3 dot(vec3, vec3);
    63         TFunctionDot4_4,  // vec4 dot(vec4, vec4);
    65         TFunctionFaceForward1_1_1,  // float faceforward(float, float, float);
    66         TFunctionFaceForward2_2_2,  // vec2 faceforward(vec2, vec2, vec2);
    67         TFunctionFaceForward3_3_3,  // vec3 faceforward(vec3, vec3, vec3);
    68         TFunctionFaceForward4_4_4,  // vec4 faceforward(vec4, vec4, vec4);
    70         TFunctionLength1,  // float length(float);
    71         TFunctionLength2,  // float length(vec2);
    72         TFunctionLength3,  // float length(vec3);
    73         TFunctionLength4,  // float length(vec4);
    75         TFunctionNormalize1,  // float normalize(float);
    76         TFunctionNormalize2,  // vec2 normalize(vec2);
    77         TFunctionNormalize3,  // vec3 normalize(vec3);
    78         TFunctionNormalize4,  // vec4 normalize(vec4);
    80         TFunctionReflect1_1,  // float reflect(float, float);
    81         TFunctionReflect2_2,  // vec2 reflect(vec2, vec2);
    82         TFunctionReflect3_3,  // vec3 reflect(vec3, vec3);
    83         TFunctionReflect4_4,  // vec4 reflect(vec4, vec4);
    85         TFunctionUnknown
    86     };
    88     TBuiltInFunction IdentifyFunction(TOperator op, const TType& param);
    89     TBuiltInFunction IdentifyFunction(
    90         TOperator op, const TType& param1, const TType& param2);
    91     TBuiltInFunction IdentifyFunction(
    92         TOperator op, const TType& param1, const TType& param2, const TType& param3);
    94     bool SetFunctionCalled(TBuiltInFunction function);
    96     std::vector<TBuiltInFunction> mFunctions;
    98     const bool* mFunctionMask;  // a boolean flag for each function.
    99     const char** mFunctionSource;
   100 };
   102 #endif  // COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_

mercurial