diff options
author | Andrew Knight <andrew.knight@intopalo.com> | 2015-04-08 17:04:36 +0300 |
---|---|---|
committer | Andrew Knight <qt@panimo.net> | 2015-04-09 10:31:12 +0000 |
commit | a218a252c4200cfe7048de81a46f7e48349084d5 (patch) | |
tree | c1a82865d97e610cd0abb3a1360408363b38205b /src/3rdparty/angle/src/compiler/translator/Initialize.cpp | |
parent | 331ddacfca90c91c5b44484bf3c78e2aa5b85947 (diff) | |
download | qtbase-a218a252c4200cfe7048de81a46f7e48349084d5.tar.gz |
Upgrade ANGLE to 2.1~99f075dade7c
This aligns with Chromium branch 2356.
This version brings more complete OpenGL ES 3 support as well as various
bug fixes and performance improvements.
The following changes were made to earlier patches:
-0000-General-fixes-for-ANGLE-2.1
Removed. All changes are now handled elsewhere.
+0001-ANGLE-Improve-Windows-Phone-support
Consolidated remaining parts from 0009/0010.
+0002-ANGLE-Fix-compilation-with-MinGW
Remaining issues from patch 0016.
+0003-ANGLE-Fix-compilation-with-MSVC2010
Remaining issues from patch 0015.
+0004-ANGLE-Dynamically-load-D3D-compiler-from-list
Renamed from patch 0008.
+0005-ANGLE-Add-support-for-querying-platform-device
Renamed from patch 0013.
-0004-Make-it-possible-to-link-ANGLE-statically-for-single
Removed. Fixed by adding defines to project files.
-0008-ANGLE-Dynamically-load-D3D-compiler-from-a-list-or-t
Renamed to patch 0005.
-0009-ANGLE-Support-WinRT
Removed. Mostly fixed upstream; remaining parts in patch 0001.
-0010-ANGLE-Enable-D3D11-for-feature-level-9-cards
Removed. Mostly fixed upstream; remaining parts in patch 0001.
-0012-ANGLE-fix-semantic-index-lookup
Removed. Fixed upstream.
-0013-ANGLE-Add-support-for-querying-platform-device
Renamed to patch 0005.
-0014-Let-ANGLE-use-multithreaded-devices-if-necessary
Removed. No longer needed.
-0015-ANGLE-Fix-angle-d3d11-on-MSVC2010
Moved remaining parts to patch 0003.
-0016-ANGLE-Fix-compilation-with-MinGW-D3D11
Moved remaining parts to patch 0002.
-0017-ANGLE-Fix-compilation-with-D3D9
Removed. Fixed upstream.
-0018-ANGLE-Fix-releasing-textures-after-we-kill-D3D11
Removed. Fixed upstream.
-0019-ANGLE-Fix-handling-of-shader-source-with-fixed-lengt
Removed. Fixed upstream.
-0020-ANGLE-Do-not-use-std-strlen
Removed. Fixed upstream.
-0020-ANGLE-Fix-compilation-with-MSVC2013-Update4
Removed. Fixed upstream.
[ChangeLog][Third-party libraries] ANGLE was updated to Chromium branch
2356 (2.1~99f075dade7c).
Change-Id: I32ccbfe95e10986bd94be7191dfd53445ea09158
Task-number: QTBUG-44815
Task-number: QTBUG-37660
Task-number: QTBUG-44694
Task-number: QTBUG-42443
Reviewed-by: Andrew Knight <qt@panimo.net>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/Initialize.cpp')
-rw-r--r-- | src/3rdparty/angle/src/compiler/translator/Initialize.cpp | 703 |
1 files changed, 268 insertions, 435 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/Initialize.cpp b/src/3rdparty/angle/src/compiler/translator/Initialize.cpp index 10b21e6d28..9e11405758 100644 --- a/src/3rdparty/angle/src/compiler/translator/Initialize.cpp +++ b/src/3rdparty/angle/src/compiler/translator/Initialize.cpp @@ -21,307 +21,208 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR TType *float2 = new TType(EbtFloat, 2); TType *float3 = new TType(EbtFloat, 3); TType *float4 = new TType(EbtFloat, 4); - TType *int1 = new TType(EbtInt); TType *int2 = new TType(EbtInt, 2); TType *int3 = new TType(EbtInt, 3); - TType *int4 = new TType(EbtInt, 4); + TType *uint1 = new TType(EbtUInt); + TType *bool1 = new TType(EbtBool); + TType *genType = new TType(EbtGenType); + TType *genIType = new TType(EbtGenIType); + TType *genUType = new TType(EbtGenUType); + TType *genBType = new TType(EbtGenBType); // // Angle and Trigonometric Functions. // - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "radians", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "radians", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "radians", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "radians", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "degrees", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "degrees", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "degrees", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "degrees", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sin", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sin", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sin", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sin", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "cos", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "cos", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "cos", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "cos", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "tan", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "tan", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "tan", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "tan", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "asin", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "asin", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "asin", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "asin", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "acos", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "acos", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "acos", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "acos", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "atan", float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "atan", float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "atan", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "atan", float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "atan", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "atan", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "atan", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "atan", float4); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpRadians, genType, "radians", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpDegrees, genType, "degrees", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSin, genType, "sin", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpCos, genType, "cos", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpTan, genType, "tan", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAsin, genType, "asin", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAcos, genType, "acos", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAtan, genType, "atan", genType, genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAtan, genType, "atan", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpSinh, genType, "sinh", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpCosh, genType, "cosh", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTanh, genType, "tanh", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAsinh, genType, "asinh", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAcosh, genType, "acosh", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAtanh, genType, "atanh", genType); // // Exponential Functions. // - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "pow", float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "pow", float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "pow", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "pow", float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "exp", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "exp", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "exp", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "exp", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "log", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "log", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "log", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "log", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "exp2", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "exp2", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "exp2", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "exp2", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "log2", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "log2", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "log2", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "log2", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sqrt", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sqrt", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sqrt", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sqrt", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "inversesqrt", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "inversesqrt", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "inversesqrt", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "inversesqrt", float4); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpPow, genType, "pow", genType, genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpExp, genType, "exp", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLog, genType, "log", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpExp2, genType, "exp2", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLog2, genType, "log2", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSqrt, genType, "sqrt", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpInverseSqrt, genType, "inversesqrt", genType); // // Common Functions. // - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "abs", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "abs", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "abs", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "abs", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sign", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sign", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sign", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sign", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "floor", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "floor", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "floor", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "floor", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "ceil", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "ceil", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "ceil", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "ceil", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "fract", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "fract", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "fract", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "fract", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mod", float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "min", float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "max", float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "clamp", float1, float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mix", float1, float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, float2, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, float3, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, float4, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "step", float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float4, float4); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float1, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float1, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float1, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "smoothstep", float1, float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float2, float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float3, float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float4, float4, float4); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float1, float1, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float1, float1, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float1, float1, float4); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAbs, genType, "abs", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAbs, genIType, "abs", genIType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSign, genType, "sign", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpSign, genIType, "sign", genIType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpFloor, genType, "floor", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTrunc, genType, "trunc", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpRound, genType, "round", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpRoundEven, genType, "roundEven", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpCeil, genType, "ceil", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpFract, genType, "fract", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMod, genType, "mod", genType, float1); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMod, genType, "mod", genType, genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMin, genType, "min", genType, float1); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMin, genType, "min", genType, genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genIType, "min", genIType, genIType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genIType, "min", genIType, int1); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genUType, "min", genUType, genUType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genUType, "min", genUType, uint1); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMax, genType, "max", genType, float1); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMax, genType, "max", genType, genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genIType, "max", genIType, genIType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genIType, "max", genIType, int1); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genUType, "max", genUType, genUType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genUType, "max", genUType, uint1); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpClamp, genType, "clamp", genType, float1, float1); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpClamp, genType, "clamp", genType, genType, genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genIType, "clamp", genIType, int1, int1); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genIType, "clamp", genIType, genIType, genIType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genUType, "clamp", genUType, uint1, uint1); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genUType, "clamp", genUType, genUType, genUType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMix, genType, "mix", genType, genType, float1); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMix, genType, "mix", genType, genType, genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpStep, genType, "step", genType, genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpStep, genType, "step", float1, genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSmoothStep, genType, "smoothstep", genType, genType, genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSmoothStep, genType, "smoothstep", float1, float1, genType); + + TType *outFloat1 = new TType(EbtFloat); + TType *outFloat2 = new TType(EbtFloat, 2); + TType *outFloat3 = new TType(EbtFloat, 3); + TType *outFloat4 = new TType(EbtFloat, 4); + outFloat1->setQualifier(EvqOut); + outFloat2->setQualifier(EvqOut); + outFloat3->setQualifier(EvqOut); + outFloat4->setQualifier(EvqOut); + + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float1, "modf", float1, outFloat1); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float2, "modf", float2, outFloat2); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float3, "modf", float3, outFloat3); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float4, "modf", float4, outFloat4); + + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpIsNan, genBType, "isnan", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpIsInf, genBType, "isinf", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpFloatBitsToInt, genIType, "floatBitsToInt", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpFloatBitsToUint, genUType, "floatBitsToUint", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpIntBitsToFloat, genType, "intBitsToFloat", genIType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUintBitsToFloat, genType, "uintBitsToFloat", genUType); + + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpPackSnorm2x16, uint1, "packSnorm2x16", float2); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpPackUnorm2x16, uint1, "packUnorm2x16", float2); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpPackHalf2x16, uint1, "packHalf2x16", float2); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUnpackSnorm2x16, float2, "unpackSnorm2x16", uint1); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUnpackUnorm2x16, float2, "unpackUnorm2x16", uint1); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUnpackHalf2x16, float2, "unpackHalf2x16", uint1); // // Geometric Functions. // - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "cross", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "normalize", float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "normalize", float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "normalize", float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "normalize", float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "faceforward", float1, float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "faceforward", float2, float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "faceforward", float3, float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "faceforward", float4, float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "reflect", float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "reflect", float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "reflect", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "reflect", float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "refract", float1, float1, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "refract", float2, float2, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "refract", float3, float3, float1); - symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "refract", float4, float4, float1); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLength, float1, "length", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpDistance, float1, "distance", genType, genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpDot, float1, "dot", genType, genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpCross, float3, "cross", float3, float3); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpNormalize, genType, "normalize", genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpFaceForward, genType, "faceforward", genType, genType, genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpReflect, genType, "reflect", genType, genType); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpRefract, genType, "refract", genType, genType, float1); TType *mat2 = new TType(EbtFloat, 2, 2); TType *mat3 = new TType(EbtFloat, 3, 3); TType *mat4 = new TType(EbtFloat, 4, 4); + TType *mat2x3 = new TType(EbtFloat, 2, 3); + TType *mat3x2 = new TType(EbtFloat, 3, 2); + TType *mat2x4 = new TType(EbtFloat, 2, 4); + TType *mat4x2 = new TType(EbtFloat, 4, 2); + TType *mat3x4 = new TType(EbtFloat, 3, 4); + TType *mat4x3 = new TType(EbtFloat, 4, 3); // // Matrix Functions. // - symbolTable.insertBuiltIn(COMMON_BUILTINS, mat2, "matrixCompMult", mat2, mat2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, mat3, "matrixCompMult", mat3, mat3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, mat4, "matrixCompMult", mat4, mat4); - - TType *bool1 = new TType(EbtBool); - TType *bool2 = new TType(EbtBool, 2); - TType *bool3 = new TType(EbtBool, 3); - TType *bool4 = new TType(EbtBool, 4); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMul, mat2, "matrixCompMult", mat2, mat2); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMul, mat3, "matrixCompMult", mat3, mat3); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMul, mat4, "matrixCompMult", mat4, mat4); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat2x3, "matrixCompMult", mat2x3, mat2x3); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat3x2, "matrixCompMult", mat3x2, mat3x2); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat2x4, "matrixCompMult", mat2x4, mat2x4); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat4x2, "matrixCompMult", mat4x2, mat4x2); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat3x4, "matrixCompMult", mat3x4, mat3x4); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat4x3, "matrixCompMult", mat4x3, mat4x3); + + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat2, "outerProduct", float2, float2); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat3, "outerProduct", float3, float3); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat4, "outerProduct", float4, float4); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat2x3, "outerProduct", float3, float2); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat3x2, "outerProduct", float2, float3); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat2x4, "outerProduct", float4, float2); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat4x2, "outerProduct", float2, float4); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat3x4, "outerProduct", float4, float3); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat4x3, "outerProduct", float3, float4); + + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat2, "transpose", mat2); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat3, "transpose", mat3); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat4, "transpose", mat4); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat2x3, "transpose", mat3x2); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat3x2, "transpose", mat2x3); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat2x4, "transpose", mat4x2); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat4x2, "transpose", mat2x4); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat3x4, "transpose", mat4x3); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat4x3, "transpose", mat3x4); + + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDeterminant, float1, "determinant", mat2); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDeterminant, float1, "determinant", mat3); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDeterminant, float1, "determinant", mat4); + + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat2, "inverse", mat2); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat3, "inverse", mat3); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat4, "inverse", mat4); + + TType *vec = new TType(EbtVec); + TType *ivec = new TType(EbtIVec); + TType *uvec = new TType(EbtUVec); + TType *bvec = new TType(EbtBVec); // // Vector relational functions. // - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", int2, int2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", int3, int3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", int4, int4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", int2, int2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", int3, int3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", int4, int4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", int2, int2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", int3, int3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", int4, int4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", int2, int2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", int3, int3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", int4, int4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", int2, int2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", int3, int3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", int4, int4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", bool2, bool2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", bool3, bool3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", bool4, bool4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", float2, float2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", float3, float3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", float4, float4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", int2, int2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", int3, int3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", int4, int4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", bool2, bool2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", bool3, bool3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", bool4, bool4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool4); - - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "not", bool2); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "not", bool3); - symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "not", bool4); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThan, bvec, "lessThan", vec, vec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThan, bvec, "lessThan", ivec, ivec); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpLessThan, bvec, "lessThan", uvec, uvec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThanEqual, bvec, "lessThanEqual", vec, vec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThanEqual, bvec, "lessThanEqual", ivec, ivec); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpLessThanEqual, bvec, "lessThanEqual", uvec, uvec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThan, bvec, "greaterThan", vec, vec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThan, bvec, "greaterThan", ivec, ivec); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpGreaterThan, bvec, "greaterThan", uvec, uvec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThanEqual, bvec, "greaterThanEqual", vec, vec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThanEqual, bvec, "greaterThanEqual", ivec, ivec); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpGreaterThanEqual, bvec, "greaterThanEqual", uvec, uvec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorEqual, bvec, "equal", vec, vec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorEqual, bvec, "equal", ivec, ivec); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpVectorEqual, bvec, "equal", uvec, uvec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorEqual, bvec, "equal", bvec, bvec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", vec, vec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", ivec, ivec); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", uvec, uvec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", bvec, bvec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAny, bool1, "any", bvec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAll, bool1, "all", bvec); + symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorLogicalNot, bvec, "not", bvec); TType *sampler2D = new TType(EbtSampler2D); TType *samplerCube = new TType(EbtSamplerCube); @@ -357,10 +258,10 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR /* The *Grad* variants are new to both vertex and fragment shaders; the fragment * shader specific pieces are added separately below. */ - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DGradEXT", sampler2D, float2, float2, float2); - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjGradEXT", sampler2D, float3, float2, float2); - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjGradEXT", sampler2D, float4, float2, float2); - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeGradEXT", samplerCube, float3, float3, float3); + symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DGradEXT", sampler2D, float2, float2, float2); + symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DProjGradEXT", sampler2D, float3, float2, float2); + symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DProjGradEXT", sampler2D, float4, float2, float2); + symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "textureCubeGradEXT", samplerCube, float3, float3, float3); } if (type == GL_FRAGMENT_SHADER) @@ -372,32 +273,21 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR if (resources.OES_standard_derivatives) { - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdx", float1); - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdx", float2); - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdx", float3); - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdx", float4); - - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdy", float1); - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdy", float2); - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdy", float3); - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdy", float4); - - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "fwidth", float1); - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "fwidth", float2); - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "fwidth", float3); - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "fwidth", float4); + symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdx, "GL_OES_standard_derivatives", genType, "dFdx", genType); + symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdy, "GL_OES_standard_derivatives", genType, "dFdy", genType); + symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpFwidth, "GL_OES_standard_derivatives", genType, "fwidth", genType); } if (resources.EXT_shader_texture_lod) { - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLodEXT", sampler2D, float2, float1); - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLodEXT", sampler2D, float3, float1); - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLodEXT", sampler2D, float4, float1); - symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLodEXT", samplerCube, float3, float1); + symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DLodEXT", sampler2D, float2, float1); + symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DProjLodEXT", sampler2D, float3, float1); + symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DProjLodEXT", sampler2D, float4, float1); + symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "textureCubeLodEXT", samplerCube, float3, float1); } } - if(type == GL_VERTEX_SHADER) + if (type == GL_VERTEX_SHADER) { symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLod", sampler2D, float2, float1); symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float3, float1); @@ -463,22 +353,11 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", samplerCubeShadow, int1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", sampler2DArrayShadow, int1); - if(type == GL_FRAGMENT_SHADER) + if (type == GL_FRAGMENT_SHADER) { - symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdx", float1); - symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdx", float2); - symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdx", float3); - symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdx", float4); - - symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdy", float1); - symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdy", float2); - symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdy", float3); - symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdy", float4); - - symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "fwidth", float1); - symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "fwidth", float2); - symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "fwidth", float3); - symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "fwidth", float4); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDFdx, genType, "dFdx", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDFdy, genType, "dFdy", genType); + symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpFwidth, genType, "fwidth", genType); } symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2); @@ -486,7 +365,7 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2); - if(type == GL_FRAGMENT_SHADER) + if (type == GL_FRAGMENT_SHADER) { symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3, float1); @@ -499,7 +378,7 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3); symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2); - if(type == GL_FRAGMENT_SHADER) + if (type == GL_FRAGMENT_SHADER) { symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2, float1); symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2, float1); @@ -600,146 +479,84 @@ void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec, TSymbolTable &symbolTable) { // - // First, insert some special built-in variables that are not in + // Insert some special built-in variables that are not in // the built-in header files. // - switch(type) { - case GL_FRAGMENT_SHADER: - symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4))); - symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1))); - symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointCoord"), TType(EbtFloat, EbpMedium, EvqPointCoord, 2))); + switch (type) + { + case GL_FRAGMENT_SHADER: + symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FragCoord"), + TType(EbtFloat, EbpMedium, EvqFragCoord, 4))); + symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FrontFacing"), + TType(EbtBool, EbpUndefined, EvqFrontFacing, 1))); + symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointCoord"), + TType(EbtFloat, EbpMedium, EvqPointCoord, 2))); // // In CSS Shaders, gl_FragColor, gl_FragData, and gl_MaxDrawBuffers are not available. // Instead, css_MixColor and css_ColorMatrix are available. // - if (spec != SH_CSS_SHADERS_SPEC) { - symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4))); - symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4))); - if (resources.EXT_frag_depth) { - symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragDepthEXT"), TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1))); - symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_FragDepthEXT", "GL_EXT_frag_depth"); - } - } else { - symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_MixColor"), TType(EbtFloat, EbpMedium, EvqGlobal, 4))); - symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_ColorMatrix"), TType(EbtFloat, EbpMedium, EvqGlobal, 4, 4))); - } - - break; - - case GL_VERTEX_SHADER: - symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4))); - symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1))); - break; - - default: assert(false && "Language not supported"); - } - - // - // Next, identify which built-ins from the already loaded headers have - // a mapping to an operator. Those that are not identified as such are - // expected to be resolved through a library of functions, versus as - // operations. - // - symbolTable.relateToOperator(COMMON_BUILTINS, "matrixCompMult", EOpMul); - - symbolTable.relateToOperator(COMMON_BUILTINS, "equal", EOpVectorEqual); - symbolTable.relateToOperator(COMMON_BUILTINS, "notEqual", EOpVectorNotEqual); - symbolTable.relateToOperator(COMMON_BUILTINS, "lessThan", EOpLessThan); - symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThan", EOpGreaterThan); - symbolTable.relateToOperator(COMMON_BUILTINS, "lessThanEqual", EOpLessThanEqual); - symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThanEqual", EOpGreaterThanEqual); - - symbolTable.relateToOperator(COMMON_BUILTINS, "radians", EOpRadians); - symbolTable.relateToOperator(COMMON_BUILTINS, "degrees", EOpDegrees); - symbolTable.relateToOperator(COMMON_BUILTINS, "sin", EOpSin); - symbolTable.relateToOperator(COMMON_BUILTINS, "cos", EOpCos); - symbolTable.relateToOperator(COMMON_BUILTINS, "tan", EOpTan); - symbolTable.relateToOperator(COMMON_BUILTINS, "asin", EOpAsin); - symbolTable.relateToOperator(COMMON_BUILTINS, "acos", EOpAcos); - symbolTable.relateToOperator(COMMON_BUILTINS, "atan", EOpAtan); - - symbolTable.relateToOperator(COMMON_BUILTINS, "pow", EOpPow); - symbolTable.relateToOperator(COMMON_BUILTINS, "exp2", EOpExp2); - symbolTable.relateToOperator(COMMON_BUILTINS, "log", EOpLog); - symbolTable.relateToOperator(COMMON_BUILTINS, "exp", EOpExp); - symbolTable.relateToOperator(COMMON_BUILTINS, "log2", EOpLog2); - symbolTable.relateToOperator(COMMON_BUILTINS, "sqrt", EOpSqrt); - symbolTable.relateToOperator(COMMON_BUILTINS, "inversesqrt", EOpInverseSqrt); - - symbolTable.relateToOperator(COMMON_BUILTINS, "abs", EOpAbs); - symbolTable.relateToOperator(COMMON_BUILTINS, "sign", EOpSign); - symbolTable.relateToOperator(COMMON_BUILTINS, "floor", EOpFloor); - symbolTable.relateToOperator(COMMON_BUILTINS, "ceil", EOpCeil); - symbolTable.relateToOperator(COMMON_BUILTINS, "fract", EOpFract); - symbolTable.relateToOperator(COMMON_BUILTINS, "mod", EOpMod); - symbolTable.relateToOperator(COMMON_BUILTINS, "min", EOpMin); - symbolTable.relateToOperator(COMMON_BUILTINS, "max", EOpMax); - symbolTable.relateToOperator(COMMON_BUILTINS, "clamp", EOpClamp); - symbolTable.relateToOperator(COMMON_BUILTINS, "mix", EOpMix); - symbolTable.relateToOperator(COMMON_BUILTINS, "step", EOpStep); - symbolTable.relateToOperator(COMMON_BUILTINS, "smoothstep", EOpSmoothStep); - - symbolTable.relateToOperator(COMMON_BUILTINS, "length", EOpLength); - symbolTable.relateToOperator(COMMON_BUILTINS, "distance", EOpDistance); - symbolTable.relateToOperator(COMMON_BUILTINS, "dot", EOpDot); - symbolTable.relateToOperator(COMMON_BUILTINS, "cross", EOpCross); - symbolTable.relateToOperator(COMMON_BUILTINS, "normalize", EOpNormalize); - symbolTable.relateToOperator(COMMON_BUILTINS, "faceforward", EOpFaceForward); - symbolTable.relateToOperator(COMMON_BUILTINS, "reflect", EOpReflect); - symbolTable.relateToOperator(COMMON_BUILTINS, "refract", EOpRefract); - - symbolTable.relateToOperator(COMMON_BUILTINS, "any", EOpAny); - symbolTable.relateToOperator(COMMON_BUILTINS, "all", EOpAll); - symbolTable.relateToOperator(COMMON_BUILTINS, "not", EOpVectorLogicalNot); - - // Map language-specific operators. - switch(type) { - case GL_VERTEX_SHADER: - break; - case GL_FRAGMENT_SHADER: - if (resources.OES_standard_derivatives) + if (spec != SH_CSS_SHADERS_SPEC) { - symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdx", EOpDFdx); - symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdy", EOpDFdy); - symbolTable.relateToOperator(ESSL1_BUILTINS, "fwidth", EOpFwidth); + symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragColor"), + TType(EbtFloat, EbpMedium, EvqFragColor, 4))); + TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true); + fragData.setArraySize(resources.MaxDrawBuffers); + symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData"), fragData)); + + if (resources.EXT_frag_depth) + { + symbolTable.insert(ESSL1_BUILTINS, "GL_EXT_frag_depth", new TVariable(NewPoolTString("gl_FragDepthEXT"), + TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1))); + } - symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdx", "GL_OES_standard_derivatives"); - symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdy", "GL_OES_standard_derivatives"); - symbolTable.relateToExtension(ESSL1_BUILTINS, "fwidth", "GL_OES_standard_derivatives"); + if (resources.EXT_shader_framebuffer_fetch || resources.NV_shader_framebuffer_fetch) + { + TType lastFragData(EbtFloat, EbpMedium, EvqLastFragData, 4, 1, true); + lastFragData.setArraySize(resources.MaxDrawBuffers); + + if (resources.EXT_shader_framebuffer_fetch) + { + symbolTable.insert(ESSL1_BUILTINS, "GL_EXT_shader_framebuffer_fetch", + new TVariable(NewPoolTString("gl_LastFragData"), lastFragData)); + } + else if (resources.NV_shader_framebuffer_fetch) + { + symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch", + new TVariable(NewPoolTString("gl_LastFragColor"), + TType(EbtFloat, EbpMedium, EvqLastFragColor, 4))); + symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch", + new TVariable(NewPoolTString("gl_LastFragData"), lastFragData)); + } + } + else if (resources.ARM_shader_framebuffer_fetch) + { + symbolTable.insert(ESSL1_BUILTINS, "GL_ARM_shader_framebuffer_fetch", + new TVariable(NewPoolTString("gl_LastFragColorARM"), + TType(EbtFloat, EbpMedium, EvqLastFragColor, 4))); + } } - if (resources.EXT_shader_texture_lod) + else { - symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DLodEXT", "GL_EXT_shader_texture_lod"); - symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DProjLodEXT", "GL_EXT_shader_texture_lod"); - symbolTable.relateToExtension(ESSL1_BUILTINS, "textureCubeLodEXT", "GL_EXT_shader_texture_lod"); + symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_MixColor"), + TType(EbtFloat, EbpMedium, EvqGlobal, 4))); + symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_ColorMatrix"), + TType(EbtFloat, EbpMedium, EvqGlobal, 4, 4))); } - break; - default: break; - } - symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdx", EOpDFdx); - symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdy", EOpDFdy); - symbolTable.relateToOperator(ESSL3_BUILTINS, "fwidth", EOpFwidth); - - if (resources.EXT_shader_texture_lod) - { - symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DGradEXT", "GL_EXT_shader_texture_lod"); - symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DProjGradEXT", "GL_EXT_shader_texture_lod"); - symbolTable.relateToExtension(ESSL1_BUILTINS, "textureCubeGradEXT", "GL_EXT_shader_texture_lod"); - } + break; - // Finally add resource-specific variables. - switch(type) { - case GL_FRAGMENT_SHADER: - if (spec != SH_CSS_SHADERS_SPEC) { - // Set up gl_FragData. The array size. - TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true); - fragData.setArraySize(resources.MaxDrawBuffers); - symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData"), fragData)); - } + case GL_VERTEX_SHADER: + symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_Position"), + TType(EbtFloat, EbpHigh, EvqPosition, 4))); + symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointSize"), + TType(EbtFloat, EbpMedium, EvqPointSize, 1))); + symbolTable.insert(ESSL3_BUILTINS, new TVariable(NewPoolTString("gl_InstanceID"), + TType(EbtInt, EbpHigh, EvqInstanceID, 1))); break; - default: break; + + default: + assert(false && "Language not supported"); } } @@ -758,4 +575,20 @@ void InitExtensionBehavior(const ShBuiltInResources& resources, extBehavior["GL_EXT_frag_depth"] = EBhUndefined; if (resources.EXT_shader_texture_lod) extBehavior["GL_EXT_shader_texture_lod"] = EBhUndefined; + if (resources.EXT_shader_framebuffer_fetch) + extBehavior["GL_EXT_shader_framebuffer_fetch"] = EBhUndefined; + if (resources.NV_shader_framebuffer_fetch) + extBehavior["GL_NV_shader_framebuffer_fetch"] = EBhUndefined; + if (resources.ARM_shader_framebuffer_fetch) + extBehavior["GL_ARM_shader_framebuffer_fetch"] = EBhUndefined; +} + +void ResetExtensionBehavior(TExtensionBehavior &extBehavior) +{ + for (auto ext_iter = extBehavior.begin(); + ext_iter != extBehavior.end(); + ++ext_iter) + { + ext_iter->second = EBhUndefined; + } } |