gfx/angle/src/compiler/BuiltInFunctionEmulator.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial