summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/compiler
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-05-18 15:16:30 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-05-26 15:11:40 +0200
commit752497910b67b2a1a80560840ca44548d8893434 (patch)
tree541501c9abfd97c3d2fa450d2e6abb60582c4420 /src/3rdparty/angle/src/compiler
parent7db527dbdd911c79f31425d099d1fc9c63e42453 (diff)
Remove ANGLE
This marks the end of EGL and OpenGL ES support on Windows. The concepts of -opengl dynamic, -opengl desktop, QT_OPENGL=software, etc. remain unchanged, with the exception of the disapperance of everything ANGLE related. CMake builds now work identically to qmake on Windows: they default to 'dynamic' OpenGL on Windows, unless -DINPUT_opengl=desktop is specified. On Windows, Qt 6 is expected to default to the "dynamic" OpenGL model by default, just like Qt 5.15. This can be changed by switching to "desktop" OpenGL, which will link to opengl32 (publicly, so other libs and applications will do so as well) and disallows using another OpenGL DLL. The "dynamic" mode is essential still because the fallback to a software rasterizer, such as the opengl32sw.dll we ship with the Qt packages, has to to work exactly like in Qt 5, the removal of ANGLE does not change this concept in any way (except of course that the middle option of using ANGLE is now gone) When it comes to the windows plugin's OpenGL blacklist feature, it works like before and accepts the ANGLE/D3D related keywords. They will then be ignored. Similarly, requesting QT_OPENGL=angle is ignored (but will show a warning). The D3D11 and DXGI configure time tests are removed: Qt 5.14 already depends on D3D 11.1 and DXGI 1.3 headers being available unconditionally on Win32 (in QRhi's D3D11 backend). No need to test for these. [ChangeLog][Windows] ANGLE is no longer included with Qt. Dynamic OpenGL builds work like before but ANGLE is no longer an option. OpenGL proper or an alternative opengl32 implementation are the two remaining options now. Attempting to set QT_OPENGL=angle or Qt::AA_UseOpenGLES will have no effect on Windows. Fixes: QTBUG-79103 Change-Id: Ia404e0d07f3fe191b27434d863c81180112ecb3b Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/3rdparty/angle/src/compiler')
-rw-r--r--src/3rdparty/angle/src/compiler/fuzz/translator_fuzzer.cpp179
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.cpp143
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.h90
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/DirectiveHandlerBase.cpp16
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/DirectiveHandlerBase.h43
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/DirectiveParser.cpp1000
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/DirectiveParser.h83
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.h43
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.y462
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/Input.cpp129
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/Input.h54
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/Lexer.cpp16
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/Lexer.h27
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/Macro.cpp44
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/Macro.h50
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/MacroExpander.cpp481
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/MacroExpander.h83
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp107
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.h60
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/SourceLocation.h39
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/Token.cpp80
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/Token.h109
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/Tokenizer.h58
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/Tokenizer.l384
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/numeric_lex.h72
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ASTMetadataHLSL.cpp462
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ASTMetadataHLSL.h63
-rw-r--r--src/3rdparty/angle/src/compiler/translator/AddAndTrueToLoopCondition.cpp59
-rw-r--r--src/3rdparty/angle/src/compiler/translator/AddAndTrueToLoopCondition.h20
-rw-r--r--src/3rdparty/angle/src/compiler/translator/AddDefaultReturnStatements.cpp58
-rw-r--r--src/3rdparty/angle/src/compiler/translator/AddDefaultReturnStatements.h22
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ArrayReturnValueToOutParameter.cpp213
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ArrayReturnValueToOutParameter.h22
-rw-r--r--src/3rdparty/angle/src/compiler/translator/BaseTypes.h1073
-rw-r--r--src/3rdparty/angle/src/compiler/translator/BreakVariableAliasingInInnerLoops.cpp107
-rw-r--r--src/3rdparty/angle/src/compiler/translator/BreakVariableAliasingInInnerLoops.h23
-rw-r--r--src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.cpp355
-rw-r--r--src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.h183
-rw-r--r--src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorGLSL.cpp293
-rw-r--r--src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorGLSL.h40
-rw-r--r--src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorHLSL.cpp184
-rw-r--r--src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorHLSL.h27
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Cache.cpp99
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Cache.h84
-rw-r--r--src/3rdparty/angle/src/compiler/translator/CallDAG.cpp346
-rw-r--r--src/3rdparty/angle/src/compiler/translator/CallDAG.h79
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ClampPointSize.cpp47
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ClampPointSize.h22
-rw-r--r--src/3rdparty/angle/src/compiler/translator/CodeGen.cpp75
-rw-r--r--src/3rdparty/angle/src/compiler/translator/CollectVariables.cpp869
-rw-r--r--src/3rdparty/angle/src/compiler/translator/CollectVariables.h37
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Common.h138
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Compiler.cpp1169
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Compiler.h308
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ConstantUnion.cpp681
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ConstantUnion.h117
-rw-r--r--src/3rdparty/angle/src/compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.cpp221
-rw-r--r--src/3rdparty/angle/src/compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.h48
-rw-r--r--src/3rdparty/angle/src/compiler/translator/DeferGlobalInitializers.cpp147
-rw-r--r--src/3rdparty/angle/src/compiler/translator/DeferGlobalInitializers.h32
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Diagnostics.cpp105
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Diagnostics.h67
-rw-r--r--src/3rdparty/angle/src/compiler/translator/DirectiveHandler.cpp203
-rw-r--r--src/3rdparty/angle/src/compiler/translator/DirectiveHandler.h57
-rw-r--r--src/3rdparty/angle/src/compiler/translator/EmulateGLFragColorBroadcast.cpp129
-rw-r--r--src/3rdparty/angle/src/compiler/translator/EmulateGLFragColorBroadcast.h31
-rw-r--r--src/3rdparty/angle/src/compiler/translator/EmulatePrecision.cpp751
-rw-r--r--src/3rdparty/angle/src/compiler/translator/EmulatePrecision.h73
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ExpandIntegerPowExpressions.cpp153
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ExpandIntegerPowExpressions.h29
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ExtensionBehavior.cpp96
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ExtensionBehavior.h60
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ExtensionGLSL.cpp105
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ExtensionGLSL.h44
-rw-r--r--src/3rdparty/angle/src/compiler/translator/FindMain.cpp38
-rw-r--r--src/3rdparty/angle/src/compiler/translator/FindMain.h23
-rw-r--r--src/3rdparty/angle/src/compiler/translator/FindSymbolNode.cpp58
-rw-r--r--src/3rdparty/angle/src/compiler/translator/FindSymbolNode.h27
-rw-r--r--src/3rdparty/angle/src/compiler/translator/FlagStd140Structs.cpp75
-rw-r--r--src/3rdparty/angle/src/compiler/translator/FlagStd140Structs.h30
-rw-r--r--src/3rdparty/angle/src/compiler/translator/HashNames.cpp72
-rw-r--r--src/3rdparty/angle/src/compiler/translator/HashNames.h28
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ImageFunctionHLSL.cpp304
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ImageFunctionHLSL.h76
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InfoSink.cpp40
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InfoSink.h120
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Initialize.cpp1135
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Initialize.h38
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InitializeDll.cpp37
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InitializeDll.h15
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InitializeGlobals.h13
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InitializeVariables.cpp290
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InitializeVariables.h53
-rw-r--r--src/3rdparty/angle/src/compiler/translator/IntermNode.cpp3330
-rw-r--r--src/3rdparty/angle/src/compiler/translator/IntermNode.h917
-rw-r--r--src/3rdparty/angle/src/compiler/translator/IntermNodePatternMatcher.cpp157
-rw-r--r--src/3rdparty/angle/src/compiler/translator/IntermNodePatternMatcher.h75
-rw-r--r--src/3rdparty/angle/src/compiler/translator/IntermNode_util.cpp254
-rw-r--r--src/3rdparty/angle/src/compiler/translator/IntermNode_util.h60
-rw-r--r--src/3rdparty/angle/src/compiler/translator/IntermTraverse.cpp983
-rw-r--r--src/3rdparty/angle/src/compiler/translator/IntermTraverse.h355
-rw-r--r--src/3rdparty/angle/src/compiler/translator/IsASTDepthBelowLimit.cpp51
-rw-r--r--src/3rdparty/angle/src/compiler/translator/IsASTDepthBelowLimit.h20
-rw-r--r--src/3rdparty/angle/src/compiler/translator/NodeSearch.h56
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Operator.cpp385
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Operator.h255
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputESSL.cpp47
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputESSL.h37
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputGLSL.cpp110
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputGLSL.h36
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputGLSLBase.cpp1357
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputGLSLBase.h122
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputHLSL.cpp3084
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputHLSL.h248
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputTree.cpp682
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputTree.h22
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputVulkanGLSL.cpp80
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputVulkanGLSL.h34
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ParamType.h102
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ParseContext.cpp6022
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ParseContext.h657
-rw-r--r--src/3rdparty/angle/src/compiler/translator/PoolAlloc.cpp360
-rw-r--r--src/3rdparty/angle/src/compiler/translator/PoolAlloc.h319
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Pragma.h31
-rw-r--r--src/3rdparty/angle/src/compiler/translator/PruneNoOps.cpp156
-rw-r--r--src/3rdparty/angle/src/compiler/translator/PruneNoOps.h24
-rw-r--r--src/3rdparty/angle/src/compiler/translator/QualifierTypes.cpp784
-rw-r--r--src/3rdparty/angle/src/compiler/translator/QualifierTypes.h191
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RecordConstantPrecision.cpp167
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RecordConstantPrecision.h28
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RegenerateStructNames.cpp76
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RegenerateStructNames.h45
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveArrayLengthMethod.cpp83
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveArrayLengthMethod.h29
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveDynamicIndexing.cpp550
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveDynamicIndexing.h27
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveEmptySwitchStatements.cpp56
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveEmptySwitchStatements.h18
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveInvariantDeclaration.cpp43
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveInvariantDeclaration.h18
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveNoOpCasesFromEndOfSwitchStatements.cpp116
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveNoOpCasesFromEndOfSwitchStatements.h21
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemovePow.cpp97
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemovePow.h21
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveSwitchFallThrough.cpp270
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveSwitchFallThrough.h27
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveUnreferencedVariables.cpp358
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveUnreferencedVariables.h24
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RewriteDoWhile.cpp159
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RewriteDoWhile.h23
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RewriteElseBlocks.cpp120
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RewriteElseBlocks.h22
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RewriteTexelFetchOffset.cpp154
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RewriteTexelFetchOffset.h28
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RewriteUnaryMinusOperatorFloat.cpp94
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RewriteUnaryMinusOperatorFloat.h19
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RewriteUnaryMinusOperatorInt.cpp112
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RewriteUnaryMinusOperatorInt.h20
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RunAtTheEndOfShader.cpp112
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RunAtTheEndOfShader.h23
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ScalarizeVecAndMatConstructorArgs.cpp238
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ScalarizeVecAndMatConstructorArgs.h27
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SearchSymbol.cpp38
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SearchSymbol.h33
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SeparateArrayInitialization.cpp92
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SeparateArrayInitialization.h29
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SeparateDeclarations.cpp79
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SeparateDeclarations.h26
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SeparateExpressionsReturningArrays.cpp126
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SeparateExpressionsReturningArrays.h23
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Severity.h22
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ShaderLang.cpp578
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ShaderVars.cpp586
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SimplifyLoopConditions.cpp300
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SimplifyLoopConditions.h25
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SplitSequenceOperator.cpp171
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SplitSequenceOperator.h28
-rw-r--r--src/3rdparty/angle/src/compiler/translator/StructureHLSL.cpp594
-rw-r--r--src/3rdparty/angle/src/compiler/translator/StructureHLSL.h98
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SymbolTable.cpp622
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SymbolTable.h545
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SymbolUniqueId.cpp28
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SymbolUniqueId.h36
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TextureFunctionHLSL.cpp1322
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TextureFunctionHLSL.h76
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TranslatorESSL.cpp184
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TranslatorESSL.h35
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TranslatorGLSL.cpp339
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TranslatorGLSL.h38
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TranslatorHLSL.cpp161
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TranslatorHLSL.h41
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TranslatorVulkan.cpp173
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TranslatorVulkan.h34
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Types.cpp1072
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Types.h509
-rw-r--r--src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitAST.cpp59
-rw-r--r--src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitAST.h33
-rw-r--r--src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitToIf.cpp186
-rw-r--r--src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitToIf.h25
-rw-r--r--src/3rdparty/angle/src/compiler/translator/UniformHLSL.cpp600
-rw-r--r--src/3rdparty/angle/src/compiler/translator/UniformHLSL.h110
-rw-r--r--src/3rdparty/angle/src/compiler/translator/UseInterfaceBlockFields.cpp105
-rw-r--r--src/3rdparty/angle/src/compiler/translator/UseInterfaceBlockFields.h30
-rw-r--r--src/3rdparty/angle/src/compiler/translator/UtilsHLSL.cpp970
-rw-r--r--src/3rdparty/angle/src/compiler/translator/UtilsHLSL.h129
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ValidateGlobalInitializer.cpp120
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ValidateGlobalInitializer.h23
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ValidateLimitations.cpp444
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ValidateLimitations.h27
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ValidateMaxParameters.cpp29
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ValidateMaxParameters.h21
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ValidateOutputs.cpp174
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ValidateOutputs.h30
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ValidateSwitch.cpp319
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ValidateSwitch.h28
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ValidateVaryingLocations.cpp174
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ValidateVaryingLocations.h25
-rw-r--r--src/3rdparty/angle/src/compiler/translator/VariablePacker.cpp413
-rw-r--r--src/3rdparty/angle/src/compiler/translator/VariablePacker.h32
-rw-r--r--src/3rdparty/angle/src/compiler/translator/VectorizeVectorScalarArithmetic.cpp284
-rw-r--r--src/3rdparty/angle/src/compiler/translator/VectorizeVectorScalarArithmetic.h25
-rw-r--r--src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp143
-rw-r--r--src/3rdparty/angle/src/compiler/translator/VersionGLSL.h76
-rw-r--r--src/3rdparty/angle/src/compiler/translator/WrapSwitchStatementsInBlocks.cpp132
-rw-r--r--src/3rdparty/angle/src/compiler/translator/WrapSwitchStatementsInBlocks.h22
-rw-r--r--src/3rdparty/angle/src/compiler/translator/blocklayout.cpp281
-rw-r--r--src/3rdparty/angle/src/compiler/translator/blocklayout.h144
-rw-r--r--src/3rdparty/angle/src/compiler/translator/blocklayoutHLSL.cpp166
-rw-r--r--src/3rdparty/angle/src/compiler/translator/blocklayoutHLSL.h68
-rw-r--r--src/3rdparty/angle/src/compiler/translator/emulated_builtin_function_data_hlsl.json1382
-rw-r--r--src/3rdparty/angle/src/compiler/translator/emulated_builtin_functions_hlsl_autogen.cpp859
-rw-r--r--src/3rdparty/angle/src/compiler/translator/glslang.h24
-rw-r--r--src/3rdparty/angle/src/compiler/translator/glslang.l697
-rw-r--r--src/3rdparty/angle/src/compiler/translator/glslang.y1468
-rw-r--r--src/3rdparty/angle/src/compiler/translator/length_limits.h26
-rw-r--r--src/3rdparty/angle/src/compiler/translator/util.cpp714
-rw-r--r--src/3rdparty/angle/src/compiler/translator/util.h63
237 files changed, 0 insertions, 59321 deletions
diff --git a/src/3rdparty/angle/src/compiler/fuzz/translator_fuzzer.cpp b/src/3rdparty/angle/src/compiler/fuzz/translator_fuzzer.cpp
deleted file mode 100644
index 910af8be6f..0000000000
--- a/src/3rdparty/angle/src/compiler/fuzz/translator_fuzzer.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-//
-// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// translator_fuzzer.cpp: A libfuzzer fuzzer for the shader translator.
-
-#include <cstddef>
-#include <cstdint>
-#include <iostream>
-#include <memory>
-#include <unordered_map>
-
-#include "angle_gl.h"
-#include "compiler/translator/Compiler.h"
-#include "compiler/translator/util.h"
-
-using namespace sh;
-
-struct TranslatorCacheKey
-{
- bool operator==(const TranslatorCacheKey &other) const
- {
- return type == other.type && spec == other.spec && output == other.output;
- }
-
- uint32_t type = 0;
- uint32_t spec = 0;
- uint32_t output = 0;
-};
-
-namespace std
-{
-
-template <>
-struct hash<TranslatorCacheKey>
-{
- std::size_t operator()(const TranslatorCacheKey &k) const
- {
- return (hash<uint32_t>()(k.type) << 1) ^ (hash<uint32_t>()(k.spec) >> 1) ^
- hash<uint32_t>()(k.output);
- }
-};
-} // namespace std
-
-struct TCompilerDeleter
-{
- void operator()(TCompiler *compiler) const { DeleteCompiler(compiler); }
-};
-
-using UniqueTCompiler = std::unique_ptr<TCompiler, TCompilerDeleter>;
-
-static std::unordered_map<TranslatorCacheKey, UniqueTCompiler> translators;
-
-extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
-{
- // Reserve some size for future compile options
- const size_t kHeaderSize = 128;
-
- if (size <= kHeaderSize)
- {
- return 0;
- }
-
- // Make sure the rest of data will be a valid C string so that we don't have to copy it.
- if (data[size - 1] != 0)
- {
- return 0;
- }
-
- uint32_t type = *reinterpret_cast<const uint32_t *>(data);
- uint32_t spec = *reinterpret_cast<const uint32_t *>(data + 4);
- uint32_t output = *reinterpret_cast<const uint32_t *>(data + 8);
- uint64_t options = *reinterpret_cast<const uint64_t *>(data + 12);
-
- if (type != GL_FRAGMENT_SHADER && type != GL_VERTEX_SHADER)
- {
- return 0;
- }
-
- if (spec != SH_GLES2_SPEC && type != SH_WEBGL_SPEC && spec != SH_GLES3_SPEC &&
- spec != SH_WEBGL2_SPEC)
- {
- return 0;
- }
-
- ShShaderOutput shaderOutput = static_cast<ShShaderOutput>(output);
- if (!(IsOutputGLSL(shaderOutput) || IsOutputESSL(shaderOutput)) &&
- (options & SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER) != 0u)
- {
- // This compiler option is only available in ESSL and GLSL.
- return 0;
- }
-
- std::vector<uint32_t> validOutputs;
- validOutputs.push_back(SH_ESSL_OUTPUT);
- validOutputs.push_back(SH_GLSL_COMPATIBILITY_OUTPUT);
- validOutputs.push_back(SH_GLSL_130_OUTPUT);
- validOutputs.push_back(SH_GLSL_140_OUTPUT);
- validOutputs.push_back(SH_GLSL_150_CORE_OUTPUT);
- validOutputs.push_back(SH_GLSL_330_CORE_OUTPUT);
- validOutputs.push_back(SH_GLSL_400_CORE_OUTPUT);
- validOutputs.push_back(SH_GLSL_410_CORE_OUTPUT);
- validOutputs.push_back(SH_GLSL_420_CORE_OUTPUT);
- validOutputs.push_back(SH_GLSL_430_CORE_OUTPUT);
- validOutputs.push_back(SH_GLSL_440_CORE_OUTPUT);
- validOutputs.push_back(SH_GLSL_450_CORE_OUTPUT);
- validOutputs.push_back(SH_HLSL_3_0_OUTPUT);
- validOutputs.push_back(SH_HLSL_4_1_OUTPUT);
- validOutputs.push_back(SH_HLSL_4_0_FL9_3_OUTPUT);
- bool found = false;
- for (auto valid : validOutputs)
- {
- found = found || (valid == output);
- }
- if (!found)
- {
- return 0;
- }
-
- size -= kHeaderSize;
- data += kHeaderSize;
-
- if (!sh::Initialize())
- {
- return 0;
- }
-
- TranslatorCacheKey key;
- key.type = type;
- key.spec = spec;
- key.output = output;
-
- if (translators.find(key) == translators.end())
- {
- UniqueTCompiler translator(
- ConstructCompiler(type, static_cast<ShShaderSpec>(spec), shaderOutput));
-
- if (translator == nullptr)
- {
- return 0;
- }
-
- ShBuiltInResources resources;
- sh::InitBuiltInResources(&resources);
-
- // Enable all the extensions to have more coverage
- resources.OES_standard_derivatives = 1;
- resources.OES_EGL_image_external = 1;
- resources.OES_EGL_image_external_essl3 = 1;
- resources.NV_EGL_stream_consumer_external = 1;
- resources.ARB_texture_rectangle = 1;
- resources.EXT_blend_func_extended = 1;
- resources.EXT_draw_buffers = 1;
- resources.EXT_frag_depth = 1;
- resources.EXT_shader_texture_lod = 1;
- resources.WEBGL_debug_shader_precision = 1;
- resources.EXT_shader_framebuffer_fetch = 1;
- resources.NV_shader_framebuffer_fetch = 1;
- resources.ARM_shader_framebuffer_fetch = 1;
- resources.EXT_YUV_target = 1;
- resources.MaxDualSourceDrawBuffers = 1;
-
- if (!translator->Init(resources))
- {
- return 0;
- }
-
- translators[key] = std::move(translator);
- }
-
- auto &translator = translators[key];
-
- const char *shaderStrings[] = {reinterpret_cast<const char *>(data)};
- translator->compile(shaderStrings, 1, options);
-
- return 0;
-}
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.cpp b/src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.cpp
deleted file mode 100644
index c89bc9fa76..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/preprocessor/DiagnosticsBase.h"
-
-#include "common/debug.h"
-
-namespace pp
-{
-
-Diagnostics::~Diagnostics()
-{
-}
-
-void Diagnostics::report(ID id, const SourceLocation &loc, const std::string &text)
-{
- print(id, loc, text);
-}
-
-bool Diagnostics::isError(ID id)
-{
- if ((id > PP_ERROR_BEGIN) && (id < PP_ERROR_END))
- return true;
-
- if ((id > PP_WARNING_BEGIN) && (id < PP_WARNING_END))
- return false;
-
- UNREACHABLE();
- return true;
-}
-
-const char *Diagnostics::message(ID id)
-{
- switch (id)
- {
- // Errors begin.
- case PP_INTERNAL_ERROR:
- return "internal error";
- case PP_OUT_OF_MEMORY:
- return "out of memory";
- case PP_INVALID_CHARACTER:
- return "invalid character";
- case PP_INVALID_NUMBER:
- return "invalid number";
- case PP_INTEGER_OVERFLOW:
- return "integer overflow";
- case PP_FLOAT_OVERFLOW:
- return "float overflow";
- case PP_TOKEN_TOO_LONG:
- return "token too long";
- case PP_INVALID_EXPRESSION:
- return "invalid expression";
- case PP_DIVISION_BY_ZERO:
- return "division by zero";
- case PP_EOF_IN_COMMENT:
- return "unexpected end of file found in comment";
- case PP_UNEXPECTED_TOKEN:
- return "unexpected token";
- case PP_DIRECTIVE_INVALID_NAME:
- return "invalid directive name";
- case PP_MACRO_NAME_RESERVED:
- return "macro name is reserved";
- case PP_MACRO_REDEFINED:
- return "macro redefined";
- case PP_MACRO_PREDEFINED_REDEFINED:
- return "predefined macro redefined";
- case PP_MACRO_PREDEFINED_UNDEFINED:
- return "predefined macro undefined";
- case PP_MACRO_UNTERMINATED_INVOCATION:
- return "unterminated macro invocation";
- case PP_MACRO_UNDEFINED_WHILE_INVOKED:
- return "macro undefined while being invoked";
- case PP_MACRO_TOO_FEW_ARGS:
- return "Not enough arguments for macro";
- case PP_MACRO_TOO_MANY_ARGS:
- return "Too many arguments for macro";
- case PP_MACRO_DUPLICATE_PARAMETER_NAMES:
- return "duplicate macro parameter name";
- case PP_MACRO_INVOCATION_CHAIN_TOO_DEEP:
- return "macro invocation chain too deep";
- case PP_CONDITIONAL_ENDIF_WITHOUT_IF:
- return "unexpected #endif found without a matching #if";
- case PP_CONDITIONAL_ELSE_WITHOUT_IF:
- return "unexpected #else found without a matching #if";
- case PP_CONDITIONAL_ELSE_AFTER_ELSE:
- return "unexpected #else found after another #else";
- case PP_CONDITIONAL_ELIF_WITHOUT_IF:
- return "unexpected #elif found without a matching #if";
- case PP_CONDITIONAL_ELIF_AFTER_ELSE:
- return "unexpected #elif found after #else";
- case PP_CONDITIONAL_UNTERMINATED:
- return "unexpected end of file found in conditional block";
- case PP_INVALID_EXTENSION_NAME:
- return "invalid extension name";
- case PP_INVALID_EXTENSION_BEHAVIOR:
- return "invalid extension behavior";
- case PP_INVALID_EXTENSION_DIRECTIVE:
- return "invalid extension directive";
- case PP_INVALID_VERSION_NUMBER:
- return "invalid version number";
- case PP_INVALID_VERSION_DIRECTIVE:
- return "invalid version directive";
- case PP_VERSION_NOT_FIRST_STATEMENT:
- return "#version directive must occur before anything else, "
- "except for comments and white space";
- case PP_VERSION_NOT_FIRST_LINE_ESSL3:
- return "#version directive must occur on the first line of the shader";
- case PP_INVALID_LINE_NUMBER:
- return "invalid line number";
- case PP_INVALID_FILE_NUMBER:
- return "invalid file number";
- case PP_INVALID_LINE_DIRECTIVE:
- return "invalid line directive";
- case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3:
- return "extension directive must occur before any non-preprocessor tokens in ESSL3";
- case PP_UNDEFINED_SHIFT:
- return "shift exponent is negative or undefined";
- case PP_TOKENIZER_ERROR:
- return "internal tokenizer error";
- // Errors end.
- // Warnings begin.
- case PP_EOF_IN_DIRECTIVE:
- return "unexpected end of file found in directive";
- case PP_CONDITIONAL_UNEXPECTED_TOKEN:
- return "unexpected token after conditional expression";
- case PP_UNRECOGNIZED_PRAGMA:
- return "unrecognized pragma";
- case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1:
- return "extension directive should occur before any non-preprocessor tokens";
- case PP_WARNING_MACRO_NAME_RESERVED:
- return "macro name with a double underscore is reserved - unintented behavior is "
- "possible";
- // Warnings end.
- default:
- UNREACHABLE();
- return "";
- }
-}
-
-} // namespace pp
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.h b/src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.h
deleted file mode 100644
index ea37614606..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.h
+++ /dev/null
@@ -1,90 +0,0 @@
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_PREPROCESSOR_DIAGNOSTICSBASE_H_
-#define COMPILER_PREPROCESSOR_DIAGNOSTICSBASE_H_
-
-#include <string>
-
-namespace pp
-{
-
-struct SourceLocation;
-
-// Base class for reporting diagnostic messages.
-// Derived classes are responsible for formatting and printing the messages.
-class Diagnostics
-{
- public:
- enum ID
- {
- PP_ERROR_BEGIN,
- PP_INTERNAL_ERROR,
- PP_OUT_OF_MEMORY,
- PP_INVALID_CHARACTER,
- PP_INVALID_NUMBER,
- PP_INTEGER_OVERFLOW,
- PP_FLOAT_OVERFLOW,
- PP_TOKEN_TOO_LONG,
- PP_INVALID_EXPRESSION,
- PP_DIVISION_BY_ZERO,
- PP_EOF_IN_COMMENT,
- PP_UNEXPECTED_TOKEN,
- PP_DIRECTIVE_INVALID_NAME,
- PP_MACRO_NAME_RESERVED,
- PP_MACRO_REDEFINED,
- PP_MACRO_PREDEFINED_REDEFINED,
- PP_MACRO_PREDEFINED_UNDEFINED,
- PP_MACRO_UNTERMINATED_INVOCATION,
- PP_MACRO_UNDEFINED_WHILE_INVOKED,
- PP_MACRO_TOO_FEW_ARGS,
- PP_MACRO_TOO_MANY_ARGS,
- PP_MACRO_DUPLICATE_PARAMETER_NAMES,
- PP_MACRO_INVOCATION_CHAIN_TOO_DEEP,
- PP_CONDITIONAL_ENDIF_WITHOUT_IF,
- PP_CONDITIONAL_ELSE_WITHOUT_IF,
- PP_CONDITIONAL_ELSE_AFTER_ELSE,
- PP_CONDITIONAL_ELIF_WITHOUT_IF,
- PP_CONDITIONAL_ELIF_AFTER_ELSE,
- PP_CONDITIONAL_UNTERMINATED,
- PP_CONDITIONAL_UNEXPECTED_TOKEN,
- PP_INVALID_EXTENSION_NAME,
- PP_INVALID_EXTENSION_BEHAVIOR,
- PP_INVALID_EXTENSION_DIRECTIVE,
- PP_INVALID_VERSION_NUMBER,
- PP_INVALID_VERSION_DIRECTIVE,
- PP_VERSION_NOT_FIRST_STATEMENT,
- PP_VERSION_NOT_FIRST_LINE_ESSL3,
- PP_INVALID_LINE_NUMBER,
- PP_INVALID_FILE_NUMBER,
- PP_INVALID_LINE_DIRECTIVE,
- PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3,
- PP_UNDEFINED_SHIFT,
- PP_TOKENIZER_ERROR,
- PP_ERROR_END,
-
- PP_WARNING_BEGIN,
- PP_EOF_IN_DIRECTIVE,
- PP_UNRECOGNIZED_PRAGMA,
- PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1,
- PP_WARNING_MACRO_NAME_RESERVED,
- PP_WARNING_END
- };
-
- virtual ~Diagnostics();
-
- void report(ID id, const SourceLocation &loc, const std::string &text);
-
- protected:
- bool isError(ID id);
- const char *message(ID id);
-
- virtual void print(ID id, const SourceLocation &loc, const std::string &text) = 0;
-};
-
-} // namespace pp
-
-#endif // COMPILER_PREPROCESSOR_DIAGNOSTICSBASE_H_
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/DirectiveHandlerBase.cpp b/src/3rdparty/angle/src/compiler/preprocessor/DirectiveHandlerBase.cpp
deleted file mode 100644
index 049dae9071..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/DirectiveHandlerBase.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/preprocessor/DirectiveHandlerBase.h"
-
-namespace pp
-{
-
-DirectiveHandler::~DirectiveHandler()
-{
-}
-
-} // namespace pp
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/DirectiveHandlerBase.h b/src/3rdparty/angle/src/compiler/preprocessor/DirectiveHandlerBase.h
deleted file mode 100644
index 6c81d015f5..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/DirectiveHandlerBase.h
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_PREPROCESSOR_DIRECTIVEHANDLERBASE_H_
-#define COMPILER_PREPROCESSOR_DIRECTIVEHANDLERBASE_H_
-
-#include <string>
-
-namespace pp
-{
-
-struct SourceLocation;
-
-// Base class for handling directives.
-// Preprocessor uses this class to notify the clients about certain
-// preprocessor directives. Derived classes are responsible for
-// handling them in an appropriate manner.
-class DirectiveHandler
-{
- public:
- virtual ~DirectiveHandler();
-
- virtual void handleError(const SourceLocation &loc, const std::string &msg) = 0;
-
- // Handle pragma of form: #pragma name[(value)]
- virtual void handlePragma(const SourceLocation &loc,
- const std::string &name,
- const std::string &value,
- bool stdgl) = 0;
-
- virtual void handleExtension(const SourceLocation &loc,
- const std::string &name,
- const std::string &behavior) = 0;
-
- virtual void handleVersion(const SourceLocation &loc, int version) = 0;
-};
-
-} // namespace pp
-
-#endif // COMPILER_PREPROCESSOR_DIRECTIVEHANDLERBASE_H_
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/DirectiveParser.cpp b/src/3rdparty/angle/src/compiler/preprocessor/DirectiveParser.cpp
deleted file mode 100644
index f6c5763990..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/DirectiveParser.cpp
+++ /dev/null
@@ -1,1000 +0,0 @@
-//
-// Copyright (c) 2011-2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/preprocessor/DirectiveParser.h"
-
-#include <algorithm>
-#include <cstdlib>
-#include <sstream>
-
-#include "common/debug.h"
-#include "compiler/preprocessor/DiagnosticsBase.h"
-#include "compiler/preprocessor/DirectiveHandlerBase.h"
-#include "compiler/preprocessor/ExpressionParser.h"
-#include "compiler/preprocessor/MacroExpander.h"
-#include "compiler/preprocessor/Token.h"
-#include "compiler/preprocessor/Tokenizer.h"
-
-namespace
-{
-enum DirectiveType
-{
- DIRECTIVE_NONE,
- DIRECTIVE_DEFINE,
- DIRECTIVE_UNDEF,
- DIRECTIVE_IF,
- DIRECTIVE_IFDEF,
- DIRECTIVE_IFNDEF,
- DIRECTIVE_ELSE,
- DIRECTIVE_ELIF,
- DIRECTIVE_ENDIF,
- DIRECTIVE_ERROR,
- DIRECTIVE_PRAGMA,
- DIRECTIVE_EXTENSION,
- DIRECTIVE_VERSION,
- DIRECTIVE_LINE
-};
-
-DirectiveType getDirective(const pp::Token *token)
-{
- const char kDirectiveDefine[] = "define";
- const char kDirectiveUndef[] = "undef";
- const char kDirectiveIf[] = "if";
- const char kDirectiveIfdef[] = "ifdef";
- const char kDirectiveIfndef[] = "ifndef";
- const char kDirectiveElse[] = "else";
- const char kDirectiveElif[] = "elif";
- const char kDirectiveEndif[] = "endif";
- const char kDirectiveError[] = "error";
- const char kDirectivePragma[] = "pragma";
- const char kDirectiveExtension[] = "extension";
- const char kDirectiveVersion[] = "version";
- const char kDirectiveLine[] = "line";
-
- if (token->type != pp::Token::IDENTIFIER)
- return DIRECTIVE_NONE;
-
- if (token->text == kDirectiveDefine)
- return DIRECTIVE_DEFINE;
- if (token->text == kDirectiveUndef)
- return DIRECTIVE_UNDEF;
- if (token->text == kDirectiveIf)
- return DIRECTIVE_IF;
- if (token->text == kDirectiveIfdef)
- return DIRECTIVE_IFDEF;
- if (token->text == kDirectiveIfndef)
- return DIRECTIVE_IFNDEF;
- if (token->text == kDirectiveElse)
- return DIRECTIVE_ELSE;
- if (token->text == kDirectiveElif)
- return DIRECTIVE_ELIF;
- if (token->text == kDirectiveEndif)
- return DIRECTIVE_ENDIF;
- if (token->text == kDirectiveError)
- return DIRECTIVE_ERROR;
- if (token->text == kDirectivePragma)
- return DIRECTIVE_PRAGMA;
- if (token->text == kDirectiveExtension)
- return DIRECTIVE_EXTENSION;
- if (token->text == kDirectiveVersion)
- return DIRECTIVE_VERSION;
- if (token->text == kDirectiveLine)
- return DIRECTIVE_LINE;
-
- return DIRECTIVE_NONE;
-}
-
-bool isConditionalDirective(DirectiveType directive)
-{
- switch (directive)
- {
- case DIRECTIVE_IF:
- case DIRECTIVE_IFDEF:
- case DIRECTIVE_IFNDEF:
- case DIRECTIVE_ELSE:
- case DIRECTIVE_ELIF:
- case DIRECTIVE_ENDIF:
- return true;
- default:
- return false;
- }
-}
-
-// Returns true if the token represents End Of Directive.
-bool isEOD(const pp::Token *token)
-{
- return (token->type == '\n') || (token->type == pp::Token::LAST);
-}
-
-void skipUntilEOD(pp::Lexer *lexer, pp::Token *token)
-{
- while (!isEOD(token))
- {
- lexer->lex(token);
- }
-}
-
-bool isMacroNameReserved(const std::string &name)
-{
- // Names prefixed with "GL_" and the name "defined" are reserved.
- return name == "defined" || (name.substr(0, 3) == "GL_");
-}
-
-bool hasDoubleUnderscores(const std::string &name)
-{
- return (name.find("__") != std::string::npos);
-}
-
-bool isMacroPredefined(const std::string &name, const pp::MacroSet &macroSet)
-{
- pp::MacroSet::const_iterator iter = macroSet.find(name);
- return iter != macroSet.end() ? iter->second->predefined : false;
-}
-
-} // namespace anonymous
-
-namespace pp
-{
-
-class DefinedParser : public Lexer
-{
- public:
- DefinedParser(Lexer *lexer, const MacroSet *macroSet, Diagnostics *diagnostics)
- : mLexer(lexer), mMacroSet(macroSet), mDiagnostics(diagnostics)
- {
- }
-
- protected:
- void lex(Token *token) override
- {
- const char kDefined[] = "defined";
-
- mLexer->lex(token);
- if (token->type != Token::IDENTIFIER)
- return;
- if (token->text != kDefined)
- return;
-
- bool paren = false;
- mLexer->lex(token);
- if (token->type == '(')
- {
- paren = true;
- mLexer->lex(token);
- }
-
- if (token->type != Token::IDENTIFIER)
- {
- mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text);
- skipUntilEOD(mLexer, token);
- return;
- }
- MacroSet::const_iterator iter = mMacroSet->find(token->text);
- std::string expression = iter != mMacroSet->end() ? "1" : "0";
-
- if (paren)
- {
- mLexer->lex(token);
- if (token->type != ')')
- {
- mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location,
- token->text);
- skipUntilEOD(mLexer, token);
- return;
- }
- }
-
- // We have a valid defined operator.
- // Convert the current token into a CONST_INT token.
- token->type = Token::CONST_INT;
- token->text = expression;
- }
-
- private:
- Lexer *mLexer;
- const MacroSet *mMacroSet;
- Diagnostics *mDiagnostics;
-};
-
-DirectiveParser::DirectiveParser(Tokenizer *tokenizer,
- MacroSet *macroSet,
- Diagnostics *diagnostics,
- DirectiveHandler *directiveHandler,
- int maxMacroExpansionDepth)
- : mPastFirstStatement(false),
- mSeenNonPreprocessorToken(false),
- mTokenizer(tokenizer),
- mMacroSet(macroSet),
- mDiagnostics(diagnostics),
- mDirectiveHandler(directiveHandler),
- mShaderVersion(100),
- mMaxMacroExpansionDepth(maxMacroExpansionDepth)
-{
-}
-
-DirectiveParser::~DirectiveParser()
-{
-}
-
-void DirectiveParser::lex(Token *token)
-{
- do
- {
- mTokenizer->lex(token);
-
- if (token->type == Token::PP_HASH)
- {
- parseDirective(token);
- mPastFirstStatement = true;
- }
- else if (!isEOD(token))
- {
- mSeenNonPreprocessorToken = true;
- }
-
- if (token->type == Token::LAST)
- {
- if (!mConditionalStack.empty())
- {
- const ConditionalBlock &block = mConditionalStack.back();
- mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNTERMINATED, block.location,
- block.type);
- }
- break;
- }
-
- } while (skipping() || (token->type == '\n'));
-
- mPastFirstStatement = true;
-}
-
-void DirectiveParser::parseDirective(Token *token)
-{
- ASSERT(token->type == Token::PP_HASH);
-
- mTokenizer->lex(token);
- if (isEOD(token))
- {
- // Empty Directive.
- return;
- }
-
- DirectiveType directive = getDirective(token);
-
- // While in an excluded conditional block/group,
- // we only parse conditional directives.
- if (skipping() && !isConditionalDirective(directive))
- {
- skipUntilEOD(mTokenizer, token);
- return;
- }
-
- switch (directive)
- {
- case DIRECTIVE_NONE:
- mDiagnostics->report(Diagnostics::PP_DIRECTIVE_INVALID_NAME, token->location,
- token->text);
- skipUntilEOD(mTokenizer, token);
- break;
- case DIRECTIVE_DEFINE:
- parseDefine(token);
- break;
- case DIRECTIVE_UNDEF:
- parseUndef(token);
- break;
- case DIRECTIVE_IF:
- parseIf(token);
- break;
- case DIRECTIVE_IFDEF:
- parseIfdef(token);
- break;
- case DIRECTIVE_IFNDEF:
- parseIfndef(token);
- break;
- case DIRECTIVE_ELSE:
- parseElse(token);
- break;
- case DIRECTIVE_ELIF:
- parseElif(token);
- break;
- case DIRECTIVE_ENDIF:
- parseEndif(token);
- break;
- case DIRECTIVE_ERROR:
- parseError(token);
- break;
- case DIRECTIVE_PRAGMA:
- parsePragma(token);
- break;
- case DIRECTIVE_EXTENSION:
- parseExtension(token);
- break;
- case DIRECTIVE_VERSION:
- parseVersion(token);
- break;
- case DIRECTIVE_LINE:
- parseLine(token);
- break;
- default:
- UNREACHABLE();
- break;
- }
-
- skipUntilEOD(mTokenizer, token);
- if (token->type == Token::LAST)
- {
- mDiagnostics->report(Diagnostics::PP_EOF_IN_DIRECTIVE, token->location, token->text);
- }
-}
-
-void DirectiveParser::parseDefine(Token *token)
-{
- ASSERT(getDirective(token) == DIRECTIVE_DEFINE);
-
- mTokenizer->lex(token);
- if (token->type != Token::IDENTIFIER)
- {
- mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text);
- return;
- }
- if (isMacroPredefined(token->text, *mMacroSet))
- {
- mDiagnostics->report(Diagnostics::PP_MACRO_PREDEFINED_REDEFINED, token->location,
- token->text);
- return;
- }
- if (isMacroNameReserved(token->text))
- {
- mDiagnostics->report(Diagnostics::PP_MACRO_NAME_RESERVED, token->location, token->text);
- return;
- }
- // Using double underscores is allowed, but may result in unintended
- // behavior, so a warning is issued. At the time of writing this was
- // specified in ESSL 3.10, but the intent judging from Khronos
- // discussions and dEQP tests was that double underscores should be
- // allowed in earlier ESSL versions too.
- if (hasDoubleUnderscores(token->text))
- {
- mDiagnostics->report(Diagnostics::PP_WARNING_MACRO_NAME_RESERVED, token->location,
- token->text);
- }
-
- std::shared_ptr<Macro> macro = std::make_shared<Macro>();
- macro->type = Macro::kTypeObj;
- macro->name = token->text;
-
- mTokenizer->lex(token);
- if (token->type == '(' && !token->hasLeadingSpace())
- {
- // Function-like macro. Collect arguments.
- macro->type = Macro::kTypeFunc;
- do
- {
- mTokenizer->lex(token);
- if (token->type != Token::IDENTIFIER)
- break;
-
- if (std::find(macro->parameters.begin(), macro->parameters.end(), token->text) !=
- macro->parameters.end())
- {
- mDiagnostics->report(Diagnostics::PP_MACRO_DUPLICATE_PARAMETER_NAMES,
- token->location, token->text);
- return;
- }
-
- macro->parameters.push_back(token->text);
-
- mTokenizer->lex(token); // Get ','.
- } while (token->type == ',');
-
- if (token->type != ')')
- {
- mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text);
- return;
- }
- mTokenizer->lex(token); // Get ')'.
- }
-
- while ((token->type != '\n') && (token->type != Token::LAST))
- {
- // Reset the token location because it is unnecessary in replacement
- // list. Resetting it also allows us to reuse Token::equals() to
- // compare macros.
- token->location = SourceLocation();
- macro->replacements.push_back(*token);
- mTokenizer->lex(token);
- }
- if (!macro->replacements.empty())
- {
- // Whitespace preceding the replacement list is not considered part of
- // the replacement list for either form of macro.
- macro->replacements.front().setHasLeadingSpace(false);
- }
-
- // Check for macro redefinition.
- MacroSet::const_iterator iter = mMacroSet->find(macro->name);
- if (iter != mMacroSet->end() && !macro->equals(*iter->second))
- {
- mDiagnostics->report(Diagnostics::PP_MACRO_REDEFINED, token->location, macro->name);
- return;
- }
- mMacroSet->insert(std::make_pair(macro->name, macro));
-}
-
-void DirectiveParser::parseUndef(Token *token)
-{
- ASSERT(getDirective(token) == DIRECTIVE_UNDEF);
-
- mTokenizer->lex(token);
- if (token->type != Token::IDENTIFIER)
- {
- mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text);
- return;
- }
-
- MacroSet::iterator iter = mMacroSet->find(token->text);
- if (iter != mMacroSet->end())
- {
- if (iter->second->predefined)
- {
- mDiagnostics->report(Diagnostics::PP_MACRO_PREDEFINED_UNDEFINED, token->location,
- token->text);
- return;
- }
- else if (iter->second->expansionCount > 0)
- {
- mDiagnostics->report(Diagnostics::PP_MACRO_UNDEFINED_WHILE_INVOKED, token->location,
- token->text);
- return;
- }
- else
- {
- mMacroSet->erase(iter);
- }
- }
-
- mTokenizer->lex(token);
- if (!isEOD(token))
- {
- mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text);
- skipUntilEOD(mTokenizer, token);
- }
-}
-
-void DirectiveParser::parseIf(Token *token)
-{
- ASSERT(getDirective(token) == DIRECTIVE_IF);
- parseConditionalIf(token);
-}
-
-void DirectiveParser::parseIfdef(Token *token)
-{
- ASSERT(getDirective(token) == DIRECTIVE_IFDEF);
- parseConditionalIf(token);
-}
-
-void DirectiveParser::parseIfndef(Token *token)
-{
- ASSERT(getDirective(token) == DIRECTIVE_IFNDEF);
- parseConditionalIf(token);
-}
-
-void DirectiveParser::parseElse(Token *token)
-{
- ASSERT(getDirective(token) == DIRECTIVE_ELSE);
-
- if (mConditionalStack.empty())
- {
- mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELSE_WITHOUT_IF, token->location,
- token->text);
- skipUntilEOD(mTokenizer, token);
- return;
- }
-
- ConditionalBlock &block = mConditionalStack.back();
- if (block.skipBlock)
- {
- // No diagnostics. Just skip the whole line.
- skipUntilEOD(mTokenizer, token);
- return;
- }
- if (block.foundElseGroup)
- {
- mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELSE_AFTER_ELSE, token->location,
- token->text);
- skipUntilEOD(mTokenizer, token);
- return;
- }
-
- block.foundElseGroup = true;
- block.skipGroup = block.foundValidGroup;
- block.foundValidGroup = true;
-
- // Check if there are extra tokens after #else.
- mTokenizer->lex(token);
- if (!isEOD(token))
- {
- mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location,
- token->text);
- skipUntilEOD(mTokenizer, token);
- }
-}
-
-void DirectiveParser::parseElif(Token *token)
-{
- ASSERT(getDirective(token) == DIRECTIVE_ELIF);
-
- if (mConditionalStack.empty())
- {
- mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELIF_WITHOUT_IF, token->location,
- token->text);
- skipUntilEOD(mTokenizer, token);
- return;
- }
-
- ConditionalBlock &block = mConditionalStack.back();
- if (block.skipBlock)
- {
- // No diagnostics. Just skip the whole line.
- skipUntilEOD(mTokenizer, token);
- return;
- }
- if (block.foundElseGroup)
- {
- mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELIF_AFTER_ELSE, token->location,
- token->text);
- skipUntilEOD(mTokenizer, token);
- return;
- }
- if (block.foundValidGroup)
- {
- // Do not parse the expression.
- // Also be careful not to emit a diagnostic.
- block.skipGroup = true;
- skipUntilEOD(mTokenizer, token);
- return;
- }
-
- int expression = parseExpressionIf(token);
- block.skipGroup = expression == 0;
- block.foundValidGroup = expression != 0;
-}
-
-void DirectiveParser::parseEndif(Token *token)
-{
- ASSERT(getDirective(token) == DIRECTIVE_ENDIF);
-
- if (mConditionalStack.empty())
- {
- mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ENDIF_WITHOUT_IF, token->location,
- token->text);
- skipUntilEOD(mTokenizer, token);
- return;
- }
-
- mConditionalStack.pop_back();
-
- // Check if there are tokens after #endif.
- mTokenizer->lex(token);
- if (!isEOD(token))
- {
- mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location,
- token->text);
- skipUntilEOD(mTokenizer, token);
- }
-}
-
-void DirectiveParser::parseError(Token *token)
-{
- ASSERT(getDirective(token) == DIRECTIVE_ERROR);
-
- std::ostringstream stream;
- mTokenizer->lex(token);
- while ((token->type != '\n') && (token->type != Token::LAST))
- {
- stream << *token;
- mTokenizer->lex(token);
- }
- mDirectiveHandler->handleError(token->location, stream.str());
-}
-
-// Parses pragma of form: #pragma name[(value)].
-void DirectiveParser::parsePragma(Token *token)
-{
- ASSERT(getDirective(token) == DIRECTIVE_PRAGMA);
-
- enum State
- {
- PRAGMA_NAME,
- LEFT_PAREN,
- PRAGMA_VALUE,
- RIGHT_PAREN
- };
-
- bool valid = true;
- std::string name, value;
- int state = PRAGMA_NAME;
-
- mTokenizer->lex(token);
- bool stdgl = token->text == "STDGL";
- if (stdgl)
- {
- mTokenizer->lex(token);
- }
- while ((token->type != '\n') && (token->type != Token::LAST))
- {
- switch (state++)
- {
- case PRAGMA_NAME:
- name = token->text;
- valid = valid && (token->type == Token::IDENTIFIER);
- break;
- case LEFT_PAREN:
- valid = valid && (token->type == '(');
- break;
- case PRAGMA_VALUE:
- value = token->text;
- valid = valid && (token->type == Token::IDENTIFIER);
- break;
- case RIGHT_PAREN:
- valid = valid && (token->type == ')');
- break;
- default:
- valid = false;
- break;
- }
- mTokenizer->lex(token);
- }
-
- valid = valid && ((state == PRAGMA_NAME) || // Empty pragma.
- (state == LEFT_PAREN) || // Without value.
- (state == RIGHT_PAREN + 1)); // With value.
- if (!valid)
- {
- mDiagnostics->report(Diagnostics::PP_UNRECOGNIZED_PRAGMA, token->location, name);
- }
- else if (state > PRAGMA_NAME) // Do not notify for empty pragma.
- {
- mDirectiveHandler->handlePragma(token->location, name, value, stdgl);
- }
-}
-
-void DirectiveParser::parseExtension(Token *token)
-{
- ASSERT(getDirective(token) == DIRECTIVE_EXTENSION);
-
- enum State
- {
- EXT_NAME,
- COLON,
- EXT_BEHAVIOR
- };
-
- bool valid = true;
- std::string name, behavior;
- int state = EXT_NAME;
-
- mTokenizer->lex(token);
- while ((token->type != '\n') && (token->type != Token::LAST))
- {
- switch (state++)
- {
- case EXT_NAME:
- if (valid && (token->type != Token::IDENTIFIER))
- {
- mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_NAME, token->location,
- token->text);
- valid = false;
- }
- if (valid)
- name = token->text;
- break;
- case COLON:
- if (valid && (token->type != ':'))
- {
- mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location,
- token->text);
- valid = false;
- }
- break;
- case EXT_BEHAVIOR:
- if (valid && (token->type != Token::IDENTIFIER))
- {
- mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_BEHAVIOR,
- token->location, token->text);
- valid = false;
- }
- if (valid)
- behavior = token->text;
- break;
- default:
- if (valid)
- {
- mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location,
- token->text);
- valid = false;
- }
- break;
- }
- mTokenizer->lex(token);
- }
- if (valid && (state != EXT_BEHAVIOR + 1))
- {
- mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_DIRECTIVE, token->location,
- token->text);
- valid = false;
- }
- if (valid && mSeenNonPreprocessorToken)
- {
- if (mShaderVersion >= 300)
- {
- mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3,
- token->location, token->text);
- valid = false;
- }
- else
- {
- mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1,
- token->location, token->text);
- }
- }
- if (valid)
- mDirectiveHandler->handleExtension(token->location, name, behavior);
-}
-
-void DirectiveParser::parseVersion(Token *token)
-{
- ASSERT(getDirective(token) == DIRECTIVE_VERSION);
-
- if (mPastFirstStatement)
- {
- mDiagnostics->report(Diagnostics::PP_VERSION_NOT_FIRST_STATEMENT, token->location,
- token->text);
- skipUntilEOD(mTokenizer, token);
- return;
- }
-
- enum State
- {
- VERSION_NUMBER,
- VERSION_PROFILE,
- VERSION_ENDLINE
- };
-
- bool valid = true;
- int version = 0;
- int state = VERSION_NUMBER;
-
- mTokenizer->lex(token);
- while (valid && (token->type != '\n') && (token->type != Token::LAST))
- {
- switch (state)
- {
- case VERSION_NUMBER:
- if (token->type != Token::CONST_INT)
- {
- mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_NUMBER, token->location,
- token->text);
- valid = false;
- }
- if (valid && !token->iValue(&version))
- {
- mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW, token->location,
- token->text);
- valid = false;
- }
- if (valid)
- {
- state = (version < 300) ? VERSION_ENDLINE : VERSION_PROFILE;
- }
- break;
- case VERSION_PROFILE:
- if (token->type != Token::IDENTIFIER || token->text != "es")
- {
- mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_DIRECTIVE, token->location,
- token->text);
- valid = false;
- }
- state = VERSION_ENDLINE;
- break;
- default:
- mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location,
- token->text);
- valid = false;
- break;
- }
-
- mTokenizer->lex(token);
- }
-
- if (valid && (state != VERSION_ENDLINE))
- {
- mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_DIRECTIVE, token->location,
- token->text);
- valid = false;
- }
-
- if (valid && version >= 300 && token->location.line > 1)
- {
- mDiagnostics->report(Diagnostics::PP_VERSION_NOT_FIRST_LINE_ESSL3, token->location,
- token->text);
- valid = false;
- }
-
- if (valid)
- {
- mDirectiveHandler->handleVersion(token->location, version);
- mShaderVersion = version;
- PredefineMacro(mMacroSet, "__VERSION__", version);
- }
-}
-
-void DirectiveParser::parseLine(Token *token)
-{
- ASSERT(getDirective(token) == DIRECTIVE_LINE);
-
- bool valid = true;
- bool parsedFileNumber = false;
- int line = 0, file = 0;
-
- MacroExpander macroExpander(mTokenizer, mMacroSet, mDiagnostics, mMaxMacroExpansionDepth);
-
- // Lex the first token after "#line" so we can check it for EOD.
- macroExpander.lex(token);
-
- if (isEOD(token))
- {
- mDiagnostics->report(Diagnostics::PP_INVALID_LINE_DIRECTIVE, token->location, token->text);
- valid = false;
- }
- else
- {
- ExpressionParser expressionParser(&macroExpander, mDiagnostics);
- ExpressionParser::ErrorSettings errorSettings;
-
- // See GLES3 section 12.42
- errorSettings.integerLiteralsMustFit32BitSignedRange = true;
-
- errorSettings.unexpectedIdentifier = Diagnostics::PP_INVALID_LINE_NUMBER;
- // The first token was lexed earlier to check if it was EOD. Include
- // the token in parsing for a second time by setting the
- // parsePresetToken flag to true.
- expressionParser.parse(token, &line, true, errorSettings, &valid);
- if (!isEOD(token) && valid)
- {
- errorSettings.unexpectedIdentifier = Diagnostics::PP_INVALID_FILE_NUMBER;
- // After parsing the line expression expressionParser has also
- // advanced to the first token of the file expression - this is the
- // token that makes the parser reduce the "input" rule for the line
- // expression and stop. So we're using parsePresetToken = true here
- // as well.
- expressionParser.parse(token, &file, true, errorSettings, &valid);
- parsedFileNumber = true;
- }
- if (!isEOD(token))
- {
- if (valid)
- {
- mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location,
- token->text);
- valid = false;
- }
- skipUntilEOD(mTokenizer, token);
- }
- }
-
- if (valid)
- {
- mTokenizer->setLineNumber(line);
- if (parsedFileNumber)
- mTokenizer->setFileNumber(file);
- }
-}
-
-bool DirectiveParser::skipping() const
-{
- if (mConditionalStack.empty())
- return false;
-
- const ConditionalBlock &block = mConditionalStack.back();
- return block.skipBlock || block.skipGroup;
-}
-
-void DirectiveParser::parseConditionalIf(Token *token)
-{
- ConditionalBlock block;
- block.type = token->text;
- block.location = token->location;
-
- if (skipping())
- {
- // This conditional block is inside another conditional group
- // which is skipped. As a consequence this whole block is skipped.
- // Be careful not to parse the conditional expression that might
- // emit a diagnostic.
- skipUntilEOD(mTokenizer, token);
- block.skipBlock = true;
- }
- else
- {
- DirectiveType directive = getDirective(token);
-
- int expression = 0;
- switch (directive)
- {
- case DIRECTIVE_IF:
- expression = parseExpressionIf(token);
- break;
- case DIRECTIVE_IFDEF:
- expression = parseExpressionIfdef(token);
- break;
- case DIRECTIVE_IFNDEF:
- expression = parseExpressionIfdef(token) == 0 ? 1 : 0;
- break;
- default:
- UNREACHABLE();
- break;
- }
- block.skipGroup = expression == 0;
- block.foundValidGroup = expression != 0;
- }
- mConditionalStack.push_back(block);
-}
-
-int DirectiveParser::parseExpressionIf(Token *token)
-{
- ASSERT((getDirective(token) == DIRECTIVE_IF) || (getDirective(token) == DIRECTIVE_ELIF));
-
- DefinedParser definedParser(mTokenizer, mMacroSet, mDiagnostics);
- MacroExpander macroExpander(&definedParser, mMacroSet, mDiagnostics, mMaxMacroExpansionDepth);
- ExpressionParser expressionParser(&macroExpander, mDiagnostics);
-
- int expression = 0;
- ExpressionParser::ErrorSettings errorSettings;
- errorSettings.integerLiteralsMustFit32BitSignedRange = false;
- errorSettings.unexpectedIdentifier = Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN;
-
- bool valid = true;
- expressionParser.parse(token, &expression, false, errorSettings, &valid);
-
- // Check if there are tokens after #if expression.
- if (!isEOD(token))
- {
- mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location,
- token->text);
- skipUntilEOD(mTokenizer, token);
- }
-
- return expression;
-}
-
-int DirectiveParser::parseExpressionIfdef(Token *token)
-{
- ASSERT((getDirective(token) == DIRECTIVE_IFDEF) || (getDirective(token) == DIRECTIVE_IFNDEF));
-
- mTokenizer->lex(token);
- if (token->type != Token::IDENTIFIER)
- {
- mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text);
- skipUntilEOD(mTokenizer, token);
- return 0;
- }
-
- MacroSet::const_iterator iter = mMacroSet->find(token->text);
- int expression = iter != mMacroSet->end() ? 1 : 0;
-
- // Check if there are tokens after #ifdef expression.
- mTokenizer->lex(token);
- if (!isEOD(token))
- {
- mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location,
- token->text);
- skipUntilEOD(mTokenizer, token);
- }
- return expression;
-}
-
-} // namespace pp
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/DirectiveParser.h b/src/3rdparty/angle/src/compiler/preprocessor/DirectiveParser.h
deleted file mode 100644
index 29c30a8239..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/DirectiveParser.h
+++ /dev/null
@@ -1,83 +0,0 @@
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_PREPROCESSOR_DIRECTIVEPARSER_H_
-#define COMPILER_PREPROCESSOR_DIRECTIVEPARSER_H_
-
-#include "compiler/preprocessor/Lexer.h"
-#include "compiler/preprocessor/Macro.h"
-#include "compiler/preprocessor/SourceLocation.h"
-
-namespace pp
-{
-
-class Diagnostics;
-class DirectiveHandler;
-class Tokenizer;
-
-class DirectiveParser : public Lexer
-{
- public:
- DirectiveParser(Tokenizer *tokenizer,
- MacroSet *macroSet,
- Diagnostics *diagnostics,
- DirectiveHandler *directiveHandler,
- int maxMacroExpansionDepth);
- ~DirectiveParser() override;
-
- void lex(Token *token) override;
-
- private:
- void parseDirective(Token *token);
- void parseDefine(Token *token);
- void parseUndef(Token *token);
- void parseIf(Token *token);
- void parseIfdef(Token *token);
- void parseIfndef(Token *token);
- void parseElse(Token *token);
- void parseElif(Token *token);
- void parseEndif(Token *token);
- void parseError(Token *token);
- void parsePragma(Token *token);
- void parseExtension(Token *token);
- void parseVersion(Token *token);
- void parseLine(Token *token);
-
- bool skipping() const;
- void parseConditionalIf(Token *token);
- int parseExpressionIf(Token *token);
- int parseExpressionIfdef(Token *token);
-
- struct ConditionalBlock
- {
- std::string type;
- SourceLocation location;
- bool skipBlock;
- bool skipGroup;
- bool foundValidGroup;
- bool foundElseGroup;
-
- ConditionalBlock()
- : skipBlock(false), skipGroup(false), foundValidGroup(false), foundElseGroup(false)
- {
- }
- };
- bool mPastFirstStatement;
- bool mSeenNonPreprocessorToken; // Tracks if a non-preprocessor token has been seen yet. Some
- // macros, such as
- // #extension must be declared before all shader code.
- std::vector<ConditionalBlock> mConditionalStack;
- Tokenizer *mTokenizer;
- MacroSet *mMacroSet;
- Diagnostics *mDiagnostics;
- DirectiveHandler *mDirectiveHandler;
- int mShaderVersion;
- int mMaxMacroExpansionDepth;
-};
-
-} // namespace pp
-
-#endif // COMPILER_PREPROCESSOR_DIRECTIVEPARSER_H_
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.h b/src/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.h
deleted file mode 100644
index 0f2901b878..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.h
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_PREPROCESSOR_EXPRESSIONPARSER_H_
-#define COMPILER_PREPROCESSOR_EXPRESSIONPARSER_H_
-
-#include "common/angleutils.h"
-#include "compiler/preprocessor/DiagnosticsBase.h"
-
-namespace pp
-{
-
-class Lexer;
-struct Token;
-
-class ExpressionParser : angle::NonCopyable
-{
- public:
- struct ErrorSettings
- {
- Diagnostics::ID unexpectedIdentifier;
- bool integerLiteralsMustFit32BitSignedRange;
- };
-
- ExpressionParser(Lexer *lexer, Diagnostics *diagnostics);
-
- bool parse(Token *token,
- int *result,
- bool parsePresetToken,
- const ErrorSettings &errorSettings,
- bool *valid);
-
- private:
- Lexer *mLexer;
- Diagnostics *mDiagnostics;
-};
-
-} // namespace pp
-
-#endif // COMPILER_PREPROCESSOR_EXPRESSIONPARSER_H_
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.y b/src/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.y
deleted file mode 100644
index 68d7cc3958..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.y
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-This file contains the Yacc grammar for GLSL ES preprocessor expression.
-
-IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh,
-WHICH GENERATES THE GLSL ES preprocessor expression parser.
-*/
-
-%{
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// This file is auto-generated by generate_parser.sh. DO NOT EDIT!
-
-#if defined(__GNUC__)
-// Triggered by the auto-generated pplval variable.
-#if !defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
-#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
-#else
-#pragma GCC diagnostic ignored "-Wuninitialized"
-#endif
-#elif defined(_MSC_VER)
-#pragma warning(disable: 4065 4244 4701 4702)
-#endif
-
-#include "ExpressionParser.h"
-
-#if defined(_MSC_VER)
-#include <malloc.h>
-#else
-#include <stdlib.h>
-#endif
-
-#include <cassert>
-#include <sstream>
-#include <stdint.h>
-
-#include "DiagnosticsBase.h"
-#include "Lexer.h"
-#include "Token.h"
-#include "common/mathutil.h"
-
-typedef int32_t YYSTYPE;
-typedef uint32_t UNSIGNED_TYPE;
-
-#define YYENABLE_NLS 0
-#define YYLTYPE_IS_TRIVIAL 1
-#define YYSTYPE_IS_TRIVIAL 1
-#define YYSTYPE_IS_DECLARED 1
-
-namespace {
-struct Context
-{
- pp::Diagnostics* diagnostics;
- pp::Lexer* lexer;
- pp::Token* token;
- int* result;
- bool parsePresetToken;
-
- pp::ExpressionParser::ErrorSettings errorSettings;
- bool *valid;
-
- void startIgnoreErrors() { ++ignoreErrors; }
- void endIgnoreErrors() { --ignoreErrors; }
-
- bool isIgnoringErrors() { return ignoreErrors > 0; }
-
- int ignoreErrors;
-};
-} // namespace
-%}
-
-%pure-parser
-%name-prefix "pp"
-%parse-param {Context *context}
-%lex-param {Context *context}
-
-%{
-static int yylex(YYSTYPE* lvalp, Context* context);
-static void yyerror(Context* context, const char* reason);
-%}
-
-%token TOK_CONST_INT
-%token TOK_IDENTIFIER
-%left TOK_OP_OR
-%left TOK_OP_AND
-%left '|'
-%left '^'
-%left '&'
-%left TOK_OP_EQ TOK_OP_NE
-%left '<' '>' TOK_OP_LE TOK_OP_GE
-%left TOK_OP_LEFT TOK_OP_RIGHT
-%left '+' '-'
-%left '*' '/' '%'
-%right TOK_UNARY
-
-%%
-
-input
- : expression {
- *(context->result) = static_cast<int>($1);
- YYACCEPT;
- }
-;
-
-expression
- : TOK_CONST_INT
- | TOK_IDENTIFIER {
- if (!context->isIgnoringErrors())
- {
- // This rule should be applied right after the token is lexed, so we can
- // refer to context->token in the error message.
- context->diagnostics->report(context->errorSettings.unexpectedIdentifier,
- context->token->location, context->token->text);
- *(context->valid) = false;
- }
- $$ = $1;
- }
- | expression TOK_OP_OR {
- if ($1 != 0)
- {
- // Ignore errors in the short-circuited part of the expression.
- // ESSL3.00 section 3.4:
- // If an operand is not evaluated, the presence of undefined identifiers
- // in the operand will not cause an error.
- // Unevaluated division by zero should not cause an error either.
- context->startIgnoreErrors();
- }
- } expression {
- if ($1 != 0)
- {
- context->endIgnoreErrors();
- $$ = static_cast<YYSTYPE>(1);
- }
- else
- {
- $$ = $1 || $4;
- }
- }
- | expression TOK_OP_AND {
- if ($1 == 0)
- {
- // Ignore errors in the short-circuited part of the expression.
- // ESSL3.00 section 3.4:
- // If an operand is not evaluated, the presence of undefined identifiers
- // in the operand will not cause an error.
- // Unevaluated division by zero should not cause an error either.
- context->startIgnoreErrors();
- }
- } expression {
- if ($1 == 0)
- {
- context->endIgnoreErrors();
- $$ = static_cast<YYSTYPE>(0);
- }
- else
- {
- $$ = $1 && $4;
- }
- }
- | expression '|' expression {
- $$ = $1 | $3;
- }
- | expression '^' expression {
- $$ = $1 ^ $3;
- }
- | expression '&' expression {
- $$ = $1 & $3;
- }
- | expression TOK_OP_NE expression {
- $$ = $1 != $3;
- }
- | expression TOK_OP_EQ expression {
- $$ = $1 == $3;
- }
- | expression TOK_OP_GE expression {
- $$ = $1 >= $3;
- }
- | expression TOK_OP_LE expression {
- $$ = $1 <= $3;
- }
- | expression '>' expression {
- $$ = $1 > $3;
- }
- | expression '<' expression {
- $$ = $1 < $3;
- }
- | expression TOK_OP_RIGHT expression {
- if ($3 < 0 || $3 > 31)
- {
- if (!context->isIgnoringErrors())
- {
- std::ostringstream stream;
- stream << $1 << " >> " << $3;
- std::string text = stream.str();
- context->diagnostics->report(pp::Diagnostics::PP_UNDEFINED_SHIFT,
- context->token->location,
- text.c_str());
- *(context->valid) = false;
- }
- $$ = static_cast<YYSTYPE>(0);
- }
- else if ($1 < 0)
- {
- // Logical shift right.
- $$ = static_cast<YYSTYPE>(static_cast<UNSIGNED_TYPE>($1) >> $3);
- }
- else
- {
- $$ = $1 >> $3;
- }
- }
- | expression TOK_OP_LEFT expression {
- if ($3 < 0 || $3 > 31)
- {
- if (!context->isIgnoringErrors())
- {
- std::ostringstream stream;
- stream << $1 << " << " << $3;
- std::string text = stream.str();
- context->diagnostics->report(pp::Diagnostics::PP_UNDEFINED_SHIFT,
- context->token->location,
- text.c_str());
- *(context->valid) = false;
- }
- $$ = static_cast<YYSTYPE>(0);
- }
- else
- {
- // Logical shift left. Casting to unsigned is needed to ensure there's no signed integer
- // overflow, which some tools treat as an error.
- $$ = static_cast<YYSTYPE>(static_cast<UNSIGNED_TYPE>($1) << $3);
- }
- }
- | expression '-' expression {
- $$ = gl::WrappingDiff<YYSTYPE>($1, $3);
- }
- | expression '+' expression {
- $$ = gl::WrappingSum<YYSTYPE>($1, $3);
- }
- | expression '%' expression {
- if ($3 == 0)
- {
- if (!context->isIgnoringErrors())
- {
- std::ostringstream stream;
- stream << $1 << " % " << $3;
- std::string text = stream.str();
- context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
- context->token->location,
- text.c_str());
- *(context->valid) = false;
- }
- $$ = static_cast<YYSTYPE>(0);
- }
- else if (($1 == std::numeric_limits<YYSTYPE>::min()) && ($3 == -1))
- {
- // Check for the special case where the minimum representable number is
- // divided by -1. If left alone this has undefined results.
- $$ = 0;
- }
- else
- {
- $$ = $1 % $3;
- }
- }
- | expression '/' expression {
- if ($3 == 0)
- {
- if (!context->isIgnoringErrors())
- {
- std::ostringstream stream;
- stream << $1 << " / " << $3;
- std::string text = stream.str();
- context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
- context->token->location,
- text.c_str());
- *(context->valid) = false;
- }
- $$ = static_cast<YYSTYPE>(0);
- }
- else if (($1 == std::numeric_limits<YYSTYPE>::min()) && ($3 == -1))
- {
- // Check for the special case where the minimum representable number is
- // divided by -1. If left alone this leads to integer overflow in C++, which
- // has undefined results.
- $$ = std::numeric_limits<YYSTYPE>::max();
- }
- else
- {
- $$ = $1 / $3;
- }
- }
- | expression '*' expression {
- $$ = gl::WrappingMul($1, $3);
- }
- | '!' expression %prec TOK_UNARY {
- $$ = ! $2;
- }
- | '~' expression %prec TOK_UNARY {
- $$ = ~ $2;
- }
- | '-' expression %prec TOK_UNARY {
- // Check for negation of minimum representable integer to prevent undefined signed int
- // overflow.
- if ($2 == std::numeric_limits<YYSTYPE>::min())
- {
- $$ = std::numeric_limits<YYSTYPE>::min();
- }
- else
- {
- $$ = -$2;
- }
- }
- | '+' expression %prec TOK_UNARY {
- $$ = + $2;
- }
- | '(' expression ')' {
- $$ = $2;
- }
-;
-
-%%
-
-int yylex(YYSTYPE *lvalp, Context *context)
-{
- pp::Token *token = context->token;
- if (!context->parsePresetToken)
- {
- context->lexer->lex(token);
- }
- context->parsePresetToken = false;
-
- int type = 0;
-
- switch (token->type)
- {
- case pp::Token::CONST_INT: {
- unsigned int val = 0;
- int testVal = 0;
- if (!token->uValue(&val) || (!token->iValue(&testVal) &&
- context->errorSettings.integerLiteralsMustFit32BitSignedRange))
- {
- context->diagnostics->report(pp::Diagnostics::PP_INTEGER_OVERFLOW,
- token->location, token->text);
- *(context->valid) = false;
- }
- *lvalp = static_cast<YYSTYPE>(val);
- type = TOK_CONST_INT;
- break;
- }
- case pp::Token::IDENTIFIER:
- *lvalp = static_cast<YYSTYPE>(-1);
- type = TOK_IDENTIFIER;
- break;
- case pp::Token::OP_OR:
- type = TOK_OP_OR;
- break;
- case pp::Token::OP_AND:
- type = TOK_OP_AND;
- break;
- case pp::Token::OP_NE:
- type = TOK_OP_NE;
- break;
- case pp::Token::OP_EQ:
- type = TOK_OP_EQ;
- break;
- case pp::Token::OP_GE:
- type = TOK_OP_GE;
- break;
- case pp::Token::OP_LE:
- type = TOK_OP_LE;
- break;
- case pp::Token::OP_RIGHT:
- type = TOK_OP_RIGHT;
- break;
- case pp::Token::OP_LEFT:
- type = TOK_OP_LEFT;
- break;
- case '|':
- case '^':
- case '&':
- case '>':
- case '<':
- case '-':
- case '+':
- case '%':
- case '/':
- case '*':
- case '!':
- case '~':
- case '(':
- case ')':
- type = token->type;
- break;
-
- default:
- break;
- }
-
- return type;
-}
-
-void yyerror(Context *context, const char *reason)
-{
- context->diagnostics->report(pp::Diagnostics::PP_INVALID_EXPRESSION,
- context->token->location,
- reason);
-}
-
-namespace pp {
-
-ExpressionParser::ExpressionParser(Lexer *lexer, Diagnostics *diagnostics)
- : mLexer(lexer),
- mDiagnostics(diagnostics)
-{
-}
-
-bool ExpressionParser::parse(Token *token,
- int *result,
- bool parsePresetToken,
- const ErrorSettings &errorSettings,
- bool *valid)
-{
- Context context;
- context.diagnostics = mDiagnostics;
- context.lexer = mLexer;
- context.token = token;
- context.result = result;
- context.ignoreErrors = 0;
- context.parsePresetToken = parsePresetToken;
- context.errorSettings = errorSettings;
- context.valid = valid;
- int ret = yyparse(&context);
- switch (ret)
- {
- case 0:
- case 1:
- break;
-
- case 2:
- mDiagnostics->report(Diagnostics::PP_OUT_OF_MEMORY, token->location, "");
- break;
-
- default:
- assert(false);
- mDiagnostics->report(Diagnostics::PP_INTERNAL_ERROR, token->location, "");
- break;
- }
-
- return ret == 0;
-}
-
-} // namespace pp
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Input.cpp b/src/3rdparty/angle/src/compiler/preprocessor/Input.cpp
deleted file mode 100644
index 0f2327b823..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/Input.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-//
-// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/preprocessor/Input.h"
-
-#include <algorithm>
-#include <cstring>
-
-#include "common/debug.h"
-
-namespace pp
-{
-
-Input::Input() : mCount(0), mString(0)
-{
-}
-
-Input::~Input()
-{
-}
-
-Input::Input(size_t count, const char *const string[], const int length[])
- : mCount(count), mString(string)
-{
- mLength.reserve(mCount);
- for (size_t i = 0; i < mCount; ++i)
- {
- int len = length ? length[i] : -1;
- mLength.push_back(len < 0 ? std::strlen(mString[i]) : len);
- }
-}
-
-const char *Input::skipChar()
-{
- // This function should only be called when there is a character to skip.
- ASSERT(mReadLoc.cIndex < mLength[mReadLoc.sIndex]);
- ++mReadLoc.cIndex;
- if (mReadLoc.cIndex == mLength[mReadLoc.sIndex])
- {
- ++mReadLoc.sIndex;
- mReadLoc.cIndex = 0;
- }
- if (mReadLoc.sIndex >= mCount)
- {
- return nullptr;
- }
- return mString[mReadLoc.sIndex] + mReadLoc.cIndex;
-}
-
-size_t Input::read(char *buf, size_t maxSize, int *lineNo)
-{
- size_t nRead = 0;
- // The previous call to read might have stopped copying the string when encountering a line
- // continuation. Check for this possibility first.
- if (mReadLoc.sIndex < mCount && maxSize > 0)
- {
- const char *c = mString[mReadLoc.sIndex] + mReadLoc.cIndex;
- if ((*c) == '\\')
- {
- c = skipChar();
- if (c != nullptr && (*c) == '\n')
- {
- // Line continuation of backslash + newline.
- skipChar();
- // Fake an EOF if the line number would overflow.
- if (*lineNo == INT_MAX)
- {
- return 0;
- }
- ++(*lineNo);
- }
- else if (c != nullptr && (*c) == '\r')
- {
- // Line continuation. Could be backslash + '\r\n' or just backslash + '\r'.
- c = skipChar();
- if (c != nullptr && (*c) == '\n')
- {
- skipChar();
- }
- // Fake an EOF if the line number would overflow.
- if (*lineNo == INT_MAX)
- {
- return 0;
- }
- ++(*lineNo);
- }
- else
- {
- // Not line continuation, so write the skipped backslash to buf.
- *buf = '\\';
- ++nRead;
- }
- }
- }
-
- size_t maxRead = maxSize;
- while ((nRead < maxRead) && (mReadLoc.sIndex < mCount))
- {
- size_t size = mLength[mReadLoc.sIndex] - mReadLoc.cIndex;
- size = std::min(size, maxSize);
- for (size_t i = 0; i < size; ++i)
- {
- // Stop if a possible line continuation is encountered.
- // It will be processed on the next call on input, which skips it
- // and increments line number if necessary.
- if (*(mString[mReadLoc.sIndex] + mReadLoc.cIndex + i) == '\\')
- {
- size = i;
- maxRead = nRead + size; // Stop reading right before the backslash.
- }
- }
- std::memcpy(buf + nRead, mString[mReadLoc.sIndex] + mReadLoc.cIndex, size);
- nRead += size;
- mReadLoc.cIndex += size;
-
- // Advance string if we reached the end of current string.
- if (mReadLoc.cIndex == mLength[mReadLoc.sIndex])
- {
- ++mReadLoc.sIndex;
- mReadLoc.cIndex = 0;
- }
- }
- return nRead;
-}
-
-} // namespace pp
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Input.h b/src/3rdparty/angle/src/compiler/preprocessor/Input.h
deleted file mode 100644
index 8c7c7ee19e..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/Input.h
+++ /dev/null
@@ -1,54 +0,0 @@
-//
-// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_PREPROCESSOR_INPUT_H_
-#define COMPILER_PREPROCESSOR_INPUT_H_
-
-#include <cstddef>
-#include <vector>
-
-namespace pp
-{
-
-// Holds and reads input for Lexer.
-class Input
-{
- public:
- Input();
- ~Input();
- Input(size_t count, const char *const string[], const int length[]);
-
- size_t count() const { return mCount; }
- const char *string(size_t index) const { return mString[index]; }
- size_t length(size_t index) const { return mLength[index]; }
-
- size_t read(char *buf, size_t maxSize, int *lineNo);
-
- struct Location
- {
- size_t sIndex; // String index;
- size_t cIndex; // Char index.
-
- Location() : sIndex(0), cIndex(0) {}
- };
- const Location &readLoc() const { return mReadLoc; }
-
- private:
- // Skip a character and return the next character after the one that was skipped.
- // Return nullptr if data runs out.
- const char *skipChar();
-
- // Input.
- size_t mCount;
- const char *const *mString;
- std::vector<size_t> mLength;
-
- Location mReadLoc;
-};
-
-} // namespace pp
-
-#endif // COMPILER_PREPROCESSOR_INPUT_H_
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Lexer.cpp b/src/3rdparty/angle/src/compiler/preprocessor/Lexer.cpp
deleted file mode 100644
index 89cb3cf44e..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/Lexer.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/preprocessor/Lexer.h"
-
-namespace pp
-{
-
-Lexer::~Lexer()
-{
-}
-
-} // namespace pp
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Lexer.h b/src/3rdparty/angle/src/compiler/preprocessor/Lexer.h
deleted file mode 100644
index 775bc0a202..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/Lexer.h
+++ /dev/null
@@ -1,27 +0,0 @@
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_PREPROCESSOR_LEXER_H_
-#define COMPILER_PREPROCESSOR_LEXER_H_
-
-#include "common/angleutils.h"
-
-namespace pp
-{
-
-struct Token;
-
-class Lexer : angle::NonCopyable
-{
- public:
- virtual ~Lexer();
-
- virtual void lex(Token *token) = 0;
-};
-
-} // namespace pp
-
-#endif // COMPILER_PREPROCESSOR_LEXER_H_
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Macro.cpp b/src/3rdparty/angle/src/compiler/preprocessor/Macro.cpp
deleted file mode 100644
index 52e2312fe6..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/Macro.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/preprocessor/Macro.h"
-
-#include "common/angleutils.h"
-#include "compiler/preprocessor/Token.h"
-
-namespace pp
-{
-
-Macro::Macro() : predefined(false), disabled(false), expansionCount(0), type(kTypeObj)
-{
-}
-
-Macro::~Macro()
-{
-}
-
-bool Macro::equals(const Macro &other) const
-{
- return (type == other.type) && (name == other.name) && (parameters == other.parameters) &&
- (replacements == other.replacements);
-}
-
-void PredefineMacro(MacroSet *macroSet, const char *name, int value)
-{
- Token token;
- token.type = Token::CONST_INT;
- token.text = ToString(value);
-
- std::shared_ptr<Macro> macro = std::make_shared<Macro>();
- macro->predefined = true;
- macro->type = Macro::kTypeObj;
- macro->name = name;
- macro->replacements.push_back(token);
-
- (*macroSet)[name] = macro;
-}
-
-} // namespace pp
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Macro.h b/src/3rdparty/angle/src/compiler/preprocessor/Macro.h
deleted file mode 100644
index c42e172ef9..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/Macro.h
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_PREPROCESSOR_MACRO_H_
-#define COMPILER_PREPROCESSOR_MACRO_H_
-
-#include <map>
-#include <memory>
-#include <string>
-#include <vector>
-
-namespace pp
-{
-
-struct Token;
-
-struct Macro
-{
- enum Type
- {
- kTypeObj,
- kTypeFunc
- };
- typedef std::vector<std::string> Parameters;
- typedef std::vector<Token> Replacements;
-
- Macro();
- ~Macro();
- bool equals(const Macro &other) const;
-
- bool predefined;
- mutable bool disabled;
- mutable int expansionCount;
-
- Type type;
- std::string name;
- Parameters parameters;
- Replacements replacements;
-};
-
-typedef std::map<std::string, std::shared_ptr<Macro>> MacroSet;
-
-void PredefineMacro(MacroSet *macroSet, const char *name, int value);
-
-} // namespace pp
-
-#endif // COMPILER_PREPROCESSOR_MACRO_H_
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/MacroExpander.cpp b/src/3rdparty/angle/src/compiler/preprocessor/MacroExpander.cpp
deleted file mode 100644
index d88d3a6853..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/MacroExpander.cpp
+++ /dev/null
@@ -1,481 +0,0 @@
-//
-// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/preprocessor/MacroExpander.h"
-
-#include <algorithm>
-
-#include "common/debug.h"
-#include "compiler/preprocessor/DiagnosticsBase.h"
-#include "compiler/preprocessor/Token.h"
-
-namespace pp
-{
-
-namespace
-{
-
-const size_t kMaxContextTokens = 10000;
-
-class TokenLexer : public Lexer
-{
- public:
- typedef std::vector<Token> TokenVector;
-
- TokenLexer(TokenVector *tokens)
- {
- tokens->swap(mTokens);
- mIter = mTokens.begin();
- }
-
- void lex(Token *token) override
- {
- if (mIter == mTokens.end())
- {
- token->reset();
- token->type = Token::LAST;
- }
- else
- {
- *token = *mIter++;
- }
- }
-
- private:
- TokenVector mTokens;
- TokenVector::const_iterator mIter;
-};
-
-} // anonymous namespace
-
-class MacroExpander::ScopedMacroReenabler final : angle::NonCopyable
-{
- public:
- ScopedMacroReenabler(MacroExpander *expander);
- ~ScopedMacroReenabler();
-
- private:
- MacroExpander *mExpander;
-};
-
-MacroExpander::ScopedMacroReenabler::ScopedMacroReenabler(MacroExpander *expander)
- : mExpander(expander)
-{
- mExpander->mDeferReenablingMacros = true;
-}
-
-MacroExpander::ScopedMacroReenabler::~ScopedMacroReenabler()
-{
- mExpander->mDeferReenablingMacros = false;
- for (auto macro : mExpander->mMacrosToReenable)
- {
- // Copying the string here by using substr is a check for use-after-free. It detects
- // use-after-free more reliably than just toggling the disabled flag.
- ASSERT(macro->name.substr() != "");
- macro->disabled = false;
- }
- mExpander->mMacrosToReenable.clear();
-}
-
-MacroExpander::MacroExpander(Lexer *lexer,
- MacroSet *macroSet,
- Diagnostics *diagnostics,
- int allowedMacroExpansionDepth)
- : mLexer(lexer),
- mMacroSet(macroSet),
- mDiagnostics(diagnostics),
- mTotalTokensInContexts(0),
- mAllowedMacroExpansionDepth(allowedMacroExpansionDepth),
- mDeferReenablingMacros(false)
-{
-}
-
-MacroExpander::~MacroExpander()
-{
- ASSERT(mMacrosToReenable.empty());
- for (MacroContext *context : mContextStack)
- {
- delete context;
- }
-}
-
-void MacroExpander::lex(Token *token)
-{
- while (true)
- {
- getToken(token);
-
- if (token->type != Token::IDENTIFIER)
- break;
-
- if (token->expansionDisabled())
- break;
-
- MacroSet::const_iterator iter = mMacroSet->find(token->text);
- if (iter == mMacroSet->end())
- break;
-
- std::shared_ptr<Macro> macro = iter->second;
- if (macro->disabled)
- {
- // If a particular token is not expanded, it is never expanded.
- token->setExpansionDisabled(true);
- break;
- }
-
- // Bump the expansion count before peeking if the next token is a '('
- // otherwise there could be a #undef of the macro before the next token.
- macro->expansionCount++;
- if ((macro->type == Macro::kTypeFunc) && !isNextTokenLeftParen())
- {
- // If the token immediately after the macro name is not a '(',
- // this macro should not be expanded.
- macro->expansionCount--;
- break;
- }
-
- pushMacro(macro, *token);
- }
-}
-
-void MacroExpander::getToken(Token *token)
-{
- if (mReserveToken.get())
- {
- *token = *mReserveToken;
- mReserveToken.reset();
- return;
- }
-
- // First pop all empty macro contexts.
- while (!mContextStack.empty() && mContextStack.back()->empty())
- {
- popMacro();
- }
-
- if (!mContextStack.empty())
- {
- *token = mContextStack.back()->get();
- }
- else
- {
- ASSERT(mTotalTokensInContexts == 0);
- mLexer->lex(token);
- }
-}
-
-void MacroExpander::ungetToken(const Token &token)
-{
- if (!mContextStack.empty())
- {
- MacroContext *context = mContextStack.back();
- context->unget();
- ASSERT(context->replacements[context->index] == token);
- }
- else
- {
- ASSERT(!mReserveToken.get());
- mReserveToken.reset(new Token(token));
- }
-}
-
-bool MacroExpander::isNextTokenLeftParen()
-{
- Token token;
- getToken(&token);
-
- bool lparen = token.type == '(';
- ungetToken(token);
-
- return lparen;
-}
-
-bool MacroExpander::pushMacro(std::shared_ptr<Macro> macro, const Token &identifier)
-{
- ASSERT(!macro->disabled);
- ASSERT(!identifier.expansionDisabled());
- ASSERT(identifier.type == Token::IDENTIFIER);
- ASSERT(identifier.text == macro->name);
-
- std::vector<Token> replacements;
- if (!expandMacro(*macro, identifier, &replacements))
- return false;
-
- // Macro is disabled for expansion until it is popped off the stack.
- macro->disabled = true;
-
- MacroContext *context = new MacroContext;
- context->macro = macro;
- context->replacements.swap(replacements);
- mContextStack.push_back(context);
- mTotalTokensInContexts += context->replacements.size();
- return true;
-}
-
-void MacroExpander::popMacro()
-{
- ASSERT(!mContextStack.empty());
-
- MacroContext *context = mContextStack.back();
- mContextStack.pop_back();
-
- ASSERT(context->empty());
- ASSERT(context->macro->disabled);
- ASSERT(context->macro->expansionCount > 0);
- if (mDeferReenablingMacros)
- {
- mMacrosToReenable.push_back(context->macro);
- }
- else
- {
- context->macro->disabled = false;
- }
- context->macro->expansionCount--;
- mTotalTokensInContexts -= context->replacements.size();
- delete context;
-}
-
-bool MacroExpander::expandMacro(const Macro &macro,
- const Token &identifier,
- std::vector<Token> *replacements)
-{
- replacements->clear();
-
- // In the case of an object-like macro, the replacement list gets its location
- // from the identifier, but in the case of a function-like macro, the replacement
- // list gets its location from the closing parenthesis of the macro invocation.
- // This is tested by dEQP-GLES3.functional.shaders.preprocessor.predefined_macros.*
- SourceLocation replacementLocation = identifier.location;
- if (macro.type == Macro::kTypeObj)
- {
- replacements->assign(macro.replacements.begin(), macro.replacements.end());
-
- if (macro.predefined)
- {
- const char kLine[] = "__LINE__";
- const char kFile[] = "__FILE__";
-
- ASSERT(replacements->size() == 1);
- Token &repl = replacements->front();
- if (macro.name == kLine)
- {
- repl.text = ToString(identifier.location.line);
- }
- else if (macro.name == kFile)
- {
- repl.text = ToString(identifier.location.file);
- }
- }
- }
- else
- {
- ASSERT(macro.type == Macro::kTypeFunc);
- std::vector<MacroArg> args;
- args.reserve(macro.parameters.size());
- if (!collectMacroArgs(macro, identifier, &args, &replacementLocation))
- return false;
-
- replaceMacroParams(macro, args, replacements);
- }
-
- for (std::size_t i = 0; i < replacements->size(); ++i)
- {
- Token &repl = replacements->at(i);
- if (i == 0)
- {
- // The first token in the replacement list inherits the padding
- // properties of the identifier token.
- repl.setAtStartOfLine(identifier.atStartOfLine());
- repl.setHasLeadingSpace(identifier.hasLeadingSpace());
- }
- repl.location = replacementLocation;
- }
- return true;
-}
-
-bool MacroExpander::collectMacroArgs(const Macro &macro,
- const Token &identifier,
- std::vector<MacroArg> *args,
- SourceLocation *closingParenthesisLocation)
-{
- Token token;
- getToken(&token);
- ASSERT(token.type == '(');
-
- args->push_back(MacroArg());
-
- // Defer reenabling macros until args collection is finished to avoid the possibility of
- // infinite recursion. Otherwise infinite recursion might happen when expanding the args after
- // macros have been popped from the context stack when parsing the args.
- ScopedMacroReenabler deferReenablingMacros(this);
-
- int openParens = 1;
- while (openParens != 0)
- {
- getToken(&token);
-
- if (token.type == Token::LAST)
- {
- mDiagnostics->report(Diagnostics::PP_MACRO_UNTERMINATED_INVOCATION, identifier.location,
- identifier.text);
- // Do not lose EOF token.
- ungetToken(token);
- return false;
- }
-
- bool isArg = false; // True if token is part of the current argument.
- switch (token.type)
- {
- case '(':
- ++openParens;
- isArg = true;
- break;
- case ')':
- --openParens;
- isArg = openParens != 0;
- *closingParenthesisLocation = token.location;
- break;
- case ',':
- // The individual arguments are separated by comma tokens, but
- // the comma tokens between matching inner parentheses do not
- // seperate arguments.
- if (openParens == 1)
- args->push_back(MacroArg());
- isArg = openParens != 1;
- break;
- default:
- isArg = true;
- break;
- }
- if (isArg)
- {
- MacroArg &arg = args->back();
- // Initial whitespace is not part of the argument.
- if (arg.empty())
- token.setHasLeadingSpace(false);
- arg.push_back(token);
- }
- }
-
- const Macro::Parameters &params = macro.parameters;
- // If there is only one empty argument, it is equivalent to no argument.
- if (params.empty() && (args->size() == 1) && args->front().empty())
- {
- args->clear();
- }
- // Validate the number of arguments.
- if (args->size() != params.size())
- {
- Diagnostics::ID id = args->size() < macro.parameters.size()
- ? Diagnostics::PP_MACRO_TOO_FEW_ARGS
- : Diagnostics::PP_MACRO_TOO_MANY_ARGS;
- mDiagnostics->report(id, identifier.location, identifier.text);
- return false;
- }
-
- // Pre-expand each argument before substitution.
- // This step expands each argument individually before they are
- // inserted into the macro body.
- size_t numTokens = 0;
- for (auto &arg : *args)
- {
- TokenLexer lexer(&arg);
- if (mAllowedMacroExpansionDepth < 1)
- {
- mDiagnostics->report(Diagnostics::PP_MACRO_INVOCATION_CHAIN_TOO_DEEP, token.location,
- token.text);
- return false;
- }
- MacroExpander expander(&lexer, mMacroSet, mDiagnostics, mAllowedMacroExpansionDepth - 1);
-
- arg.clear();
- expander.lex(&token);
- while (token.type != Token::LAST)
- {
- arg.push_back(token);
- expander.lex(&token);
- numTokens++;
- if (numTokens + mTotalTokensInContexts > kMaxContextTokens)
- {
- mDiagnostics->report(Diagnostics::PP_OUT_OF_MEMORY, token.location, token.text);
- return false;
- }
- }
- }
- return true;
-}
-
-void MacroExpander::replaceMacroParams(const Macro &macro,
- const std::vector<MacroArg> &args,
- std::vector<Token> *replacements)
-{
- for (std::size_t i = 0; i < macro.replacements.size(); ++i)
- {
- if (!replacements->empty() &&
- replacements->size() + mTotalTokensInContexts > kMaxContextTokens)
- {
- const Token &token = replacements->back();
- mDiagnostics->report(Diagnostics::PP_OUT_OF_MEMORY, token.location, token.text);
- return;
- }
-
- const Token &repl = macro.replacements[i];
- if (repl.type != Token::IDENTIFIER)
- {
- replacements->push_back(repl);
- continue;
- }
-
- // TODO(alokp): Optimize this.
- // There is no need to search for macro params every time.
- // The param index can be cached with the replacement token.
- Macro::Parameters::const_iterator iter =
- std::find(macro.parameters.begin(), macro.parameters.end(), repl.text);
- if (iter == macro.parameters.end())
- {
- replacements->push_back(repl);
- continue;
- }
-
- std::size_t iArg = std::distance(macro.parameters.begin(), iter);
- const MacroArg &arg = args[iArg];
- if (arg.empty())
- {
- continue;
- }
- std::size_t iRepl = replacements->size();
- replacements->insert(replacements->end(), arg.begin(), arg.end());
- // The replacement token inherits padding properties from
- // macro replacement token.
- replacements->at(iRepl).setHasLeadingSpace(repl.hasLeadingSpace());
- }
-}
-
-MacroExpander::MacroContext::MacroContext() : macro(0), index(0)
-{
-}
-
-MacroExpander::MacroContext::~MacroContext()
-{
-}
-
-bool MacroExpander::MacroContext::empty() const
-{
- return index == replacements.size();
-}
-
-const Token &MacroExpander::MacroContext::get()
-{
- return replacements[index++];
-}
-
-void MacroExpander::MacroContext::unget()
-{
- ASSERT(index > 0);
- --index;
-}
-
-} // namespace pp
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/MacroExpander.h b/src/3rdparty/angle/src/compiler/preprocessor/MacroExpander.h
deleted file mode 100644
index fae7676fb0..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/MacroExpander.h
+++ /dev/null
@@ -1,83 +0,0 @@
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_PREPROCESSOR_MACROEXPANDER_H_
-#define COMPILER_PREPROCESSOR_MACROEXPANDER_H_
-
-#include <memory>
-#include <vector>
-
-#include "compiler/preprocessor/Lexer.h"
-#include "compiler/preprocessor/Macro.h"
-
-namespace pp
-{
-
-class Diagnostics;
-struct SourceLocation;
-
-class MacroExpander : public Lexer
-{
- public:
- MacroExpander(Lexer *lexer,
- MacroSet *macroSet,
- Diagnostics *diagnostics,
- int allowedMacroExpansionDepth);
- ~MacroExpander() override;
-
- void lex(Token *token) override;
-
- private:
- void getToken(Token *token);
- void ungetToken(const Token &token);
- bool isNextTokenLeftParen();
-
- bool pushMacro(std::shared_ptr<Macro> macro, const Token &identifier);
- void popMacro();
-
- bool expandMacro(const Macro &macro, const Token &identifier, std::vector<Token> *replacements);
-
- typedef std::vector<Token> MacroArg;
- bool collectMacroArgs(const Macro &macro,
- const Token &identifier,
- std::vector<MacroArg> *args,
- SourceLocation *closingParenthesisLocation);
- void replaceMacroParams(const Macro &macro,
- const std::vector<MacroArg> &args,
- std::vector<Token> *replacements);
-
- struct MacroContext
- {
- MacroContext();
- ~MacroContext();
- bool empty() const;
- const Token &get();
- void unget();
-
- std::shared_ptr<Macro> macro;
- std::size_t index;
- std::vector<Token> replacements;
- };
-
- Lexer *mLexer;
- MacroSet *mMacroSet;
- Diagnostics *mDiagnostics;
-
- std::unique_ptr<Token> mReserveToken;
- std::vector<MacroContext *> mContextStack;
- size_t mTotalTokensInContexts;
-
- int mAllowedMacroExpansionDepth;
-
- bool mDeferReenablingMacros;
- std::vector<std::shared_ptr<Macro>> mMacrosToReenable;
-
- class ScopedMacroReenabler;
-};
-
-} // namespace pp
-
-#endif // COMPILER_PREPROCESSOR_MACROEXPANDER_H_
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp b/src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp
deleted file mode 100644
index 349c7b06c7..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-//
-// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/preprocessor/Preprocessor.h"
-
-#include "common/debug.h"
-#include "compiler/preprocessor/DiagnosticsBase.h"
-#include "compiler/preprocessor/DirectiveParser.h"
-#include "compiler/preprocessor/Macro.h"
-#include "compiler/preprocessor/MacroExpander.h"
-#include "compiler/preprocessor/Token.h"
-#include "compiler/preprocessor/Tokenizer.h"
-
-namespace pp
-{
-
-struct PreprocessorImpl
-{
- Diagnostics *diagnostics;
- MacroSet macroSet;
- Tokenizer tokenizer;
- DirectiveParser directiveParser;
- MacroExpander macroExpander;
-
- PreprocessorImpl(Diagnostics *diag,
- DirectiveHandler *directiveHandler,
- const PreprocessorSettings &settings)
- : diagnostics(diag),
- tokenizer(diag),
- directiveParser(&tokenizer,
- &macroSet,
- diag,
- directiveHandler,
- settings.maxMacroExpansionDepth),
- macroExpander(&directiveParser, &macroSet, diag, settings.maxMacroExpansionDepth)
- {
- }
-};
-
-Preprocessor::Preprocessor(Diagnostics *diagnostics,
- DirectiveHandler *directiveHandler,
- const PreprocessorSettings &settings)
-{
- mImpl = new PreprocessorImpl(diagnostics, directiveHandler, settings);
-}
-
-Preprocessor::~Preprocessor()
-{
- delete mImpl;
-}
-
-bool Preprocessor::init(size_t count, const char *const string[], const int length[])
-{
- static const int kDefaultGLSLVersion = 100;
-
- // Add standard pre-defined macros.
- predefineMacro("__LINE__", 0);
- predefineMacro("__FILE__", 0);
- predefineMacro("__VERSION__", kDefaultGLSLVersion);
- predefineMacro("GL_ES", 1);
-
- return mImpl->tokenizer.init(count, string, length);
-}
-
-void Preprocessor::predefineMacro(const char *name, int value)
-{
- PredefineMacro(&mImpl->macroSet, name, value);
-}
-
-void Preprocessor::lex(Token *token)
-{
- bool validToken = false;
- while (!validToken)
- {
- mImpl->macroExpander.lex(token);
- switch (token->type)
- {
- // We should not be returning internal preprocessing tokens.
- // Convert preprocessing tokens to compiler tokens or report
- // diagnostics.
- case Token::PP_HASH:
- UNREACHABLE();
- break;
- case Token::PP_NUMBER:
- mImpl->diagnostics->report(Diagnostics::PP_INVALID_NUMBER, token->location,
- token->text);
- break;
- case Token::PP_OTHER:
- mImpl->diagnostics->report(Diagnostics::PP_INVALID_CHARACTER, token->location,
- token->text);
- break;
- default:
- validToken = true;
- break;
- }
- }
-}
-
-void Preprocessor::setMaxTokenSize(size_t maxTokenSize)
-{
- mImpl->tokenizer.setMaxTokenSize(maxTokenSize);
-}
-
-} // namespace pp
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.h b/src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.h
deleted file mode 100644
index 2fe504f7f9..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.h
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_PREPROCESSOR_PREPROCESSOR_H_
-#define COMPILER_PREPROCESSOR_PREPROCESSOR_H_
-
-#include <cstddef>
-
-#include "common/angleutils.h"
-
-namespace pp
-{
-
-class Diagnostics;
-class DirectiveHandler;
-struct PreprocessorImpl;
-struct Token;
-
-struct PreprocessorSettings : private angle::NonCopyable
-{
- PreprocessorSettings() : maxMacroExpansionDepth(1000) {}
- int maxMacroExpansionDepth;
-};
-
-class Preprocessor : angle::NonCopyable
-{
- public:
- Preprocessor(Diagnostics *diagnostics,
- DirectiveHandler *directiveHandler,
- const PreprocessorSettings &settings);
- ~Preprocessor();
-
- // count: specifies the number of elements in the string and length arrays.
- // string: specifies an array of pointers to strings.
- // length: specifies an array of string lengths.
- // If length is NULL, each string is assumed to be null terminated.
- // If length is a value other than NULL, it points to an array containing
- // a string length for each of the corresponding elements of string.
- // Each element in the length array may contain the length of the
- // corresponding string or a value less than 0 to indicate that the string
- // is null terminated.
- bool init(size_t count, const char *const string[], const int length[]);
- // Adds a pre-defined macro.
- void predefineMacro(const char *name, int value);
-
- void lex(Token *token);
-
- // Set maximum preprocessor token size
- void setMaxTokenSize(size_t maxTokenSize);
-
- private:
- PreprocessorImpl *mImpl;
-};
-
-} // namespace pp
-
-#endif // COMPILER_PREPROCESSOR_PREPROCESSOR_H_
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/SourceLocation.h b/src/3rdparty/angle/src/compiler/preprocessor/SourceLocation.h
deleted file mode 100644
index 51908a3b4b..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/SourceLocation.h
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_PREPROCESSOR_SOURCELOCATION_H_
-#define COMPILER_PREPROCESSOR_SOURCELOCATION_H_
-
-namespace pp
-{
-
-struct SourceLocation
-{
- SourceLocation() : file(0), line(0) {}
- SourceLocation(int f, int l) : file(f), line(l) {}
-
- bool equals(const SourceLocation &other) const
- {
- return (file == other.file) && (line == other.line);
- }
-
- int file;
- int line;
-};
-
-inline bool operator==(const SourceLocation &lhs, const SourceLocation &rhs)
-{
- return lhs.equals(rhs);
-}
-
-inline bool operator!=(const SourceLocation &lhs, const SourceLocation &rhs)
-{
- return !lhs.equals(rhs);
-}
-
-} // namespace pp
-
-#endif // COMPILER_PREPROCESSOR_SOURCELOCATION_H_
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Token.cpp b/src/3rdparty/angle/src/compiler/preprocessor/Token.cpp
deleted file mode 100644
index ce0ce94f49..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/Token.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-//
-// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/preprocessor/Token.h"
-
-#include "common/debug.h"
-#include "compiler/preprocessor/numeric_lex.h"
-
-namespace pp
-{
-
-void Token::reset()
-{
- type = 0;
- flags = 0;
- location = SourceLocation();
- text.clear();
-}
-
-bool Token::equals(const Token &other) const
-{
- return (type == other.type) && (flags == other.flags) && (location == other.location) &&
- (text == other.text);
-}
-
-void Token::setAtStartOfLine(bool start)
-{
- if (start)
- flags |= AT_START_OF_LINE;
- else
- flags &= ~AT_START_OF_LINE;
-}
-
-void Token::setHasLeadingSpace(bool space)
-{
- if (space)
- flags |= HAS_LEADING_SPACE;
- else
- flags &= ~HAS_LEADING_SPACE;
-}
-
-void Token::setExpansionDisabled(bool disable)
-{
- if (disable)
- flags |= EXPANSION_DISABLED;
- else
- flags &= ~EXPANSION_DISABLED;
-}
-
-bool Token::iValue(int *value) const
-{
- ASSERT(type == CONST_INT);
- return numeric_lex_int(text, value);
-}
-
-bool Token::uValue(unsigned int *value) const
-{
- ASSERT(type == CONST_INT);
- return numeric_lex_int(text, value);
-}
-
-bool Token::fValue(float *value) const
-{
- ASSERT(type == CONST_FLOAT);
- return numeric_lex_float(text, value);
-}
-
-std::ostream &operator<<(std::ostream &out, const Token &token)
-{
- if (token.hasLeadingSpace())
- out << " ";
-
- out << token.text;
- return out;
-}
-
-} // namespace pp
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Token.h b/src/3rdparty/angle/src/compiler/preprocessor/Token.h
deleted file mode 100644
index 26732ab64d..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/Token.h
+++ /dev/null
@@ -1,109 +0,0 @@
-//
-// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_PREPROCESSOR_TOKEN_H_
-#define COMPILER_PREPROCESSOR_TOKEN_H_
-
-#include <ostream>
-#include <string>
-
-#include "compiler/preprocessor/SourceLocation.h"
-
-namespace pp
-{
-
-struct Token
-{
- enum Type
- {
- // Calling this ERROR causes a conflict with wingdi.h
- GOT_ERROR = -1,
- LAST = 0, // EOF.
-
- IDENTIFIER = 258,
-
- CONST_INT,
- CONST_FLOAT,
-
- OP_INC,
- OP_DEC,
- OP_LEFT,
- OP_RIGHT,
- OP_LE,
- OP_GE,
- OP_EQ,
- OP_NE,
- OP_AND,
- OP_XOR,
- OP_OR,
- OP_ADD_ASSIGN,
- OP_SUB_ASSIGN,
- OP_MUL_ASSIGN,
- OP_DIV_ASSIGN,
- OP_MOD_ASSIGN,
- OP_LEFT_ASSIGN,
- OP_RIGHT_ASSIGN,
- OP_AND_ASSIGN,
- OP_XOR_ASSIGN,
- OP_OR_ASSIGN,
-
- // Preprocessing token types.
- // These types are used by the preprocessor internally.
- // Preprocessor clients must not depend or check for them.
- PP_HASH,
- PP_NUMBER,
- PP_OTHER
- };
- enum Flags
- {
- AT_START_OF_LINE = 1 << 0,
- HAS_LEADING_SPACE = 1 << 1,
- EXPANSION_DISABLED = 1 << 2
- };
-
- Token() : type(0), flags(0) {}
-
- void reset();
- bool equals(const Token &other) const;
-
- // Returns true if this is the first token on line.
- // It disregards any leading whitespace.
- bool atStartOfLine() const { return (flags & AT_START_OF_LINE) != 0; }
- void setAtStartOfLine(bool start);
-
- bool hasLeadingSpace() const { return (flags & HAS_LEADING_SPACE) != 0; }
- void setHasLeadingSpace(bool space);
-
- bool expansionDisabled() const { return (flags & EXPANSION_DISABLED) != 0; }
- void setExpansionDisabled(bool disable);
-
- // Converts text into numeric value for CONST_INT and CONST_FLOAT token.
- // Returns false if the parsed value cannot fit into an int or float.
- bool iValue(int *value) const;
- bool uValue(unsigned int *value) const;
- bool fValue(float *value) const;
-
- int type;
- unsigned int flags;
- SourceLocation location;
- std::string text;
-};
-
-inline bool operator==(const Token &lhs, const Token &rhs)
-{
- return lhs.equals(rhs);
-}
-
-inline bool operator!=(const Token &lhs, const Token &rhs)
-{
- return !lhs.equals(rhs);
-}
-
-std::ostream &operator<<(std::ostream &out, const Token &token);
-
-} // namepsace pp
-
-#endif // COMPILER_PREPROCESSOR_TOKEN_H_
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Tokenizer.h b/src/3rdparty/angle/src/compiler/preprocessor/Tokenizer.h
deleted file mode 100644
index af4fd7ce7b..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/Tokenizer.h
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_PREPROCESSOR_TOKENIZER_H_
-#define COMPILER_PREPROCESSOR_TOKENIZER_H_
-
-#include "common/angleutils.h"
-#include "compiler/preprocessor/Input.h"
-#include "compiler/preprocessor/Lexer.h"
-
-namespace pp
-{
-
-class Diagnostics;
-
-class Tokenizer : public Lexer
-{
- public:
- struct Context
- {
- Diagnostics *diagnostics;
-
- Input input;
- // The location where yytext points to. Token location should track
- // scanLoc instead of Input::mReadLoc because they may not be the same
- // if text is buffered up in the scanner input buffer.
- Input::Location scanLoc;
-
- bool leadingSpace;
- bool lineStart;
- };
-
- Tokenizer(Diagnostics *diagnostics);
- ~Tokenizer() override;
-
- bool init(size_t count, const char *const string[], const int length[]);
-
- void setFileNumber(int file);
- void setLineNumber(int line);
- void setMaxTokenSize(size_t maxTokenSize);
-
- void lex(Token *token) override;
-
- private:
- bool initScanner();
- void destroyScanner();
-
- void *mHandle; // Scanner handle.
- Context mContext; // Scanner extra.
- size_t mMaxTokenSize; // Maximum token size
-};
-
-} // namespace pp
-
-#endif // COMPILER_PREPROCESSOR_TOKENIZER_H_
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Tokenizer.l b/src/3rdparty/angle/src/compiler/preprocessor/Tokenizer.l
deleted file mode 100644
index 096812d45f..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/Tokenizer.l
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
-//
-// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-This file contains the Lex specification for GLSL ES preprocessor.
-Based on Microsoft Visual Studio 2010 Preprocessor Grammar:
-http://msdn.microsoft.com/en-us/library/2scxys89.aspx
-
-IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh.
-*/
-
-%top{
-//
-// Copyright (c) 2011-2014 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// This file is auto-generated by generate_parser.sh. DO NOT EDIT!
-}
-
-%{
-#if defined(_MSC_VER)
-#pragma warning(disable: 4005)
-#endif
-
-#include "compiler/preprocessor/Tokenizer.h"
-
-#include "compiler/preprocessor/DiagnosticsBase.h"
-#include "compiler/preprocessor/Token.h"
-
-#if defined(__GNUC__)
-// Triggered by the auto-generated yy_fatal_error function.
-#pragma GCC diagnostic ignored "-Wmissing-noreturn"
-#elif defined(_MSC_VER)
-#pragma warning(disable: 4244)
-#endif
-
-// Workaround for flex using the register keyword, deprecated in C++11.
-#ifdef __cplusplus
-#if __cplusplus > 199711L
-#define register
-#endif
-#endif
-
-typedef std::string YYSTYPE;
-typedef pp::SourceLocation YYLTYPE;
-
-// Use the unused yycolumn variable to track file (string) number.
-#define yyfileno yycolumn
-
-#define YY_USER_INIT \
- do { \
- yyfileno = 0; \
- yylineno = 1; \
- yyextra->leadingSpace = false; \
- yyextra->lineStart = true; \
- } while(0);
-
-#define YY_USER_ACTION \
- do \
- { \
- pp::Input* input = &yyextra->input; \
- pp::Input::Location* scanLoc = &yyextra->scanLoc; \
- while ((scanLoc->sIndex < input->count()) && \
- (scanLoc->cIndex >= input->length(scanLoc->sIndex))) \
- { \
- scanLoc->cIndex -= input->length(scanLoc->sIndex++); \
- ++yyfileno; yylineno = 1; \
- } \
- yylloc->file = yyfileno; \
- yylloc->line = yylineno; \
- scanLoc->cIndex += yyleng; \
- } while(0);
-
-#define YY_INPUT(buf, result, maxSize) \
- result = yyextra->input.read(buf, maxSize, &yylineno);
-
-%}
-
-%option noyywrap nounput never-interactive
-%option reentrant bison-bridge bison-locations
-%option prefix="pp"
-%option extra-type="pp::Tokenizer::Context*"
-%x COMMENT
-
-NEWLINE \n|\r|\r\n
-IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]*
-PUNCTUATOR [][<>(){}.+-/*%^|&~=!:;,?]
-
-DECIMAL_CONSTANT [1-9][0-9]*[uU]?
-OCTAL_CONSTANT 0[0-7]*[uU]?
-HEXADECIMAL_CONSTANT 0[xX][0-9a-fA-F]+[uU]?
-
-DIGIT [0-9]
-EXPONENT_PART [eE][+-]?{DIGIT}+
-FRACTIONAL_CONSTANT ({DIGIT}*"."{DIGIT}+)|({DIGIT}+".")
-
-%%
-
- /* Line comment */
-"//"[^\r\n]*
-
- /* Block comment */
- /* Line breaks are just counted - not returned. */
- /* The comment is replaced by a single space. */
-"/*" { BEGIN(COMMENT); }
-<COMMENT>[^*\r\n]+
-<COMMENT>"*"
-<COMMENT>{NEWLINE} {
- if (yylineno == INT_MAX)
- {
- *yylval = "Integer overflow on line number";
- return pp::Token::GOT_ERROR;
- }
- ++yylineno;
-}
-<COMMENT>"*/" {
- yyextra->leadingSpace = true;
- BEGIN(INITIAL);
-}
-
-# {
- // # is only valid at start of line for preprocessor directives.
- yylval->assign(1, yytext[0]);
- return yyextra->lineStart ? pp::Token::PP_HASH : pp::Token::PP_OTHER;
-}
-
-{IDENTIFIER} {
- yylval->assign(yytext, yyleng);
- return pp::Token::IDENTIFIER;
-}
-
-({DECIMAL_CONSTANT}[uU]?)|({OCTAL_CONSTANT}[uU]?)|({HEXADECIMAL_CONSTANT}[uU]?) {
- yylval->assign(yytext, yyleng);
- return pp::Token::CONST_INT;
-}
-
-({DIGIT}+{EXPONENT_PART}[fF]?)|({FRACTIONAL_CONSTANT}{EXPONENT_PART}?[fF]?) {
- yylval->assign(yytext, yyleng);
- return pp::Token::CONST_FLOAT;
-}
-
- /* Anything that starts with a {DIGIT} or .{DIGIT} must be a number. */
- /* Rule to catch all invalid integers and floats. */
-({DIGIT}+[_a-zA-Z0-9.]*)|("."{DIGIT}+[_a-zA-Z0-9.]*) {
- yylval->assign(yytext, yyleng);
- return pp::Token::PP_NUMBER;
-}
-
-"++" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_INC;
-}
-"--" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_DEC;
-}
-"<<" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_LEFT;
-}
-">>" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_RIGHT;
-}
-"<=" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_LE;
-}
-">=" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_GE;
-}
-"==" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_EQ;
-}
-"!=" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_NE;
-}
-"&&" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_AND;
-}
-"^^" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_XOR;
-}
-"||" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_OR;
-}
-"+=" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_ADD_ASSIGN;
-}
-"-=" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_SUB_ASSIGN;
-}
-"*=" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_MUL_ASSIGN;
-}
-"/=" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_DIV_ASSIGN;
-}
-"%=" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_MOD_ASSIGN;
-}
-"<<=" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_LEFT_ASSIGN;
-}
-">>=" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_RIGHT_ASSIGN;
-}
-"&=" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_AND_ASSIGN;
-}
-"^=" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_XOR_ASSIGN;
-}
-"|=" {
- yylval->assign(yytext, yyleng);
- return pp::Token::OP_OR_ASSIGN;
-}
-
-{PUNCTUATOR} {
- yylval->assign(1, yytext[0]);
- return yytext[0];
-}
-
-[ \t\v\f]+ { yyextra->leadingSpace = true; }
-
-{NEWLINE} {
- if (yylineno == INT_MAX)
- {
- *yylval = "Integer overflow on line number";
- return pp::Token::GOT_ERROR;
- }
- ++yylineno;
- yylval->assign(1, '\n');
- return '\n';
-}
-
-. {
- yylval->assign(1, yytext[0]);
- return pp::Token::PP_OTHER;
-}
-
-<*><<EOF>> {
- // YY_USER_ACTION is not invoked for handling EOF.
- // Set the location for EOF token manually.
- pp::Input* input = &yyextra->input;
- pp::Input::Location* scanLoc = &yyextra->scanLoc;
- yy_size_t sIndexMax = input->count() ? input->count() - 1 : 0;
- if (scanLoc->sIndex != sIndexMax)
- {
- // We can only reach here if there are empty strings at the
- // end of the input.
- scanLoc->sIndex = sIndexMax; scanLoc->cIndex = 0;
- // FIXME: this is not 64-bit clean.
- yyfileno = static_cast<int>(sIndexMax); yylineno = 1;
- }
- yylloc->file = yyfileno;
- yylloc->line = yylineno;
- yylval->clear();
-
- // Line number overflows fake EOFs to exit early, check for this case.
- if (yylineno == INT_MAX) {
- yyextra->diagnostics->report(pp::Diagnostics::PP_TOKENIZER_ERROR,
- pp::SourceLocation(yyfileno, yylineno),
- "Integer overflow on line number");
- }
- else if (YY_START == COMMENT)
- {
- yyextra->diagnostics->report(pp::Diagnostics::PP_EOF_IN_COMMENT,
- pp::SourceLocation(yyfileno, yylineno),
- "EOF while in a comment");
- }
- yyterminate();
-}
-
-%%
-
-namespace pp {
-
-Tokenizer::Tokenizer(Diagnostics *diagnostics) : mHandle(nullptr), mMaxTokenSize(256)
-{
- mContext.diagnostics = diagnostics;
-}
-
-Tokenizer::~Tokenizer()
-{
- destroyScanner();
-}
-
-bool Tokenizer::init(size_t count, const char * const string[], const int length[])
-{
- if ((count > 0) && (string == 0))
- return false;
-
- mContext.input = Input(count, string, length);
- return initScanner();
-}
-
-void Tokenizer::setFileNumber(int file)
-{
- // We use column number as file number.
- // See macro yyfileno.
- yyset_column(file, mHandle);
-}
-
-void Tokenizer::setLineNumber(int line)
-{
- yyset_lineno(line, mHandle);
-}
-
-void Tokenizer::setMaxTokenSize(size_t maxTokenSize)
-{
- mMaxTokenSize = maxTokenSize;
-}
-
-void Tokenizer::lex(Token *token)
-{
- int tokenType = yylex(&token->text, &token->location, mHandle);
-
- if (tokenType == Token::GOT_ERROR)
- {
- mContext.diagnostics->report(Diagnostics::PP_TOKENIZER_ERROR, token->location, token->text);
- token->type = Token::LAST;
- }
- else
- {
- token->type = tokenType;
- }
-
- if (token->text.size() > mMaxTokenSize)
- {
- mContext.diagnostics->report(Diagnostics::PP_TOKEN_TOO_LONG,
- token->location, token->text);
- token->text.erase(mMaxTokenSize);
- }
-
- token->flags = 0;
-
- token->setAtStartOfLine(mContext.lineStart);
- mContext.lineStart = token->type == '\n';
-
- token->setHasLeadingSpace(mContext.leadingSpace);
- mContext.leadingSpace = false;
-}
-
-bool Tokenizer::initScanner()
-{
- if ((mHandle == nullptr) && yylex_init_extra(&mContext, &mHandle))
- return false;
-
- yyrestart(0, mHandle);
- return true;
-}
-
-void Tokenizer::destroyScanner()
-{
- if (mHandle == nullptr)
- return;
-
- yylex_destroy(mHandle);
- mHandle = nullptr;
-}
-
-} // namespace pp
-
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/numeric_lex.h b/src/3rdparty/angle/src/compiler/preprocessor/numeric_lex.h
deleted file mode 100644
index 6ea779ab8f..0000000000
--- a/src/3rdparty/angle/src/compiler/preprocessor/numeric_lex.h
+++ /dev/null
@@ -1,72 +0,0 @@
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// numeric_lex.h: Functions to extract numeric values from string.
-
-#ifndef COMPILER_PREPROCESSOR_NUMERICLEX_H_
-#define COMPILER_PREPROCESSOR_NUMERICLEX_H_
-
-#include <cmath>
-#include <sstream>
-
-namespace pp
-{
-
-inline std::ios::fmtflags numeric_base_int(const std::string &str)
-{
- if ((str.size() >= 2) && (str[0] == '0') && (str[1] == 'x' || str[1] == 'X'))
- {
- return std::ios::hex;
- }
- if ((str.size() >= 1) && (str[0] == '0'))
- {
- return std::ios::oct;
- }
- return std::ios::dec;
-}
-
-// The following functions parse the given string to extract a numerical
-// value of the given type. These functions assume that the string is
-// of the correct form. They can only fail if the parsed value is too big,
-// in which case false is returned.
-
-template <typename IntType>
-bool numeric_lex_int(const std::string &str, IntType *value)
-{
- std::istringstream stream(str);
- // This should not be necessary, but MSVS has a buggy implementation.
- // It returns incorrect results if the base is not specified.
- stream.setf(numeric_base_int(str), std::ios::basefield);
-
- stream >> (*value);
- return !stream.fail();
-}
-
-template <typename FloatType>
-bool numeric_lex_float(const std::string &str, FloatType *value)
-{
-// On 64-bit Intel Android, istringstream is broken. Until this is fixed in
-// a newer NDK, don't use it. Android doesn't have locale support, so this
-// doesn't have to force the C locale.
-// TODO(thakis): Remove this once this bug has been fixed in the NDK and
-// that NDK has been rolled into chromium.
-#if defined(ANGLE_PLATFORM_ANDROID) && __x86_64__
- *value = strtod(str.c_str(), nullptr);
- return errno != ERANGE;
-#else
- std::istringstream stream(str);
- // Force "C" locale so that decimal character is always '.', and
- // not dependent on the current locale.
- stream.imbue(std::locale::classic());
-
- stream >> (*value);
- return !stream.fail() && std::isfinite(*value);
-#endif
-}
-
-} // namespace pp.
-
-#endif // COMPILER_PREPROCESSOR_NUMERICLEX_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/ASTMetadataHLSL.cpp b/src/3rdparty/angle/src/compiler/translator/ASTMetadataHLSL.cpp
deleted file mode 100644
index b04fc28259..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ASTMetadataHLSL.cpp
+++ /dev/null
@@ -1,462 +0,0 @@
-//
-// Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// Analysis of the AST needed for HLSL generation
-
-#include "compiler/translator/ASTMetadataHLSL.h"
-
-#include "compiler/translator/CallDAG.h"
-#include "compiler/translator/IntermTraverse.h"
-#include "compiler/translator/SymbolTable.h"
-
-namespace sh
-{
-
-namespace
-{
-
-// Class used to traverse the AST of a function definition, checking if the
-// function uses a gradient, and writing the set of control flow using gradients.
-// It assumes that the analysis has already been made for the function's
-// callees.
-class PullGradient : public TIntermTraverser
-{
- public:
- PullGradient(MetadataList *metadataList, size_t index, const CallDAG &dag)
- : TIntermTraverser(true, false, true),
- mMetadataList(metadataList),
- mMetadata(&(*metadataList)[index]),
- mIndex(index),
- mDag(dag)
- {
- ASSERT(index < metadataList->size());
-
- // ESSL 100 builtin gradient functions
- mGradientBuiltinFunctions.insert("texture2D");
- mGradientBuiltinFunctions.insert("texture2DProj");
- mGradientBuiltinFunctions.insert("textureCube");
-
- // ESSL 300 builtin gradient functions
- mGradientBuiltinFunctions.insert("texture");
- mGradientBuiltinFunctions.insert("textureProj");
- mGradientBuiltinFunctions.insert("textureOffset");
- mGradientBuiltinFunctions.insert("textureProjOffset");
-
- // ESSL 310 doesn't add builtin gradient functions
- }
-
- void traverse(TIntermFunctionDefinition *node)
- {
- node->traverse(this);
- ASSERT(mParents.empty());
- }
-
- // Called when a gradient operation or a call to a function using a gradient is found.
- void onGradient()
- {
- mMetadata->mUsesGradient = true;
- // Mark the latest control flow as using a gradient.
- if (!mParents.empty())
- {
- mMetadata->mControlFlowsContainingGradient.insert(mParents.back());
- }
- }
-
- void visitControlFlow(Visit visit, TIntermNode *node)
- {
- if (visit == PreVisit)
- {
- mParents.push_back(node);
- }
- else if (visit == PostVisit)
- {
- ASSERT(mParents.back() == node);
- mParents.pop_back();
- // A control flow's using a gradient means its parents are too.
- if (mMetadata->mControlFlowsContainingGradient.count(node) > 0 && !mParents.empty())
- {
- mMetadata->mControlFlowsContainingGradient.insert(mParents.back());
- }
- }
- }
-
- bool visitLoop(Visit visit, TIntermLoop *loop) override
- {
- visitControlFlow(visit, loop);
- return true;
- }
-
- bool visitIfElse(Visit visit, TIntermIfElse *ifElse) override
- {
- visitControlFlow(visit, ifElse);
- return true;
- }
-
- bool visitUnary(Visit visit, TIntermUnary *node) override
- {
- if (visit == PreVisit)
- {
- switch (node->getOp())
- {
- case EOpDFdx:
- case EOpDFdy:
- case EOpFwidth:
- onGradient();
- default:
- break;
- }
- }
-
- return true;
- }
-
- bool visitAggregate(Visit visit, TIntermAggregate *node) override
- {
- if (visit == PreVisit)
- {
- if (node->getOp() == EOpCallFunctionInAST)
- {
- size_t calleeIndex = mDag.findIndex(node->getFunctionSymbolInfo());
- ASSERT(calleeIndex != CallDAG::InvalidIndex && calleeIndex < mIndex);
-
- if ((*mMetadataList)[calleeIndex].mUsesGradient)
- {
- onGradient();
- }
- }
- else if (node->getOp() == EOpCallBuiltInFunction)
- {
- if (mGradientBuiltinFunctions.find(node->getFunctionSymbolInfo()->getName()) !=
- mGradientBuiltinFunctions.end())
- {
- onGradient();
- }
- }
- }
-
- return true;
- }
-
- private:
- MetadataList *mMetadataList;
- ASTMetadataHLSL *mMetadata;
- size_t mIndex;
- const CallDAG &mDag;
-
- // Contains a stack of the control flow nodes that are parents of the node being
- // currently visited. It is used to mark control flows using a gradient.
- std::vector<TIntermNode *> mParents;
-
- // A list of builtin functions that use gradients
- std::set<TString> mGradientBuiltinFunctions;
-};
-
-// Traverses the AST of a function definition to compute the the discontinuous loops
-// and the if statements containing gradient loops. It assumes that the gradient loops
-// (loops that contain a gradient) have already been computed and that it has already
-// traversed the current function's callees.
-class PullComputeDiscontinuousAndGradientLoops : public TIntermTraverser
-{
- public:
- PullComputeDiscontinuousAndGradientLoops(MetadataList *metadataList,
- size_t index,
- const CallDAG &dag)
- : TIntermTraverser(true, false, true),
- mMetadataList(metadataList),
- mMetadata(&(*metadataList)[index]),
- mIndex(index),
- mDag(dag)
- {
- }
-
- void traverse(TIntermFunctionDefinition *node)
- {
- node->traverse(this);
- ASSERT(mLoopsAndSwitches.empty());
- ASSERT(mIfs.empty());
- }
-
- // Called when traversing a gradient loop or a call to a function with a
- // gradient loop in its call graph.
- void onGradientLoop()
- {
- mMetadata->mHasGradientLoopInCallGraph = true;
- // Mark the latest if as using a discontinuous loop.
- if (!mIfs.empty())
- {
- mMetadata->mIfsContainingGradientLoop.insert(mIfs.back());
- }
- }
-
- bool visitLoop(Visit visit, TIntermLoop *loop) override
- {
- if (visit == PreVisit)
- {
- mLoopsAndSwitches.push_back(loop);
-
- if (mMetadata->hasGradientInCallGraph(loop))
- {
- onGradientLoop();
- }
- }
- else if (visit == PostVisit)
- {
- ASSERT(mLoopsAndSwitches.back() == loop);
- mLoopsAndSwitches.pop_back();
- }
-
- return true;
- }
-
- bool visitIfElse(Visit visit, TIntermIfElse *node) override
- {
- if (visit == PreVisit)
- {
- mIfs.push_back(node);
- }
- else if (visit == PostVisit)
- {
- ASSERT(mIfs.back() == node);
- mIfs.pop_back();
- // An if using a discontinuous loop means its parents ifs are also discontinuous.
- if (mMetadata->mIfsContainingGradientLoop.count(node) > 0 && !mIfs.empty())
- {
- mMetadata->mIfsContainingGradientLoop.insert(mIfs.back());
- }
- }
-
- return true;
- }
-
- bool visitBranch(Visit visit, TIntermBranch *node) override
- {
- if (visit == PreVisit)
- {
- switch (node->getFlowOp())
- {
- case EOpBreak:
- {
- ASSERT(!mLoopsAndSwitches.empty());
- TIntermLoop *loop = mLoopsAndSwitches.back()->getAsLoopNode();
- if (loop != nullptr)
- {
- mMetadata->mDiscontinuousLoops.insert(loop);
- }
- }
- break;
- case EOpContinue:
- {
- ASSERT(!mLoopsAndSwitches.empty());
- TIntermLoop *loop = nullptr;
- size_t i = mLoopsAndSwitches.size();
- while (loop == nullptr && i > 0)
- {
- --i;
- loop = mLoopsAndSwitches.at(i)->getAsLoopNode();
- }
- ASSERT(loop != nullptr);
- mMetadata->mDiscontinuousLoops.insert(loop);
- }
- break;
- case EOpKill:
- case EOpReturn:
- // A return or discard jumps out of all the enclosing loops
- if (!mLoopsAndSwitches.empty())
- {
- for (TIntermNode *intermNode : mLoopsAndSwitches)
- {
- TIntermLoop *loop = intermNode->getAsLoopNode();
- if (loop)
- {
- mMetadata->mDiscontinuousLoops.insert(loop);
- }
- }
- }
- break;
- default:
- UNREACHABLE();
- }
- }
-
- return true;
- }
-
- bool visitAggregate(Visit visit, TIntermAggregate *node) override
- {
- if (visit == PreVisit && node->getOp() == EOpCallFunctionInAST)
- {
- size_t calleeIndex = mDag.findIndex(node->getFunctionSymbolInfo());
- ASSERT(calleeIndex != CallDAG::InvalidIndex && calleeIndex < mIndex);
-
- if ((*mMetadataList)[calleeIndex].mHasGradientLoopInCallGraph)
- {
- onGradientLoop();
- }
- }
-
- return true;
- }
-
- bool visitSwitch(Visit visit, TIntermSwitch *node) override
- {
- if (visit == PreVisit)
- {
- mLoopsAndSwitches.push_back(node);
- }
- else if (visit == PostVisit)
- {
- ASSERT(mLoopsAndSwitches.back() == node);
- mLoopsAndSwitches.pop_back();
- }
- return true;
- }
-
- private:
- MetadataList *mMetadataList;
- ASTMetadataHLSL *mMetadata;
- size_t mIndex;
- const CallDAG &mDag;
-
- std::vector<TIntermNode *> mLoopsAndSwitches;
- std::vector<TIntermIfElse *> mIfs;
-};
-
-// Tags all the functions called in a discontinuous loop
-class PushDiscontinuousLoops : public TIntermTraverser
-{
- public:
- PushDiscontinuousLoops(MetadataList *metadataList, size_t index, const CallDAG &dag)
- : TIntermTraverser(true, true, true),
- mMetadataList(metadataList),
- mMetadata(&(*metadataList)[index]),
- mIndex(index),
- mDag(dag),
- mNestedDiscont(mMetadata->mCalledInDiscontinuousLoop ? 1 : 0)
- {
- }
-
- void traverse(TIntermFunctionDefinition *node)
- {
- node->traverse(this);
- ASSERT(mNestedDiscont == (mMetadata->mCalledInDiscontinuousLoop ? 1 : 0));
- }
-
- bool visitLoop(Visit visit, TIntermLoop *loop) override
- {
- bool isDiscontinuous = mMetadata->mDiscontinuousLoops.count(loop) > 0;
-
- if (visit == PreVisit && isDiscontinuous)
- {
- mNestedDiscont++;
- }
- else if (visit == PostVisit && isDiscontinuous)
- {
- mNestedDiscont--;
- }
-
- return true;
- }
-
- bool visitAggregate(Visit visit, TIntermAggregate *node) override
- {
- switch (node->getOp())
- {
- case EOpCallFunctionInAST:
- if (visit == PreVisit && mNestedDiscont > 0)
- {
- size_t calleeIndex = mDag.findIndex(node->getFunctionSymbolInfo());
- ASSERT(calleeIndex != CallDAG::InvalidIndex && calleeIndex < mIndex);
-
- (*mMetadataList)[calleeIndex].mCalledInDiscontinuousLoop = true;
- }
- break;
- default:
- break;
- }
- return true;
- }
-
- private:
- MetadataList *mMetadataList;
- ASTMetadataHLSL *mMetadata;
- size_t mIndex;
- const CallDAG &mDag;
-
- int mNestedDiscont;
-};
-}
-
-bool ASTMetadataHLSL::hasGradientInCallGraph(TIntermLoop *node)
-{
- return mControlFlowsContainingGradient.count(node) > 0;
-}
-
-bool ASTMetadataHLSL::hasGradientLoop(TIntermIfElse *node)
-{
- return mIfsContainingGradientLoop.count(node) > 0;
-}
-
-MetadataList CreateASTMetadataHLSL(TIntermNode *root, const CallDAG &callDag)
-{
- MetadataList metadataList(callDag.size());
-
- // Compute all the information related to when gradient operations are used.
- // We want to know for each function and control flow operation if they have
- // a gradient operation in their call graph (shortened to "using a gradient"
- // in the rest of the file).
- //
- // This computation is logically split in three steps:
- // 1 - For each function compute if it uses a gradient in its body, ignoring
- // calls to other user-defined functions.
- // 2 - For each function determine if it uses a gradient in its call graph,
- // using the result of step 1 and the CallDAG to know its callees.
- // 3 - For each control flow statement of each function, check if it uses a
- // gradient in the function's body, or if it calls a user-defined function that
- // uses a gradient.
- //
- // We take advantage of the call graph being a DAG and instead compute 1, 2 and 3
- // for leaves first, then going down the tree. This is correct because 1 doesn't
- // depend on other functions, and 2 and 3 depend only on callees.
- for (size_t i = 0; i < callDag.size(); i++)
- {
- PullGradient pull(&metadataList, i, callDag);
- pull.traverse(callDag.getRecordFromIndex(i).node);
- }
-
- // Compute which loops are discontinuous and which function are called in
- // these loops. The same way computing gradient usage is a "pull" process,
- // computing "bing used in a discont. loop" is a push process. However we also
- // need to know what ifs have a discontinuous loop inside so we do the same type
- // of callgraph analysis as for the gradient.
-
- // First compute which loops are discontinuous (no specific order) and pull
- // the ifs and functions using a gradient loop.
- for (size_t i = 0; i < callDag.size(); i++)
- {
- PullComputeDiscontinuousAndGradientLoops pull(&metadataList, i, callDag);
- pull.traverse(callDag.getRecordFromIndex(i).node);
- }
-
- // Then push the information to callees, either from the a local discontinuous
- // loop or from the caller being called in a discontinuous loop already
- for (size_t i = callDag.size(); i-- > 0;)
- {
- PushDiscontinuousLoops push(&metadataList, i, callDag);
- push.traverse(callDag.getRecordFromIndex(i).node);
- }
-
- // We create "Lod0" version of functions with the gradient operations replaced
- // by non-gradient operations so that the D3D compiler is happier with discont
- // loops.
- for (auto &metadata : metadataList)
- {
- metadata.mNeedsLod0 = metadata.mCalledInDiscontinuousLoop && metadata.mUsesGradient;
- }
-
- return metadataList;
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/ASTMetadataHLSL.h b/src/3rdparty/angle/src/compiler/translator/ASTMetadataHLSL.h
deleted file mode 100644
index 550a522b86..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ASTMetadataHLSL.h
+++ /dev/null
@@ -1,63 +0,0 @@
-//
-// Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// Defines analyses of the AST needed for HLSL generation
-
-#ifndef COMPILER_TRANSLATOR_ASTMETADATAHLSL_H_
-#define COMPILER_TRANSLATOR_ASTMETADATAHLSL_H_
-
-#include <set>
-#include <vector>
-
-namespace sh
-{
-
-class CallDAG;
-class TIntermNode;
-class TIntermIfElse;
-class TIntermLoop;
-
-struct ASTMetadataHLSL
-{
- ASTMetadataHLSL()
- : mUsesGradient(false),
- mCalledInDiscontinuousLoop(false),
- mHasGradientLoopInCallGraph(false),
- mNeedsLod0(false)
- {
- }
-
- // Here "something uses a gradient" means here that it either contains a
- // gradient operation, or a call to a function that uses a gradient.
- bool hasGradientInCallGraph(TIntermLoop *node);
- bool hasGradientLoop(TIntermIfElse *node);
-
- // Does the function use a gradient.
- bool mUsesGradient;
-
- // Even if usesGradient is true, some control flow might not use a gradient
- // so we store the set of all gradient-using control flows.
- std::set<TIntermNode *> mControlFlowsContainingGradient;
-
- // Remember information about the discontinuous loops and which functions
- // are called in such loops.
- bool mCalledInDiscontinuousLoop;
- bool mHasGradientLoopInCallGraph;
- std::set<TIntermLoop *> mDiscontinuousLoops;
- std::set<TIntermIfElse *> mIfsContainingGradientLoop;
-
- // Will we need to generate a Lod0 version of the function.
- bool mNeedsLod0;
-};
-
-typedef std::vector<ASTMetadataHLSL> MetadataList;
-
-// Return the AST analysis result, in the order defined by the call DAG
-MetadataList CreateASTMetadataHLSL(TIntermNode *root, const CallDAG &callDag);
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_ASTMETADATAHLSL_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/AddAndTrueToLoopCondition.cpp b/src/3rdparty/angle/src/compiler/translator/AddAndTrueToLoopCondition.cpp
deleted file mode 100644
index 6a05104233..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/AddAndTrueToLoopCondition.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-//
-// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/translator/AddAndTrueToLoopCondition.h"
-
-#include "compiler/translator/IntermTraverse.h"
-
-namespace sh
-{
-
-namespace
-{
-
-// An AST traverser that rewrites for and while loops by replacing "condition" with
-// "condition && true" to work around condition bug on Intel Mac.
-class AddAndTrueToLoopConditionTraverser : public TIntermTraverser
-{
- public:
- AddAndTrueToLoopConditionTraverser() : TIntermTraverser(true, false, false) {}
-
- bool visitLoop(Visit, TIntermLoop *loop) override
- {
- // do-while loop doesn't have this bug.
- if (loop->getType() != ELoopFor && loop->getType() != ELoopWhile)
- {
- return true;
- }
-
- // For loop may not have a condition.
- if (loop->getCondition() == nullptr)
- {
- return true;
- }
-
- // Constant true.
- TConstantUnion *trueConstant = new TConstantUnion();
- trueConstant->setBConst(true);
- TIntermTyped *trueValue = new TIntermConstantUnion(trueConstant, TType(EbtBool));
-
- // CONDITION && true.
- TIntermBinary *andOp = new TIntermBinary(EOpLogicalAnd, loop->getCondition(), trueValue);
- loop->setCondition(andOp);
-
- return true;
- }
-};
-
-} // anonymous namespace
-
-void AddAndTrueToLoopCondition(TIntermNode *root)
-{
- AddAndTrueToLoopConditionTraverser traverser;
- root->traverse(&traverser);
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/AddAndTrueToLoopCondition.h b/src/3rdparty/angle/src/compiler/translator/AddAndTrueToLoopCondition.h
deleted file mode 100644
index 34debe0ed9..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/AddAndTrueToLoopCondition.h
+++ /dev/null
@@ -1,20 +0,0 @@
-//
-// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// Rewrite condition in for and while loops to work around driver bug on Intel Mac.
-
-#ifndef COMPILER_TRANSLATOR_ADDANDTRUETOLOOPCONDITION_H_
-#define COMPILER_TRANSLATOR_ADDANDTRUETOLOOPCONDITION_H_
-
-class TIntermNode;
-namespace sh
-{
-
-void AddAndTrueToLoopCondition(TIntermNode *root);
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_ADDANDTRUETOLOOPCONDITION_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/AddDefaultReturnStatements.cpp b/src/3rdparty/angle/src/compiler/translator/AddDefaultReturnStatements.cpp
deleted file mode 100644
index 4dfe60c0bc..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/AddDefaultReturnStatements.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// AddDefaultReturnStatements.cpp: Add default return statements to functions that do not end in a
-// return.
-//
-
-#include "compiler/translator/AddDefaultReturnStatements.h"
-
-#include "compiler/translator/IntermNode.h"
-#include "compiler/translator/IntermNode_util.h"
-#include "compiler/translator/util.h"
-
-namespace sh
-{
-
-namespace
-{
-
-bool NeedsReturnStatement(TIntermFunctionDefinition *node, TType *returnType)
-{
- *returnType = node->getFunctionPrototype()->getType();
- if (returnType->getBasicType() == EbtVoid)
- {
- return false;
- }
-
- TIntermBlock *bodyNode = node->getBody();
- TIntermBranch *returnNode = bodyNode->getSequence()->back()->getAsBranchNode();
- if (returnNode != nullptr && returnNode->getFlowOp() == EOpReturn)
- {
- return false;
- }
-
- return true;
-}
-
-} // anonymous namespace
-
-void AddDefaultReturnStatements(TIntermBlock *root)
-{
- TType returnType;
- for (TIntermNode *node : *root->getSequence())
- {
- TIntermFunctionDefinition *definition = node->getAsFunctionDefinition();
- if (definition != nullptr && NeedsReturnStatement(definition, &returnType))
- {
- TIntermBranch *branch = new TIntermBranch(EOpReturn, CreateZeroNode(returnType));
-
- TIntermBlock *bodyNode = definition->getBody();
- bodyNode->getSequence()->push_back(branch);
- }
- }
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/AddDefaultReturnStatements.h b/src/3rdparty/angle/src/compiler/translator/AddDefaultReturnStatements.h
deleted file mode 100644
index 40a70ad8c2..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/AddDefaultReturnStatements.h
+++ /dev/null
@@ -1,22 +0,0 @@
-//
-// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// AddDefaultReturnStatements.h: Add default return statements to functions that do not end in a
-// return.
-//
-
-#ifndef COMPILER_TRANSLATOR_ADDDEFAULTRETURNSTATEMENTS_H_
-#define COMPILER_TRANSLATOR_ADDDEFAULTRETURNSTATEMENTS_H_
-
-class TIntermBlock;
-
-namespace sh
-{
-
-void AddDefaultReturnStatements(TIntermBlock *root);
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_ADDDEFAULTRETURNSTATEMENTS_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/ArrayReturnValueToOutParameter.cpp b/src/3rdparty/angle/src/compiler/translator/ArrayReturnValueToOutParameter.cpp
deleted file mode 100644
index 17721fb0dc..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ArrayReturnValueToOutParameter.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-//
-// Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// The ArrayReturnValueToOutParameter function changes return values of an array type to out
-// parameters in function definitions, prototypes, and call sites.
-
-#include "compiler/translator/ArrayReturnValueToOutParameter.h"
-
-#include <map>
-
-#include "compiler/translator/IntermTraverse.h"
-#include "compiler/translator/SymbolTable.h"
-
-namespace sh
-{
-
-namespace
-{
-
-void CopyAggregateChildren(TIntermAggregateBase *from, TIntermAggregateBase *to)
-{
- const TIntermSequence *fromSequence = from->getSequence();
- for (size_t ii = 0; ii < fromSequence->size(); ++ii)
- {
- to->getSequence()->push_back(fromSequence->at(ii));
- }
-}
-
-TIntermSymbol *CreateReturnValueSymbol(const TSymbolUniqueId &id, const TType &type)
-{
- TIntermSymbol *node = new TIntermSymbol(id, "angle_return", type);
- node->setInternal(true);
- node->getTypePointer()->setQualifier(EvqOut);
- return node;
-}
-
-TIntermAggregate *CreateReplacementCall(TIntermAggregate *originalCall,
- TIntermTyped *returnValueTarget)
-{
- TIntermSequence *replacementArguments = new TIntermSequence();
- TIntermSequence *originalArguments = originalCall->getSequence();
- for (auto &arg : *originalArguments)
- {
- replacementArguments->push_back(arg);
- }
- replacementArguments->push_back(returnValueTarget);
- TIntermAggregate *replacementCall = TIntermAggregate::CreateFunctionCall(
- TType(EbtVoid), originalCall->getFunctionSymbolInfo()->getId(),
- originalCall->getFunctionSymbolInfo()->getNameObj(), replacementArguments);
- replacementCall->setLine(originalCall->getLine());
- return replacementCall;
-}
-
-class ArrayReturnValueToOutParameterTraverser : private TIntermTraverser
-{
- public:
- static void apply(TIntermNode *root, TSymbolTable *symbolTable);
-
- private:
- ArrayReturnValueToOutParameterTraverser(TSymbolTable *symbolTable);
-
- bool visitFunctionPrototype(Visit visit, TIntermFunctionPrototype *node) override;
- bool visitFunctionDefinition(Visit visit, TIntermFunctionDefinition *node) override;
- bool visitAggregate(Visit visit, TIntermAggregate *node) override;
- bool visitBranch(Visit visit, TIntermBranch *node) override;
- bool visitBinary(Visit visit, TIntermBinary *node) override;
-
- // Set when traversal is inside a function with array return value.
- TIntermFunctionDefinition *mFunctionWithArrayReturnValue;
-
- // Map from function symbol ids to array return value ids.
- std::map<int, TSymbolUniqueId *> mReturnValueIds;
-};
-
-void ArrayReturnValueToOutParameterTraverser::apply(TIntermNode *root, TSymbolTable *symbolTable)
-{
- ArrayReturnValueToOutParameterTraverser arrayReturnValueToOutParam(symbolTable);
- root->traverse(&arrayReturnValueToOutParam);
- arrayReturnValueToOutParam.updateTree();
-}
-
-ArrayReturnValueToOutParameterTraverser::ArrayReturnValueToOutParameterTraverser(
- TSymbolTable *symbolTable)
- : TIntermTraverser(true, false, true, symbolTable), mFunctionWithArrayReturnValue(nullptr)
-{
-}
-
-bool ArrayReturnValueToOutParameterTraverser::visitFunctionDefinition(
- Visit visit,
- TIntermFunctionDefinition *node)
-{
- if (node->getFunctionPrototype()->isArray() && visit == PreVisit)
- {
- // Replacing the function header is done on visitFunctionPrototype().
- mFunctionWithArrayReturnValue = node;
- }
- if (visit == PostVisit)
- {
- mFunctionWithArrayReturnValue = nullptr;
- }
- return true;
-}
-
-bool ArrayReturnValueToOutParameterTraverser::visitFunctionPrototype(Visit visit,
- TIntermFunctionPrototype *node)
-{
- if (visit == PreVisit && node->isArray())
- {
- // Replace the whole prototype node with another node that has the out parameter
- // added. Also set the function to return void.
- TIntermFunctionPrototype *replacement =
- new TIntermFunctionPrototype(TType(EbtVoid), node->getFunctionSymbolInfo()->getId());
- CopyAggregateChildren(node, replacement);
- const TSymbolUniqueId &functionId = node->getFunctionSymbolInfo()->getId();
- if (mReturnValueIds.find(functionId.get()) == mReturnValueIds.end())
- {
- mReturnValueIds[functionId.get()] = new TSymbolUniqueId(mSymbolTable);
- }
- replacement->getSequence()->push_back(
- CreateReturnValueSymbol(*mReturnValueIds[functionId.get()], node->getType()));
- *replacement->getFunctionSymbolInfo() = *node->getFunctionSymbolInfo();
- replacement->setLine(node->getLine());
-
- queueReplacement(replacement, OriginalNode::IS_DROPPED);
- }
- return false;
-}
-
-bool ArrayReturnValueToOutParameterTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
-{
- ASSERT(!node->isArray() || node->getOp() != EOpCallInternalRawFunction);
- if (visit == PreVisit && node->isArray() && node->getOp() == EOpCallFunctionInAST)
- {
- // Handle call sites where the returned array is not assigned.
- // Examples where f() is a function returning an array:
- // 1. f();
- // 2. another_array == f();
- // 3. another_function(f());
- // 4. return f();
- // Cases 2 to 4 are already converted to simpler cases by
- // SeparateExpressionsReturningArrays, so we only need to worry about the case where a
- // function call returning an array forms an expression by itself.
- TIntermBlock *parentBlock = getParentNode()->getAsBlock();
- if (parentBlock)
- {
- nextTemporaryId();
- TIntermSequence replacements;
- replacements.push_back(createTempDeclaration(node->getType()));
- TIntermSymbol *returnSymbol = createTempSymbol(node->getType());
- replacements.push_back(CreateReplacementCall(node, returnSymbol));
- mMultiReplacements.push_back(
- NodeReplaceWithMultipleEntry(parentBlock, node, replacements));
- }
- return false;
- }
- return true;
-}
-
-bool ArrayReturnValueToOutParameterTraverser::visitBranch(Visit visit, TIntermBranch *node)
-{
- if (mFunctionWithArrayReturnValue && node->getFlowOp() == EOpReturn)
- {
- // Instead of returning a value, assign to the out parameter and then return.
- TIntermSequence replacements;
-
- TIntermTyped *expression = node->getExpression();
- ASSERT(expression != nullptr);
- const TSymbolUniqueId &functionId =
- mFunctionWithArrayReturnValue->getFunctionSymbolInfo()->getId();
- ASSERT(mReturnValueIds.find(functionId.get()) != mReturnValueIds.end());
- const TSymbolUniqueId &returnValueId = *mReturnValueIds[functionId.get()];
- TIntermSymbol *returnValueSymbol =
- CreateReturnValueSymbol(returnValueId, expression->getType());
- TIntermBinary *replacementAssignment =
- new TIntermBinary(EOpAssign, returnValueSymbol, expression);
- replacementAssignment->setLine(expression->getLine());
- replacements.push_back(replacementAssignment);
-
- TIntermBranch *replacementBranch = new TIntermBranch(EOpReturn, nullptr);
- replacementBranch->setLine(node->getLine());
- replacements.push_back(replacementBranch);
-
- mMultiReplacements.push_back(
- NodeReplaceWithMultipleEntry(getParentNode()->getAsBlock(), node, replacements));
- }
- return false;
-}
-
-bool ArrayReturnValueToOutParameterTraverser::visitBinary(Visit visit, TIntermBinary *node)
-{
- if (node->getOp() == EOpAssign && node->getLeft()->isArray())
- {
- TIntermAggregate *rightAgg = node->getRight()->getAsAggregate();
- ASSERT(rightAgg == nullptr || rightAgg->getOp() != EOpCallInternalRawFunction);
- if (rightAgg != nullptr && rightAgg->getOp() == EOpCallFunctionInAST)
- {
- TIntermAggregate *replacementCall = CreateReplacementCall(rightAgg, node->getLeft());
- queueReplacement(replacementCall, OriginalNode::IS_DROPPED);
- }
- }
- return false;
-}
-
-} // namespace
-
-void ArrayReturnValueToOutParameter(TIntermNode *root, TSymbolTable *symbolTable)
-{
- ArrayReturnValueToOutParameterTraverser::apply(root, symbolTable);
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/ArrayReturnValueToOutParameter.h b/src/3rdparty/angle/src/compiler/translator/ArrayReturnValueToOutParameter.h
deleted file mode 100644
index 469c7a3b14..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ArrayReturnValueToOutParameter.h
+++ /dev/null
@@ -1,22 +0,0 @@
-//
-// Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// The ArrayReturnValueToOutParameter function changes return values of an array type to out
-// parameters in function definitions, prototypes and call sites.
-
-#ifndef COMPILER_TRANSLATOR_ARRAYRETURNVALUETOOUTPARAMETER_H_
-#define COMPILER_TRANSLATOR_ARRAYRETURNVALUETOOUTPARAMETER_H_
-
-namespace sh
-{
-
-class TIntermNode;
-class TSymbolTable;
-
-void ArrayReturnValueToOutParameter(TIntermNode *root, TSymbolTable *symbolTable);
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_ARRAYRETURNVALUETOOUTPARAMETER_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/BaseTypes.h b/src/3rdparty/angle/src/compiler/translator/BaseTypes.h
deleted file mode 100644
index b2070f3baf..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/BaseTypes.h
+++ /dev/null
@@ -1,1073 +0,0 @@
-//
-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_TRANSLATOR_BASETYPES_H_
-#define COMPILER_TRANSLATOR_BASETYPES_H_
-
-#include <algorithm>
-#include <array>
-
-#include "common/debug.h"
-#include "GLSLANG/ShaderLang.h"
-
-namespace sh
-{
-
-//
-// Precision qualifiers
-//
-enum TPrecision
-{
- // These need to be kept sorted
- EbpUndefined,
- EbpLow,
- EbpMedium,
- EbpHigh,
-
- // end of list
- EbpLast
-};
-
-inline const char *getPrecisionString(TPrecision p)
-{
- switch (p)
- {
- case EbpHigh:
- return "highp";
- case EbpMedium:
- return "mediump";
- case EbpLow:
- return "lowp";
- default:
- return "mediump"; // Safest fallback
- }
-}
-
-//
-// Basic type. Arrays, vectors, etc., are orthogonal to this.
-//
-enum TBasicType
-{
- EbtVoid,
- EbtFloat,
- EbtInt,
- EbtUInt,
- EbtBool,
- EbtGVec4, // non type: represents vec4, ivec4, and uvec4
- EbtGenType, // non type: represents float, vec2, vec3, and vec4
- EbtGenIType, // non type: represents int, ivec2, ivec3, and ivec4
- EbtGenUType, // non type: represents uint, uvec2, uvec3, and uvec4
- EbtGenBType, // non type: represents bool, bvec2, bvec3, and bvec4
- EbtVec, // non type: represents vec2, vec3, and vec4
- EbtIVec, // non type: represents ivec2, ivec3, and ivec4
- EbtUVec, // non type: represents uvec2, uvec3, and uvec4
- EbtBVec, // non type: represents bvec2, bvec3, and bvec4
- EbtYuvCscStandardEXT, // Only valid if EXT_YUV_target exists.
- EbtGuardSamplerBegin, // non type: see implementation of IsSampler()
- EbtSampler2D,
- EbtSampler3D,
- EbtSamplerCube,
- EbtSampler2DArray,
- EbtSamplerExternalOES, // Only valid if OES_EGL_image_external exists.
- EbtSamplerExternal2DY2YEXT, // Only valid if GL_EXT_YUV_target exists.
- EbtSampler2DRect, // Only valid if GL_ARB_texture_rectangle exists.
- EbtSampler2DMS,
- EbtISampler2D,
- EbtISampler3D,
- EbtISamplerCube,
- EbtISampler2DArray,
- EbtISampler2DMS,
- EbtUSampler2D,
- EbtUSampler3D,
- EbtUSamplerCube,
- EbtUSampler2DArray,
- EbtUSampler2DMS,
- EbtSampler2DShadow,
- EbtSamplerCubeShadow,
- EbtSampler2DArrayShadow,
- EbtGuardSamplerEnd, // non type: see implementation of IsSampler()
- EbtGSampler2D, // non type: represents sampler2D, isampler2D, and usampler2D
- EbtGSampler3D, // non type: represents sampler3D, isampler3D, and usampler3D
- EbtGSamplerCube, // non type: represents samplerCube, isamplerCube, and usamplerCube
- EbtGSampler2DArray, // non type: represents sampler2DArray, isampler2DArray, and
- // usampler2DArray
- EbtGSampler2DMS, // non type: represents sampler2DMS, isampler2DMS, and usampler2DMS
-
- // images
- EbtGuardImageBegin,
- EbtImage2D,
- EbtIImage2D,
- EbtUImage2D,
- EbtImage3D,
- EbtIImage3D,
- EbtUImage3D,
- EbtImage2DArray,
- EbtIImage2DArray,
- EbtUImage2DArray,
- EbtImageCube,
- EbtIImageCube,
- EbtUImageCube,
- EbtGuardImageEnd,
-
- EbtGuardGImageBegin,
- EbtGImage2D, // non type: represents image2D, uimage2D, iimage2D
- EbtGImage3D, // non type: represents image3D, uimage3D, iimage3D
- EbtGImage2DArray, // non type: represents image2DArray, uimage2DArray, iimage2DArray
- EbtGImageCube, // non type: represents imageCube, uimageCube, iimageCube
- EbtGuardGImageEnd,
-
- EbtStruct,
- EbtInterfaceBlock,
- EbtAddress, // should be deprecated??
-
- EbtAtomicCounter,
-
- // end of list
- EbtLast
-};
-
-inline TBasicType convertGImageToFloatImage(TBasicType type)
-{
- switch (type)
- {
- case EbtGImage2D:
- return EbtImage2D;
- case EbtGImage3D:
- return EbtImage3D;
- case EbtGImage2DArray:
- return EbtImage2DArray;
- case EbtGImageCube:
- return EbtImageCube;
- default:
- UNREACHABLE();
- }
- return EbtLast;
-}
-
-inline TBasicType convertGImageToIntImage(TBasicType type)
-{
- switch (type)
- {
- case EbtGImage2D:
- return EbtIImage2D;
- case EbtGImage3D:
- return EbtIImage3D;
- case EbtGImage2DArray:
- return EbtIImage2DArray;
- case EbtGImageCube:
- return EbtIImageCube;
- default:
- UNREACHABLE();
- }
- return EbtLast;
-}
-
-inline TBasicType convertGImageToUnsignedImage(TBasicType type)
-{
- switch (type)
- {
- case EbtGImage2D:
- return EbtUImage2D;
- case EbtGImage3D:
- return EbtUImage3D;
- case EbtGImage2DArray:
- return EbtUImage2DArray;
- case EbtGImageCube:
- return EbtUImageCube;
- default:
- UNREACHABLE();
- }
- return EbtLast;
-}
-
-const char *getBasicString(TBasicType t);
-
-inline bool IsSampler(TBasicType type)
-{
- return type > EbtGuardSamplerBegin && type < EbtGuardSamplerEnd;
-}
-
-inline bool IsImage(TBasicType type)
-{
- return type > EbtGuardImageBegin && type < EbtGuardImageEnd;
-}
-
-inline bool IsGImage(TBasicType type)
-{
- return type > EbtGuardGImageBegin && type < EbtGuardGImageEnd;
-}
-
-inline bool IsAtomicCounter(TBasicType type)
-{
- return type == EbtAtomicCounter;
-}
-
-inline bool IsOpaqueType(TBasicType type)
-{
- return IsSampler(type) || IsImage(type) || IsAtomicCounter(type);
-}
-
-inline bool IsIntegerSampler(TBasicType type)
-{
- switch (type)
- {
- case EbtISampler2D:
- case EbtISampler3D:
- case EbtISamplerCube:
- case EbtISampler2DArray:
- case EbtISampler2DMS:
- case EbtUSampler2D:
- case EbtUSampler3D:
- case EbtUSamplerCube:
- case EbtUSampler2DArray:
- case EbtUSampler2DMS:
- return true;
- case EbtSampler2D:
- case EbtSampler3D:
- case EbtSamplerCube:
- case EbtSamplerExternalOES:
- case EbtSamplerExternal2DY2YEXT:
- case EbtSampler2DRect:
- case EbtSampler2DArray:
- case EbtSampler2DShadow:
- case EbtSamplerCubeShadow:
- case EbtSampler2DArrayShadow:
- case EbtSampler2DMS:
- return false;
- default:
- assert(!IsSampler(type));
- }
-
- return false;
-}
-
-inline bool IsSampler2DMS(TBasicType type)
-{
- switch (type)
- {
- case EbtSampler2DMS:
- case EbtISampler2DMS:
- case EbtUSampler2DMS:
- return true;
- default:
- return false;
- }
-}
-
-inline bool IsFloatImage(TBasicType type)
-{
- switch (type)
- {
- case EbtImage2D:
- case EbtImage3D:
- case EbtImage2DArray:
- case EbtImageCube:
- return true;
- default:
- break;
- }
-
- return false;
-}
-
-inline bool IsIntegerImage(TBasicType type)
-{
-
- switch (type)
- {
- case EbtIImage2D:
- case EbtIImage3D:
- case EbtIImage2DArray:
- case EbtIImageCube:
- return true;
- default:
- break;
- }
-
- return false;
-}
-
-inline bool IsUnsignedImage(TBasicType type)
-{
-
- switch (type)
- {
- case EbtUImage2D:
- case EbtUImage3D:
- case EbtUImage2DArray:
- case EbtUImageCube:
- return true;
- default:
- break;
- }
-
- return false;
-}
-
-inline bool IsSampler2D(TBasicType type)
-{
- switch (type)
- {
- case EbtSampler2D:
- case EbtISampler2D:
- case EbtUSampler2D:
- case EbtSampler2DArray:
- case EbtISampler2DArray:
- case EbtUSampler2DArray:
- case EbtSampler2DRect:
- case EbtSamplerExternalOES:
- case EbtSamplerExternal2DY2YEXT:
- case EbtSampler2DShadow:
- case EbtSampler2DArrayShadow:
- case EbtSampler2DMS:
- case EbtISampler2DMS:
- case EbtUSampler2DMS:
- return true;
- case EbtSampler3D:
- case EbtISampler3D:
- case EbtUSampler3D:
- case EbtISamplerCube:
- case EbtUSamplerCube:
- case EbtSamplerCube:
- case EbtSamplerCubeShadow:
- return false;
- default:
- assert(!IsSampler(type));
- }
-
- return false;
-}
-
-inline bool IsSamplerCube(TBasicType type)
-{
- switch (type)
- {
- case EbtSamplerCube:
- case EbtISamplerCube:
- case EbtUSamplerCube:
- case EbtSamplerCubeShadow:
- return true;
- case EbtSampler2D:
- case EbtSampler3D:
- case EbtSamplerExternalOES:
- case EbtSamplerExternal2DY2YEXT:
- case EbtSampler2DRect:
- case EbtSampler2DArray:
- case EbtSampler2DMS:
- case EbtISampler2D:
- case EbtISampler3D:
- case EbtISampler2DArray:
- case EbtISampler2DMS:
- case EbtUSampler2D:
- case EbtUSampler3D:
- case EbtUSampler2DArray:
- case EbtUSampler2DMS:
- case EbtSampler2DShadow:
- case EbtSampler2DArrayShadow:
- return false;
- default:
- assert(!IsSampler(type));
- }
-
- return false;
-}
-
-inline bool IsSampler3D(TBasicType type)
-{
- switch (type)
- {
- case EbtSampler3D:
- case EbtISampler3D:
- case EbtUSampler3D:
- return true;
- case EbtSampler2D:
- case EbtSamplerCube:
- case EbtSamplerExternalOES:
- case EbtSamplerExternal2DY2YEXT:
- case EbtSampler2DRect:
- case EbtSampler2DArray:
- case EbtSampler2DMS:
- case EbtISampler2D:
- case EbtISamplerCube:
- case EbtISampler2DArray:
- case EbtISampler2DMS:
- case EbtUSampler2D:
- case EbtUSamplerCube:
- case EbtUSampler2DArray:
- case EbtUSampler2DMS:
- case EbtSampler2DShadow:
- case EbtSamplerCubeShadow:
- case EbtSampler2DArrayShadow:
- return false;
- default:
- assert(!IsSampler(type));
- }
-
- return false;
-}
-
-inline bool IsSamplerArray(TBasicType type)
-{
- switch (type)
- {
- case EbtSampler2DArray:
- case EbtISampler2DArray:
- case EbtUSampler2DArray:
- case EbtSampler2DArrayShadow:
- return true;
- case EbtSampler2D:
- case EbtISampler2D:
- case EbtUSampler2D:
- case EbtSampler2DRect:
- case EbtSamplerExternalOES:
- case EbtSamplerExternal2DY2YEXT:
- case EbtSampler3D:
- case EbtISampler3D:
- case EbtUSampler3D:
- case EbtISamplerCube:
- case EbtUSamplerCube:
- case EbtSamplerCube:
- case EbtSampler2DShadow:
- case EbtSamplerCubeShadow:
- case EbtSampler2DMS:
- case EbtISampler2DMS:
- case EbtUSampler2DMS:
- return false;
- default:
- assert(!IsSampler(type));
- }
-
- return false;
-}
-
-inline bool IsShadowSampler(TBasicType type)
-{
- switch (type)
- {
- case EbtSampler2DShadow:
- case EbtSamplerCubeShadow:
- case EbtSampler2DArrayShadow:
- return true;
- case EbtISampler2D:
- case EbtISampler3D:
- case EbtISamplerCube:
- case EbtISampler2DArray:
- case EbtISampler2DMS:
- case EbtUSampler2D:
- case EbtUSampler3D:
- case EbtUSamplerCube:
- case EbtUSampler2DArray:
- case EbtUSampler2DMS:
- case EbtSampler2D:
- case EbtSampler3D:
- case EbtSamplerCube:
- case EbtSamplerExternalOES:
- case EbtSamplerExternal2DY2YEXT:
- case EbtSampler2DRect:
- case EbtSampler2DArray:
- case EbtSampler2DMS:
- return false;
- default:
- assert(!IsSampler(type));
- }
-
- return false;
-}
-
-inline bool IsImage2D(TBasicType type)
-{
- switch (type)
- {
- case EbtImage2D:
- case EbtIImage2D:
- case EbtUImage2D:
- return true;
- case EbtImage3D:
- case EbtIImage3D:
- case EbtUImage3D:
- case EbtImage2DArray:
- case EbtIImage2DArray:
- case EbtUImage2DArray:
- case EbtImageCube:
- case EbtIImageCube:
- case EbtUImageCube:
- return false;
- default:
- assert(!IsImage(type));
- }
-
- return false;
-}
-
-inline bool IsImage3D(TBasicType type)
-{
- switch (type)
- {
- case EbtImage3D:
- case EbtIImage3D:
- case EbtUImage3D:
- return true;
- case EbtImage2D:
- case EbtIImage2D:
- case EbtUImage2D:
- case EbtImage2DArray:
- case EbtIImage2DArray:
- case EbtUImage2DArray:
- case EbtImageCube:
- case EbtIImageCube:
- case EbtUImageCube:
- return false;
- default:
- assert(!IsImage(type));
- }
-
- return false;
-}
-
-inline bool IsImage2DArray(TBasicType type)
-{
- switch (type)
- {
- case EbtImage2DArray:
- case EbtIImage2DArray:
- case EbtUImage2DArray:
- return true;
- case EbtImage2D:
- case EbtIImage2D:
- case EbtUImage2D:
- case EbtImage3D:
- case EbtIImage3D:
- case EbtUImage3D:
- case EbtImageCube:
- case EbtIImageCube:
- case EbtUImageCube:
- return false;
- default:
- assert(!IsImage(type));
- }
-
- return false;
-}
-
-inline bool IsImageCube(TBasicType type)
-{
- switch (type)
- {
- case EbtImageCube:
- case EbtIImageCube:
- case EbtUImageCube:
- return true;
- case EbtImage2D:
- case EbtIImage2D:
- case EbtUImage2D:
- case EbtImage3D:
- case EbtIImage3D:
- case EbtUImage3D:
- case EbtImage2DArray:
- case EbtIImage2DArray:
- case EbtUImage2DArray:
- return false;
- default:
- assert(!IsImage(type));
- }
-
- return false;
-}
-
-inline bool IsInteger(TBasicType type)
-{
- return type == EbtInt || type == EbtUInt;
-}
-
-inline bool SupportsPrecision(TBasicType type)
-{
- return type == EbtFloat || type == EbtInt || type == EbtUInt || IsOpaqueType(type);
-}
-
-//
-// Qualifiers and built-ins. These are mainly used to see what can be read
-// or written, and by the machine dependent translator to know which registers
-// to allocate variables in. Since built-ins tend to go to different registers
-// than varying or uniform, it makes sense they are peers, not sub-classes.
-//
-enum TQualifier
-{
- EvqTemporary, // For temporaries (within a function), read/write
- EvqGlobal, // For globals read/write
- EvqConst, // User defined constants and non-output parameters in functions
- EvqAttribute, // Readonly
- EvqVaryingIn, // readonly, fragment shaders only
- EvqVaryingOut, // vertex shaders only read/write
- EvqUniform, // Readonly, vertex and fragment
- EvqBuffer, // read/write, vertex, fragment and compute shader
-
- EvqVertexIn, // Vertex shader input
- EvqFragmentOut, // Fragment shader output
- EvqVertexOut, // Vertex shader output
- EvqFragmentIn, // Fragment shader input
-
- // parameters
- EvqIn,
- EvqOut,
- EvqInOut,
- EvqConstReadOnly,
-
- // built-ins read by vertex shader
- EvqInstanceID,
- EvqVertexID,
-
- // built-ins written by vertex shader
- EvqPosition,
- EvqPointSize,
-
- // built-ins read by fragment shader
- EvqFragCoord,
- EvqFrontFacing,
- EvqPointCoord,
-
- // built-ins written by fragment shader
- EvqFragColor,
- EvqFragData,
-
- EvqFragDepth, // gl_FragDepth for ESSL300.
- EvqFragDepthEXT, // gl_FragDepthEXT for ESSL100, EXT_frag_depth.
-
- EvqSecondaryFragColorEXT, // EXT_blend_func_extended
- EvqSecondaryFragDataEXT, // EXT_blend_func_extended
-
- EvqViewIDOVR, // OVR_multiview
- EvqViewportIndex, // gl_ViewportIndex
-
- // built-ins written by the shader_framebuffer_fetch extension(s)
- EvqLastFragColor,
- EvqLastFragData,
-
- // GLSL ES 3.0 vertex output and fragment input
- EvqSmooth, // Incomplete qualifier, smooth is the default
- EvqFlat, // Incomplete qualifier
- EvqCentroid, // Incomplete qualifier
- EvqSmoothOut,
- EvqFlatOut,
- EvqCentroidOut, // Implies smooth
- EvqSmoothIn,
- EvqFlatIn,
- EvqCentroidIn, // Implies smooth
-
- // GLSL ES 3.1 compute shader special variables
- EvqShared,
- EvqComputeIn,
- EvqNumWorkGroups,
- EvqWorkGroupSize,
- EvqWorkGroupID,
- EvqLocalInvocationID,
- EvqGlobalInvocationID,
- EvqLocalInvocationIndex,
-
- // GLSL ES 3.1 memory qualifiers
- EvqReadOnly,
- EvqWriteOnly,
- EvqCoherent,
- EvqRestrict,
- EvqVolatile,
-
- // GLSL ES 3.1 extension OES_geometry_shader qualifiers
- EvqGeometryIn,
- EvqGeometryOut,
- EvqPerVertexIn, // gl_in
- EvqPrimitiveIDIn, // gl_PrimitiveIDIn
- EvqInvocationID, // gl_InvocationID
- EvqPrimitiveID, // gl_PrimitiveID
- EvqLayer, // gl_Layer
-
- // end of list
- EvqLast
-};
-
-inline bool IsQualifierUnspecified(TQualifier qualifier)
-{
- return (qualifier == EvqTemporary || qualifier == EvqGlobal);
-}
-
-enum TLayoutImageInternalFormat
-{
- EiifUnspecified,
- EiifRGBA32F,
- EiifRGBA16F,
- EiifR32F,
- EiifRGBA32UI,
- EiifRGBA16UI,
- EiifRGBA8UI,
- EiifR32UI,
- EiifRGBA32I,
- EiifRGBA16I,
- EiifRGBA8I,
- EiifR32I,
- EiifRGBA8,
- EiifRGBA8_SNORM
-};
-
-enum TLayoutMatrixPacking
-{
- EmpUnspecified,
- EmpRowMajor,
- EmpColumnMajor
-};
-
-enum TLayoutBlockStorage
-{
- EbsUnspecified,
- EbsShared,
- EbsPacked,
- EbsStd140,
- EbsStd430
-};
-
-enum TYuvCscStandardEXT
-{
- EycsUndefined,
- EycsItu601,
- EycsItu601FullRange,
- EycsItu709
-};
-
-enum TLayoutPrimitiveType
-{
- EptUndefined,
- EptPoints,
- EptLines,
- EptLinesAdjacency,
- EptTriangles,
- EptTrianglesAdjacency,
- EptLineStrip,
- EptTriangleStrip
-};
-
-struct TLayoutQualifier
-{
- // Must have a trivial default constructor since it is used in YYSTYPE.
- TLayoutQualifier() = default;
-
- constexpr static TLayoutQualifier Create() { return TLayoutQualifier(0); }
-
- bool isEmpty() const
- {
- return location == -1 && binding == -1 && offset == -1 && numViews == -1 && yuv == false &&
- matrixPacking == EmpUnspecified && blockStorage == EbsUnspecified &&
- !localSize.isAnyValueSet() && imageInternalFormat == EiifUnspecified &&
- primitiveType == EptUndefined && invocations == 0 && maxVertices == -1;
- }
-
- bool isCombinationValid() const
- {
- bool workSizeSpecified = localSize.isAnyValueSet();
- bool numViewsSet = (numViews != -1);
- bool geometryShaderSpecified =
- (primitiveType != EptUndefined) || (invocations != 0) || (maxVertices != -1);
- bool otherLayoutQualifiersSpecified =
- (location != -1 || binding != -1 || matrixPacking != EmpUnspecified ||
- blockStorage != EbsUnspecified || imageInternalFormat != EiifUnspecified);
-
- // we can have either the work group size specified, or number of views,
- // or yuv layout qualifier, or the other layout qualifiers.
- return (workSizeSpecified ? 1 : 0) + (numViewsSet ? 1 : 0) + (yuv ? 1 : 0) +
- (otherLayoutQualifiersSpecified ? 1 : 0) + (geometryShaderSpecified ? 1 : 0) <=
- 1;
- }
-
- bool isLocalSizeEqual(const sh::WorkGroupSize &localSizeIn) const
- {
- return localSize.isWorkGroupSizeMatching(localSizeIn);
- }
-
- int location;
- unsigned int locationsSpecified;
- TLayoutMatrixPacking matrixPacking;
- TLayoutBlockStorage blockStorage;
-
- // Compute shader layout qualifiers.
- sh::WorkGroupSize localSize;
-
- int binding;
- int offset;
-
- // Image format layout qualifier
- TLayoutImageInternalFormat imageInternalFormat;
-
- // OVR_multiview num_views.
- int numViews;
-
- // EXT_YUV_target yuv layout qualifier.
- bool yuv;
-
- // OES_geometry_shader layout qualifiers.
- TLayoutPrimitiveType primitiveType;
- int invocations;
- int maxVertices;
-
- private:
- explicit constexpr TLayoutQualifier(int /*placeholder*/)
- : location(-1),
- locationsSpecified(0),
- matrixPacking(EmpUnspecified),
- blockStorage(EbsUnspecified),
- localSize(-1),
- binding(-1),
- offset(-1),
- imageInternalFormat(EiifUnspecified),
- numViews(-1),
- yuv(false),
- primitiveType(EptUndefined),
- invocations(0),
- maxVertices(-1)
- {
- }
-};
-
-struct TMemoryQualifier
-{
- // Must have a trivial default constructor since it is used in YYSTYPE.
- TMemoryQualifier() = default;
-
- bool isEmpty() const
- {
- return !readonly && !writeonly && !coherent && !restrictQualifier && !volatileQualifier;
- }
-
- constexpr static TMemoryQualifier Create() { return TMemoryQualifier(0); }
-
- // GLSL ES 3.10 Revision 4, 4.9 Memory Access Qualifiers
- // An image can be qualified as both readonly and writeonly. It still can be can be used with
- // imageSize().
- bool readonly;
- bool writeonly;
- bool coherent;
-
- // restrict and volatile are reserved keywords in C/C++
- bool restrictQualifier;
- bool volatileQualifier;
-
- private:
- explicit constexpr TMemoryQualifier(int /*placeholder*/)
- : readonly(false),
- writeonly(false),
- coherent(false),
- restrictQualifier(false),
- volatileQualifier(false)
- {
- }
-};
-
-inline const char *getWorkGroupSizeString(size_t dimension)
-{
- switch (dimension)
- {
- case 0u:
- return "local_size_x";
- case 1u:
- return "local_size_y";
- case 2u:
- return "local_size_z";
- default:
- UNREACHABLE();
- return "dimension out of bounds";
- }
-}
-
-//
-// This is just for debug and error message print out, carried along with the definitions above.
-//
-inline const char *getQualifierString(TQualifier q)
-{
- // clang-format off
- switch(q)
- {
- case EvqTemporary: return "Temporary";
- case EvqGlobal: return "Global";
- case EvqConst: return "const";
- case EvqAttribute: return "attribute";
- case EvqVaryingIn: return "varying";
- case EvqVaryingOut: return "varying";
- case EvqUniform: return "uniform";
- case EvqBuffer: return "buffer";
- case EvqVertexIn: return "in";
- case EvqFragmentOut: return "out";
- case EvqVertexOut: return "out";
- case EvqFragmentIn: return "in";
- case EvqIn: return "in";
- case EvqOut: return "out";
- case EvqInOut: return "inout";
- case EvqConstReadOnly: return "const";
- case EvqInstanceID: return "InstanceID";
- case EvqVertexID: return "VertexID";
- case EvqPosition: return "Position";
- case EvqPointSize: return "PointSize";
- case EvqFragCoord: return "FragCoord";
- case EvqFrontFacing: return "FrontFacing";
- case EvqPointCoord: return "PointCoord";
- case EvqFragColor: return "FragColor";
- case EvqFragData: return "FragData";
- case EvqFragDepthEXT: return "FragDepth";
- case EvqFragDepth: return "FragDepth";
- case EvqSecondaryFragColorEXT: return "SecondaryFragColorEXT";
- case EvqSecondaryFragDataEXT: return "SecondaryFragDataEXT";
- case EvqViewIDOVR: return "ViewIDOVR";
- case EvqViewportIndex: return "ViewportIndex";
- case EvqLayer: return "Layer";
- case EvqLastFragColor: return "LastFragColor";
- case EvqLastFragData: return "LastFragData";
- case EvqSmoothOut: return "smooth out";
- case EvqCentroidOut: return "smooth centroid out";
- case EvqFlatOut: return "flat out";
- case EvqSmoothIn: return "smooth in";
- case EvqFlatIn: return "flat in";
- case EvqCentroidIn: return "smooth centroid in";
- case EvqCentroid: return "centroid";
- case EvqFlat: return "flat";
- case EvqSmooth: return "smooth";
- case EvqShared: return "shared";
- case EvqComputeIn: return "in";
- case EvqNumWorkGroups: return "NumWorkGroups";
- case EvqWorkGroupSize: return "WorkGroupSize";
- case EvqWorkGroupID: return "WorkGroupID";
- case EvqLocalInvocationID: return "LocalInvocationID";
- case EvqGlobalInvocationID: return "GlobalInvocationID";
- case EvqLocalInvocationIndex: return "LocalInvocationIndex";
- case EvqReadOnly: return "readonly";
- case EvqWriteOnly: return "writeonly";
- case EvqGeometryIn: return "in";
- case EvqGeometryOut: return "out";
- case EvqPerVertexIn: return "gl_in";
- default: UNREACHABLE(); return "unknown qualifier";
- }
- // clang-format on
-}
-
-inline const char *getMatrixPackingString(TLayoutMatrixPacking mpq)
-{
- switch (mpq)
- {
- case EmpUnspecified:
- return "mp_unspecified";
- case EmpRowMajor:
- return "row_major";
- case EmpColumnMajor:
- return "column_major";
- default:
- UNREACHABLE();
- return "unknown matrix packing";
- }
-}
-
-inline const char *getBlockStorageString(TLayoutBlockStorage bsq)
-{
- switch (bsq)
- {
- case EbsUnspecified:
- return "bs_unspecified";
- case EbsShared:
- return "shared";
- case EbsPacked:
- return "packed";
- case EbsStd140:
- return "std140";
- case EbsStd430:
- return "std430";
- default:
- UNREACHABLE();
- return "unknown block storage";
- }
-}
-
-inline const char *getImageInternalFormatString(TLayoutImageInternalFormat iifq)
-{
- switch (iifq)
- {
- case EiifRGBA32F:
- return "rgba32f";
- case EiifRGBA16F:
- return "rgba16f";
- case EiifR32F:
- return "r32f";
- case EiifRGBA32UI:
- return "rgba32ui";
- case EiifRGBA16UI:
- return "rgba16ui";
- case EiifRGBA8UI:
- return "rgba8ui";
- case EiifR32UI:
- return "r32ui";
- case EiifRGBA32I:
- return "rgba32i";
- case EiifRGBA16I:
- return "rgba16i";
- case EiifRGBA8I:
- return "rgba8i";
- case EiifR32I:
- return "r32i";
- case EiifRGBA8:
- return "rgba8";
- case EiifRGBA8_SNORM:
- return "rgba8_snorm";
- default:
- UNREACHABLE();
- return "unknown internal image format";
- }
-}
-
-inline TYuvCscStandardEXT getYuvCscStandardEXT(const std::string &str)
-{
- if (str == "itu_601")
- return EycsItu601;
- else if (str == "itu_601_full_range")
- return EycsItu601FullRange;
- else if (str == "itu_709")
- return EycsItu709;
- return EycsUndefined;
-}
-
-inline const char *getYuvCscStandardEXTString(TYuvCscStandardEXT ycsq)
-{
- switch (ycsq)
- {
- case EycsItu601:
- return "itu_601";
- case EycsItu601FullRange:
- return "itu_601_full_range";
- case EycsItu709:
- return "itu_709";
- default:
- UNREACHABLE();
- return "unknown color space conversion standard";
- }
-}
-
-inline const char *getGeometryShaderPrimitiveTypeString(TLayoutPrimitiveType primitiveType)
-{
- switch (primitiveType)
- {
- case EptPoints:
- return "points";
- case EptLines:
- return "lines";
- case EptTriangles:
- return "triangles";
- case EptLinesAdjacency:
- return "lines_adjacency";
- case EptTrianglesAdjacency:
- return "triangles_adjacency";
- case EptLineStrip:
- return "line_strip";
- case EptTriangleStrip:
- return "triangle_strip";
- default:
- UNREACHABLE();
- return "unknown geometry shader primitive type";
- }
-}
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_BASETYPES_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/BreakVariableAliasingInInnerLoops.cpp b/src/3rdparty/angle/src/compiler/translator/BreakVariableAliasingInInnerLoops.cpp
deleted file mode 100644
index d6a1e025de..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/BreakVariableAliasingInInnerLoops.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-//
-// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// BreakVariableAliasingInInnerLoops.h: To optimize simple assignments, the HLSL compiler frontend
-// may record a variable as aliasing another. Sometimes the alias information gets garbled
-// so we work around this issue by breaking the aliasing chain in inner loops.
-
-#include "BreakVariableAliasingInInnerLoops.h"
-
-#include "compiler/translator/IntermNode_util.h"
-#include "compiler/translator/IntermTraverse.h"
-
-// A HLSL compiler developer gave us more details on the root cause and the workaround needed:
-// The root problem is that if the HLSL compiler is applying aliasing information even on
-// incomplete simulations (in this case, a single pass). The bug is triggered by an assignment
-// that comes from a series of assignments, possibly with swizzled or ternary operators with
-// known conditionals, where the source is before the loop.
-// So, a workaround is to add a +0 term to variables the first time they are assigned to in
-// an inner loop (if they are declared in an outside scope, otherwise there is no need).
-// This will break the aliasing chain.
-
-// For simplicity here we add a +0 to any assignment that is in at least two nested loops. Because
-// the bug only shows up with swizzles, and ternary assignment, whole array or whole structure
-// assignment don't need a workaround.
-
-namespace sh
-{
-
-namespace
-{
-
-class AliasingBreaker : public TIntermTraverser
-{
- public:
- AliasingBreaker() : TIntermTraverser(true, false, true) {}
-
- protected:
- bool visitBinary(Visit visit, TIntermBinary *binary)
- {
- if (visit != PreVisit)
- {
- return false;
- }
-
- if (mLoopLevel < 2 || !binary->isAssignment())
- {
- return true;
- }
-
- TIntermTyped *B = binary->getRight();
- TType type = B->getType();
-
- if (!type.isScalar() && !type.isVector() && !type.isMatrix())
- {
- return true;
- }
-
- if (type.isArray() || IsSampler(type.getBasicType()))
- {
- return true;
- }
-
- // We have a scalar / vector / matrix assignment with loop depth 2.
- // Transform it from
- // A = B
- // to
- // A = (B + typeof<B>(0));
-
- TIntermBinary *bPlusZero = new TIntermBinary(EOpAdd, B, CreateZeroNode(type));
- bPlusZero->setLine(B->getLine());
-
- binary->replaceChildNode(B, bPlusZero);
-
- return true;
- }
-
- bool visitLoop(Visit visit, TIntermLoop *loop)
- {
- if (visit == PreVisit)
- {
- mLoopLevel++;
- }
- else
- {
- ASSERT(mLoopLevel > 0);
- mLoopLevel--;
- }
-
- return true;
- }
-
- private:
- int mLoopLevel = 0;
-};
-
-} // anonymous namespace
-
-void BreakVariableAliasingInInnerLoops(TIntermNode *root)
-{
- AliasingBreaker breaker;
- root->traverse(&breaker);
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/BreakVariableAliasingInInnerLoops.h b/src/3rdparty/angle/src/compiler/translator/BreakVariableAliasingInInnerLoops.h
deleted file mode 100644
index b1d906f919..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/BreakVariableAliasingInInnerLoops.h
+++ /dev/null
@@ -1,23 +0,0 @@
-//
-// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// BreakVariableAliasingInInnerLoops.h: To optimize simple assignments, the HLSL compiler frontend
-// may record a variable as aliasing another. Sometimes the alias information gets garbled
-// so we work around this issue by breaking the aliasing chain in inner loops.
-
-#ifndef COMPILER_TRANSLATOR_BREAKVARIABLEALIASINGININNERLOOPS_H_
-#define COMPILER_TRANSLATOR_BREAKVARIABLEALIASINGININNERLOOPS_H_
-
-class TIntermNode;
-
-namespace sh
-{
-
-void BreakVariableAliasingInInnerLoops(TIntermNode *root);
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_BREAKVARIABLEALIASINGININNERLOOPS_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.cpp b/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.cpp
deleted file mode 100644
index 905e634fd1..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.cpp
+++ /dev/null
@@ -1,355 +0,0 @@
-//
-// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/translator/BuiltInFunctionEmulator.h"
-#include "angle_gl.h"
-#include "compiler/translator/Cache.h"
-#include "compiler/translator/IntermTraverse.h"
-#include "compiler/translator/SymbolTable.h"
-
-namespace sh
-{
-
-class BuiltInFunctionEmulator::BuiltInFunctionEmulationMarker : public TIntermTraverser
-{
- public:
- BuiltInFunctionEmulationMarker(BuiltInFunctionEmulator &emulator)
- : TIntermTraverser(true, false, false), mEmulator(emulator)
- {
- }
-
- bool visitUnary(Visit visit, TIntermUnary *node) override
- {
- if (visit == PreVisit)
- {
- bool needToEmulate =
- mEmulator.setFunctionCalled(node->getOp(), node->getOperand()->getType());
- if (needToEmulate)
- node->setUseEmulatedFunction();
- }
- return true;
- }
-
- bool visitAggregate(Visit visit, TIntermAggregate *node) override
- {
- if (visit == PreVisit)
- {
- // Here we handle all the built-in functions mapped to ops, not just the ones that are
- // currently identified as problematic.
- if (node->isConstructor() || node->isFunctionCall())
- {
- return true;
- }
- const TIntermSequence &sequence = *(node->getSequence());
- bool needToEmulate = false;
- // Right now we only handle built-in functions with two to four parameters.
- if (sequence.size() == 2)
- {
- TIntermTyped *param1 = sequence[0]->getAsTyped();
- TIntermTyped *param2 = sequence[1]->getAsTyped();
- if (!param1 || !param2)
- return true;
- needToEmulate = mEmulator.setFunctionCalled(node->getOp(), param1->getType(),
- param2->getType());
- }
- else if (sequence.size() == 3)
- {
- TIntermTyped *param1 = sequence[0]->getAsTyped();
- TIntermTyped *param2 = sequence[1]->getAsTyped();
- TIntermTyped *param3 = sequence[2]->getAsTyped();
- if (!param1 || !param2 || !param3)
- return true;
- needToEmulate = mEmulator.setFunctionCalled(node->getOp(), param1->getType(),
- param2->getType(), param3->getType());
- }
- else if (sequence.size() == 4)
- {
- TIntermTyped *param1 = sequence[0]->getAsTyped();
- TIntermTyped *param2 = sequence[1]->getAsTyped();
- TIntermTyped *param3 = sequence[2]->getAsTyped();
- TIntermTyped *param4 = sequence[3]->getAsTyped();
- if (!param1 || !param2 || !param3 || !param4)
- return true;
- needToEmulate =
- mEmulator.setFunctionCalled(node->getOp(), param1->getType(), param2->getType(),
- param3->getType(), param4->getType());
- }
- else
- {
- return true;
- }
-
- if (needToEmulate)
- node->setUseEmulatedFunction();
- }
- return true;
- }
-
- private:
- BuiltInFunctionEmulator &mEmulator;
-};
-
-BuiltInFunctionEmulator::BuiltInFunctionEmulator()
-{
-}
-
-FunctionId BuiltInFunctionEmulator::addEmulatedFunction(TOperator op,
- const TType *param,
- const char *emulatedFunctionDefinition)
-{
- FunctionId id(op, param);
- mEmulatedFunctions[id] = std::string(emulatedFunctionDefinition);
- return id;
-}
-
-FunctionId BuiltInFunctionEmulator::addEmulatedFunction(TOperator op,
- const TType *param1,
- const TType *param2,
- const char *emulatedFunctionDefinition)
-{
- FunctionId id(op, param1, param2);
- mEmulatedFunctions[id] = std::string(emulatedFunctionDefinition);
- return id;
-}
-
-FunctionId BuiltInFunctionEmulator::addEmulatedFunctionWithDependency(
- const FunctionId &dependency,
- TOperator op,
- const TType *param1,
- const TType *param2,
- const char *emulatedFunctionDefinition)
-{
- FunctionId id(op, param1, param2);
- mEmulatedFunctions[id] = std::string(emulatedFunctionDefinition);
- mFunctionDependencies[id] = dependency;
- return id;
-}
-
-FunctionId BuiltInFunctionEmulator::addEmulatedFunction(TOperator op,
- const TType *param1,
- const TType *param2,
- const TType *param3,
- const char *emulatedFunctionDefinition)
-{
- FunctionId id(op, param1, param2, param3);
- mEmulatedFunctions[id] = std::string(emulatedFunctionDefinition);
- return id;
-}
-
-FunctionId BuiltInFunctionEmulator::addEmulatedFunction(TOperator op,
- const TType *param1,
- const TType *param2,
- const TType *param3,
- const TType *param4,
- const char *emulatedFunctionDefinition)
-{
- FunctionId id(op, param1, param2, param3, param4);
- mEmulatedFunctions[id] = std::string(emulatedFunctionDefinition);
- return id;
-}
-
-FunctionId BuiltInFunctionEmulator::addEmulatedFunctionWithDependency(
- const FunctionId &dependency,
- TOperator op,
- const TType *param1,
- const TType *param2,
- const TType *param3,
- const TType *param4,
- const char *emulatedFunctionDefinition)
-{
- FunctionId id(op, param1, param2, param3, param4);
- mEmulatedFunctions[id] = std::string(emulatedFunctionDefinition);
- mFunctionDependencies[id] = dependency;
- return id;
-}
-
-bool BuiltInFunctionEmulator::isOutputEmpty() const
-{
- return (mFunctions.size() == 0);
-}
-
-void BuiltInFunctionEmulator::outputEmulatedFunctions(TInfoSinkBase &out) const
-{
- for (const auto &function : mFunctions)
- {
- const char *body = findEmulatedFunction(function);
- ASSERT(body);
- out << body;
- out << "\n\n";
- }
-}
-
-bool BuiltInFunctionEmulator::setFunctionCalled(TOperator op, const TType &param)
-{
- return setFunctionCalled(FunctionId(op, &param));
-}
-
-bool BuiltInFunctionEmulator::setFunctionCalled(TOperator op,
- const TType &param1,
- const TType &param2)
-{
- return setFunctionCalled(FunctionId(op, &param1, &param2));
-}
-
-bool BuiltInFunctionEmulator::setFunctionCalled(TOperator op,
- const TType &param1,
- const TType &param2,
- const TType &param3)
-{
- return setFunctionCalled(FunctionId(op, &param1, &param2, &param3));
-}
-
-bool BuiltInFunctionEmulator::setFunctionCalled(TOperator op,
- const TType &param1,
- const TType &param2,
- const TType &param3,
- const TType &param4)
-{
- return setFunctionCalled(FunctionId(op, &param1, &param2, &param3, &param4));
-}
-
-const char *BuiltInFunctionEmulator::findEmulatedFunction(const FunctionId &functionId) const
-{
- for (const auto &queryFunction : mQueryFunctions)
- {
- const char *result = queryFunction(functionId);
- if (result)
- {
- return result;
- }
- }
-
- const auto &result = mEmulatedFunctions.find(functionId);
- if (result != mEmulatedFunctions.end())
- {
- return result->second.c_str();
- }
-
- return nullptr;
-}
-
-bool BuiltInFunctionEmulator::setFunctionCalled(const FunctionId &functionId)
-{
- if (!findEmulatedFunction(functionId))
- {
- return false;
- }
-
- for (size_t i = 0; i < mFunctions.size(); ++i)
- {
- if (mFunctions[i] == functionId)
- return true;
- }
- // If the function depends on another, mark the dependency as called.
- auto dependency = mFunctionDependencies.find(functionId);
- if (dependency != mFunctionDependencies.end())
- {
- setFunctionCalled((*dependency).second);
- }
- // Copy the functionId if it needs to be stored, to make sure that the TType pointers inside
- // remain valid and constant.
- mFunctions.push_back(functionId.getCopy());
- return true;
-}
-
-void BuiltInFunctionEmulator::markBuiltInFunctionsForEmulation(TIntermNode *root)
-{
- ASSERT(root);
-
- if (mEmulatedFunctions.empty() && mQueryFunctions.empty())
- return;
-
- BuiltInFunctionEmulationMarker marker(*this);
- root->traverse(&marker);
-}
-
-void BuiltInFunctionEmulator::cleanup()
-{
- mFunctions.clear();
- mFunctionDependencies.clear();
-}
-
-void BuiltInFunctionEmulator::addFunctionMap(BuiltinQueryFunc queryFunc)
-{
- mQueryFunctions.push_back(queryFunc);
-}
-
-// static
-void BuiltInFunctionEmulator::WriteEmulatedFunctionName(TInfoSinkBase &out, const char *name)
-{
- ASSERT(name[strlen(name) - 1] != '(');
- out << name << "_emu";
-}
-
-FunctionId::FunctionId()
- : mOp(EOpNull),
- mParam1(TCache::getType(EbtVoid)),
- mParam2(TCache::getType(EbtVoid)),
- mParam3(TCache::getType(EbtVoid)),
- mParam4(TCache::getType(EbtVoid))
-{
-}
-
-FunctionId::FunctionId(TOperator op, const TType *param)
- : mOp(op),
- mParam1(param),
- mParam2(TCache::getType(EbtVoid)),
- mParam3(TCache::getType(EbtVoid)),
- mParam4(TCache::getType(EbtVoid))
-{
-}
-
-FunctionId::FunctionId(TOperator op, const TType *param1, const TType *param2)
- : mOp(op),
- mParam1(param1),
- mParam2(param2),
- mParam3(TCache::getType(EbtVoid)),
- mParam4(TCache::getType(EbtVoid))
-{
-}
-
-FunctionId::FunctionId(TOperator op, const TType *param1, const TType *param2, const TType *param3)
- : mOp(op), mParam1(param1), mParam2(param2), mParam3(param3), mParam4(TCache::getType(EbtVoid))
-{
-}
-
-FunctionId::FunctionId(TOperator op,
- const TType *param1,
- const TType *param2,
- const TType *param3,
- const TType *param4)
- : mOp(op), mParam1(param1), mParam2(param2), mParam3(param3), mParam4(param4)
-{
-}
-
-bool FunctionId::operator==(const FunctionId &other) const
-{
- return (mOp == other.mOp && *mParam1 == *other.mParam1 && *mParam2 == *other.mParam2 &&
- *mParam3 == *other.mParam3 && *mParam4 == *other.mParam4);
-}
-
-bool FunctionId::operator<(const FunctionId &other) const
-{
- if (mOp != other.mOp)
- return mOp < other.mOp;
- if (*mParam1 != *other.mParam1)
- return *mParam1 < *other.mParam1;
- if (*mParam2 != *other.mParam2)
- return *mParam2 < *other.mParam2;
- if (*mParam3 != *other.mParam3)
- return *mParam3 < *other.mParam3;
- if (*mParam4 != *other.mParam4)
- return *mParam4 < *other.mParam4;
- return false; // all fields are equal
-}
-
-FunctionId FunctionId::getCopy() const
-{
- return FunctionId(mOp, new TType(*mParam1), new TType(*mParam2), new TType(*mParam3),
- new TType(*mParam4));
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.h b/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.h
deleted file mode 100644
index 5f15f66224..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.h
+++ /dev/null
@@ -1,183 +0,0 @@
-//
-// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATOR_H_
-#define COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATOR_H_
-
-#include "compiler/translator/InfoSink.h"
-#include "compiler/translator/IntermNode.h"
-#include "compiler/translator/ParamType.h"
-
-namespace sh
-{
-
-struct MiniFunctionId
-{
- constexpr MiniFunctionId(TOperator op = EOpNull,
- ParamType paramType1 = ParamType::Void,
- ParamType paramType2 = ParamType::Void,
- ParamType paramType3 = ParamType::Void,
- ParamType paramType4 = ParamType::Void)
- : op(op),
- paramType1(paramType1),
- paramType2(paramType2),
- paramType3(paramType3),
- paramType4(paramType4)
- {
- }
-
- TOperator op;
- ParamType paramType1;
- ParamType paramType2;
- ParamType paramType3;
- ParamType paramType4;
-};
-
-class FunctionId final
-{
- public:
- FunctionId();
- FunctionId(TOperator op, const TType *param);
- FunctionId(TOperator op, const TType *param1, const TType *param2);
- FunctionId(TOperator op, const TType *param1, const TType *param2, const TType *param3);
- FunctionId(TOperator op,
- const TType *param1,
- const TType *param2,
- const TType *param3,
- const TType *param4);
-
- FunctionId(const FunctionId &) = default;
- FunctionId &operator=(const FunctionId &) = default;
-
- bool operator==(const FunctionId &other) const;
- bool operator<(const FunctionId &other) const;
-
- FunctionId getCopy() const;
-
- private:
- friend bool operator==(const MiniFunctionId &miniId, const FunctionId &functionId);
- TOperator mOp;
-
- // The memory that these TType objects use is freed by PoolAllocator. The
- // BuiltInFunctionEmulator's lifetime can extend until after the memory pool is freed, but
- // that's not an issue since this class never destructs these objects.
- const TType *mParam1;
- const TType *mParam2;
- const TType *mParam3;
- const TType *mParam4;
-};
-
-inline bool operator==(ParamType paramType, const TType *type)
-{
- return SameParamType(paramType, type->getBasicType(), type->getNominalSize(),
- type->getSecondarySize());
-}
-
-inline bool operator==(const MiniFunctionId &miniId, const FunctionId &functionId)
-{
- return miniId.op == functionId.mOp && miniId.paramType1 == functionId.mParam1 &&
- miniId.paramType2 == functionId.mParam2 && miniId.paramType3 == functionId.mParam3 &&
- miniId.paramType4 == functionId.mParam4;
-}
-
-using BuiltinQueryFunc = const char *(const FunctionId &);
-
-//
-// This class decides which built-in functions need to be replaced with the emulated ones. It can be
-// used to work around driver bugs or implement functions that are not natively implemented on a
-// specific platform.
-//
-class BuiltInFunctionEmulator
-{
- public:
- BuiltInFunctionEmulator();
-
- void markBuiltInFunctionsForEmulation(TIntermNode *root);
-
- void cleanup();
-
- // "name" gets written as "name_emu".
- static void WriteEmulatedFunctionName(TInfoSinkBase &out, const char *name);
-
- bool isOutputEmpty() const;
-
- // Output function emulation definition. This should be before any other shader source.
- void outputEmulatedFunctions(TInfoSinkBase &out) const;
-
- // Add functions that need to be emulated.
- FunctionId addEmulatedFunction(TOperator op,
- const TType *param,
- const char *emulatedFunctionDefinition);
- FunctionId addEmulatedFunction(TOperator op,
- const TType *param1,
- const TType *param2,
- const char *emulatedFunctionDefinition);
- FunctionId addEmulatedFunction(TOperator op,
- const TType *param1,
- const TType *param2,
- const TType *param3,
- const char *emulatedFunctionDefinition);
- FunctionId addEmulatedFunction(TOperator op,
- const TType *param1,
- const TType *param2,
- const TType *param3,
- const TType *param4,
- const char *emulatedFunctionDefinition);
-
- FunctionId addEmulatedFunctionWithDependency(const FunctionId &dependency,
- TOperator op,
- const TType *param1,
- const TType *param2,
- const char *emulatedFunctionDefinition);
- FunctionId addEmulatedFunctionWithDependency(const FunctionId &dependency,
- TOperator op,
- const TType *param1,
- const TType *param2,
- const TType *param3,
- const TType *param4,
- const char *emulatedFunctionDefinition);
-
- void addFunctionMap(BuiltinQueryFunc queryFunc);
-
- private:
- class BuiltInFunctionEmulationMarker;
-
- // Records that a function is called by the shader and might need to be emulated. If the
- // function is not in mEmulatedFunctions, this becomes a no-op. Returns true if the function
- // call needs to be replaced with an emulated one.
- bool setFunctionCalled(TOperator op, const TType &param);
- bool setFunctionCalled(TOperator op, const TType &param1, const TType &param2);
- bool setFunctionCalled(TOperator op,
- const TType &param1,
- const TType &param2,
- const TType &param3);
- bool setFunctionCalled(TOperator op,
- const TType &param1,
- const TType &param2,
- const TType &param3,
- const TType &param4);
-
- bool setFunctionCalled(const FunctionId &functionId);
-
- const char *findEmulatedFunction(const FunctionId &functionId) const;
-
- // Map from function id to emulated function definition
- std::map<FunctionId, std::string> mEmulatedFunctions;
-
- // Map from dependent functions to their dependencies. This structure allows each function to
- // have at most one dependency.
- std::map<FunctionId, FunctionId> mFunctionDependencies;
-
- // Called function ids
- std::vector<FunctionId> mFunctions;
-
- // Constexpr function tables.
- std::vector<BuiltinQueryFunc *> mQueryFunctions;
-};
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATOR_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorGLSL.cpp b/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorGLSL.cpp
deleted file mode 100644
index 27ee04da35..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorGLSL.cpp
+++ /dev/null
@@ -1,293 +0,0 @@
-//
-// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "angle_gl.h"
-#include "compiler/translator/BuiltInFunctionEmulator.h"
-#include "compiler/translator/BuiltInFunctionEmulatorGLSL.h"
-#include "compiler/translator/Cache.h"
-#include "compiler/translator/SymbolTable.h"
-#include "compiler/translator/VersionGLSL.h"
-
-namespace sh
-{
-
-void InitBuiltInAbsFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator *emu,
- sh::GLenum shaderType)
-{
- if (shaderType == GL_VERTEX_SHADER)
- {
- const TType *int1 = TCache::getType(EbtInt);
- emu->addEmulatedFunction(EOpAbs, int1, "int abs_emu(int x) { return x * sign(x); }");
- }
-}
-
-void InitBuiltInIsnanFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator *emu,
- int targetGLSLVersion)
-{
- // isnan() is supported since GLSL 1.3.
- if (targetGLSLVersion < GLSL_VERSION_130)
- return;
-
- const TType *float1 = TCache::getType(EbtFloat);
- const TType *float2 = TCache::getType(EbtFloat, 2);
- const TType *float3 = TCache::getType(EbtFloat, 3);
- const TType *float4 = TCache::getType(EbtFloat, 4);
-
- // !(x > 0.0 || x < 0.0 || x == 0.0) will be optimized and always equal to false.
- emu->addEmulatedFunction(
- EOpIsNan, float1,
- "bool isnan_emu(float x) { return (x > 0.0 || x < 0.0) ? false : x != 0.0; }");
- emu->addEmulatedFunction(
- EOpIsNan, float2,
- "bvec2 isnan_emu(vec2 x)\n"
- "{\n"
- " bvec2 isnan;\n"
- " for (int i = 0; i < 2; i++)\n"
- " {\n"
- " isnan[i] = (x[i] > 0.0 || x[i] < 0.0) ? false : x[i] != 0.0;\n"
- " }\n"
- " return isnan;\n"
- "}\n");
- emu->addEmulatedFunction(
- EOpIsNan, float3,
- "bvec3 isnan_emu(vec3 x)\n"
- "{\n"
- " bvec3 isnan;\n"
- " for (int i = 0; i < 3; i++)\n"
- " {\n"
- " isnan[i] = (x[i] > 0.0 || x[i] < 0.0) ? false : x[i] != 0.0;\n"
- " }\n"
- " return isnan;\n"
- "}\n");
- emu->addEmulatedFunction(
- EOpIsNan, float4,
- "bvec4 isnan_emu(vec4 x)\n"
- "{\n"
- " bvec4 isnan;\n"
- " for (int i = 0; i < 4; i++)\n"
- " {\n"
- " isnan[i] = (x[i] > 0.0 || x[i] < 0.0) ? false : x[i] != 0.0;\n"
- " }\n"
- " return isnan;\n"
- "}\n");
-}
-
-void InitBuiltInAtanFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator *emu)
-{
- const TType *float1 = TCache::getType(EbtFloat);
- auto floatFuncId = emu->addEmulatedFunction(
- EOpAtan, float1, float1,
- "emu_precision float atan_emu(emu_precision float y, emu_precision "
- "float x)\n"
- "{\n"
- " if (x > 0.0) return atan(y / x);\n"
- " else if (x < 0.0 && y >= 0.0) return atan(y / x) + 3.14159265;\n"
- " else if (x < 0.0 && y < 0.0) return atan(y / x) - 3.14159265;\n"
- " else return 1.57079632 * sign(y);\n"
- "}\n");
- for (int dim = 2; dim <= 4; ++dim)
- {
- const TType *floatVec = TCache::getType(EbtFloat, static_cast<unsigned char>(dim));
- std::stringstream ss;
- ss << "emu_precision vec" << dim << " atan_emu(emu_precision vec" << dim
- << " y, emu_precision vec" << dim << " x)\n"
- << "{\n"
- " return vec"
- << dim << "(";
- for (int i = 0; i < dim; ++i)
- {
- ss << "atan_emu(y[" << i << "], x[" << i << "])";
- if (i < dim - 1)
- {
- ss << ", ";
- }
- }
- ss << ");\n"
- "}\n";
- emu->addEmulatedFunctionWithDependency(floatFuncId, EOpAtan, floatVec, floatVec,
- ss.str().c_str());
- }
-}
-
-// Emulate built-in functions missing from GLSL 1.30 and higher
-void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator *emu,
- sh::GLenum shaderType,
- int targetGLSLVersion)
-{
- // Emulate packUnorm2x16 and unpackUnorm2x16 (GLSL 4.10)
- if (targetGLSLVersion < GLSL_VERSION_410)
- {
- const TType *float2 = TCache::getType(EbtFloat, 2);
- const TType *uint1 = TCache::getType(EbtUInt);
-
- // clang-format off
- emu->addEmulatedFunction(EOpPackUnorm2x16, float2,
- "uint packUnorm2x16_emu(vec2 v)\n"
- "{\n"
- " int x = int(round(clamp(v.x, 0.0, 1.0) * 65535.0));\n"
- " int y = int(round(clamp(v.y, 0.0, 1.0) * 65535.0));\n"
- " return uint((y << 16) | (x & 0xFFFF));\n"
- "}\n");
-
- emu->addEmulatedFunction(EOpUnpackUnorm2x16, uint1,
- "vec2 unpackUnorm2x16_emu(uint u)\n"
- "{\n"
- " float x = float(u & 0xFFFFu) / 65535.0;\n"
- " float y = float(u >> 16) / 65535.0;\n"
- " return vec2(x, y);\n"
- "}\n");
- // clang-format on
- }
-
- // Emulate packSnorm2x16, packHalf2x16, unpackSnorm2x16, and unpackHalf2x16 (GLSL 4.20)
- // by using floatBitsToInt, floatBitsToUint, intBitsToFloat, and uintBitsToFloat (GLSL 3.30).
- if (targetGLSLVersion >= GLSL_VERSION_330 && targetGLSLVersion < GLSL_VERSION_420)
- {
- const TType *float2 = TCache::getType(EbtFloat, 2);
- const TType *uint1 = TCache::getType(EbtUInt);
-
- // clang-format off
- emu->addEmulatedFunction(EOpPackSnorm2x16, float2,
- "uint packSnorm2x16_emu(vec2 v)\n"
- "{\n"
- " #if defined(GL_ARB_shading_language_packing)\n"
- " return packSnorm2x16(v);\n"
- " #else\n"
- " int x = int(round(clamp(v.x, -1.0, 1.0) * 32767.0));\n"
- " int y = int(round(clamp(v.y, -1.0, 1.0) * 32767.0));\n"
- " return uint((y << 16) | (x & 0xFFFF));\n"
- " #endif\n"
- "}\n");
- emu->addEmulatedFunction(EOpUnpackSnorm2x16, uint1,
- "#if !defined(GL_ARB_shading_language_packing)\n"
- " float fromSnorm(uint x)\n"
- " {\n"
- " int xi = (int(x) & 0x7FFF) - (int(x) & 0x8000);\n"
- " return clamp(float(xi) / 32767.0, -1.0, 1.0);\n"
- " }\n"
- "#endif\n"
- "\n"
- "vec2 unpackSnorm2x16_emu(uint u)\n"
- "{\n"
- " #if defined(GL_ARB_shading_language_packing)\n"
- " return unpackSnorm2x16(u);\n"
- " #else\n"
- " uint y = (u >> 16);\n"
- " uint x = u;\n"
- " return vec2(fromSnorm(x), fromSnorm(y));\n"
- " #endif\n"
- "}\n");
- // Functions uint f32tof16(float val) and float f16tof32(uint val) are
- // based on the OpenGL redbook Appendix Session "Floating-Point Formats Used in OpenGL".
- emu->addEmulatedFunction(EOpPackHalf2x16, float2,
- "#if !defined(GL_ARB_shading_language_packing)\n"
- " uint f32tof16(float val)\n"
- " {\n"
- " uint f32 = floatBitsToUint(val);\n"
- " uint f16 = 0u;\n"
- " uint sign = (f32 >> 16) & 0x8000u;\n"
- " int exponent = int((f32 >> 23) & 0xFFu) - 127;\n"
- " uint mantissa = f32 & 0x007FFFFFu;\n"
- " if (exponent == 128)\n"
- " {\n"
- " // Infinity or NaN\n"
- " // NaN bits that are masked out by 0x3FF get discarded.\n"
- " // This can turn some NaNs to infinity, but this is allowed by the spec.\n"
- " f16 = sign | (0x1Fu << 10);\n"
- " f16 |= (mantissa & 0x3FFu);\n"
- " }\n"
- " else if (exponent > 15)\n"
- " {\n"
- " // Overflow - flush to Infinity\n"
- " f16 = sign | (0x1Fu << 10);\n"
- " }\n"
- " else if (exponent > -15)\n"
- " {\n"
- " // Representable value\n"
- " exponent += 15;\n"
- " mantissa >>= 13;\n"
- " f16 = sign | uint(exponent << 10) | mantissa;\n"
- " }\n"
- " else\n"
- " {\n"
- " f16 = sign;\n"
- " }\n"
- " return f16;\n"
- " }\n"
- "#endif\n"
- "\n"
- "uint packHalf2x16_emu(vec2 v)\n"
- "{\n"
- " #if defined(GL_ARB_shading_language_packing)\n"
- " return packHalf2x16(v);\n"
- " #else\n"
- " uint x = f32tof16(v.x);\n"
- " uint y = f32tof16(v.y);\n"
- " return (y << 16) | x;\n"
- " #endif\n"
- "}\n");
- emu->addEmulatedFunction(EOpUnpackHalf2x16, uint1,
- "#if !defined(GL_ARB_shading_language_packing)\n"
- " float f16tof32(uint val)\n"
- " {\n"
- " uint sign = (val & 0x8000u) << 16;\n"
- " int exponent = int((val & 0x7C00u) >> 10);\n"
- " uint mantissa = val & 0x03FFu;\n"
- " float f32 = 0.0;\n"
- " if(exponent == 0)\n"
- " {\n"
- " if (mantissa != 0u)\n"
- " {\n"
- " const float scale = 1.0 / (1 << 24);\n"
- " f32 = scale * mantissa;\n"
- " }\n"
- " }\n"
- " else if (exponent == 31)\n"
- " {\n"
- " return uintBitsToFloat(sign | 0x7F800000u | mantissa);\n"
- " }\n"
- " else\n"
- " {\n"
- " exponent -= 15;\n"
- " float scale;\n"
- " if(exponent < 0)\n"
- " {\n"
- " // The negative unary operator is buggy on OSX.\n"
- " // Work around this by using abs instead.\n"
- " scale = 1.0 / (1 << abs(exponent));\n"
- " }\n"
- " else\n"
- " {\n"
- " scale = 1 << exponent;\n"
- " }\n"
- " float decimal = 1.0 + float(mantissa) / float(1 << 10);\n"
- " f32 = scale * decimal;\n"
- " }\n"
- "\n"
- " if (sign != 0u)\n"
- " {\n"
- " f32 = -f32;\n"
- " }\n"
- "\n"
- " return f32;\n"
- " }\n"
- "#endif\n"
- "\n"
- "vec2 unpackHalf2x16_emu(uint u)\n"
- "{\n"
- " #if defined(GL_ARB_shading_language_packing)\n"
- " return unpackHalf2x16(u);\n"
- " #else\n"
- " uint y = (u >> 16);\n"
- " uint x = u & 0xFFFFu;\n"
- " return vec2(f16tof32(x), f16tof32(y));\n"
- " #endif\n"
- "}\n");
- // clang-format on
- }
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorGLSL.h b/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorGLSL.h
deleted file mode 100644
index e1b4779bd5..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorGLSL.h
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATORGLSL_H_
-#define COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATORGLSL_H_
-
-#include "GLSLANG/ShaderLang.h"
-
-namespace sh
-{
-class BuiltInFunctionEmulator;
-
-//
-// This works around bug in Intel Mac drivers.
-//
-void InitBuiltInAbsFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator *emu,
- sh::GLenum shaderType);
-
-//
-// This works around isnan() bug in Intel Mac drivers
-//
-void InitBuiltInIsnanFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator *emu,
- int targetGLSLVersion);
-//
-// This works around atan(y, x) bug in NVIDIA drivers.
-//
-void InitBuiltInAtanFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator *emu);
-
-//
-// This function is emulating built-in functions missing from GLSL 1.30 and higher.
-//
-void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator *emu,
- sh::GLenum shaderType,
- int targetGLSLVersion);
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATORGLSL_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorHLSL.cpp b/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorHLSL.cpp
deleted file mode 100644
index e78d86d00a..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorHLSL.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-//
-// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "angle_gl.h"
-#include "compiler/translator/BuiltInFunctionEmulator.h"
-#include "compiler/translator/BuiltInFunctionEmulatorHLSL.h"
-#include "compiler/translator/SymbolTable.h"
-#include "compiler/translator/VersionGLSL.h"
-
-namespace sh
-{
-
-// Defined in emulated_builtin_functions_hlsl_autogen.cpp.
-const char *FindHLSLFunction(const FunctionId &functionID);
-
-void InitBuiltInIsnanFunctionEmulatorForHLSLWorkarounds(BuiltInFunctionEmulator *emu,
- int targetGLSLVersion)
-{
- if (targetGLSLVersion < GLSL_VERSION_130)
- return;
-
- TType *float1 = new TType(EbtFloat);
- TType *float2 = new TType(EbtFloat, 2);
- TType *float3 = new TType(EbtFloat, 3);
- TType *float4 = new TType(EbtFloat, 4);
-
- emu->addEmulatedFunction(EOpIsNan, float1,
- "bool isnan_emu(float x)\n"
- "{\n"
- " return (x > 0.0 || x < 0.0) ? false : x != 0.0;\n"
- "}\n"
- "\n");
-
- emu->addEmulatedFunction(
- EOpIsNan, float2,
- "bool2 isnan_emu(float2 x)\n"
- "{\n"
- " bool2 isnan;\n"
- " for (int i = 0; i < 2; i++)\n"
- " {\n"
- " isnan[i] = (x[i] > 0.0 || x[i] < 0.0) ? false : x[i] != 0.0;\n"
- " }\n"
- " return isnan;\n"
- "}\n");
-
- emu->addEmulatedFunction(
- EOpIsNan, float3,
- "bool3 isnan_emu(float3 x)\n"
- "{\n"
- " bool3 isnan;\n"
- " for (int i = 0; i < 3; i++)\n"
- " {\n"
- " isnan[i] = (x[i] > 0.0 || x[i] < 0.0) ? false : x[i] != 0.0;\n"
- " }\n"
- " return isnan;\n"
- "}\n");
-
- emu->addEmulatedFunction(
- EOpIsNan, float4,
- "bool4 isnan_emu(float4 x)\n"
- "{\n"
- " bool4 isnan;\n"
- " for (int i = 0; i < 4; i++)\n"
- " {\n"
- " isnan[i] = (x[i] > 0.0 || x[i] < 0.0) ? false : x[i] != 0.0;\n"
- " }\n"
- " return isnan;\n"
- "}\n");
-}
-
-void InitBuiltInFunctionEmulatorForHLSL(BuiltInFunctionEmulator *emu)
-{
- 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 *uint2 = new TType(EbtUInt, 2);
- TType *uint3 = new TType(EbtUInt, 3);
- TType *uint4 = new TType(EbtUInt, 4);
-
- emu->addFunctionMap(FindHLSLFunction);
-
- // (a + b2^16) * (c + d2^16) = ac + (ad + bc) * 2^16 + bd * 2^32
- // Also note that below, a * d + ((a * c) >> 16) is guaranteed not to overflow, because:
- // a <= 0xffff, d <= 0xffff, ((a * c) >> 16) <= 0xffff and 0xffff * 0xffff + 0xffff = 0xffff0000
- FunctionId umulExtendedUint1 = emu->addEmulatedFunction(
- EOpUmulExtended, uint1, uint1, uint1, uint1,
- "void umulExtended_emu(uint x, uint y, out uint msb, out uint lsb)\n"
- "{\n"
- " lsb = x * y;\n"
- " uint a = (x & 0xffffu);\n"
- " uint b = (x >> 16);\n"
- " uint c = (y & 0xffffu);\n"
- " uint d = (y >> 16);\n"
- " uint ad = a * d + ((a * c) >> 16);\n"
- " uint bc = b * c;\n"
- " uint carry = uint(ad > (0xffffffffu - bc));\n"
- " msb = ((ad + bc) >> 16) + (carry << 16) + b * d;\n"
- "}\n");
- emu->addEmulatedFunctionWithDependency(
- umulExtendedUint1, EOpUmulExtended, uint2, uint2, uint2, uint2,
- "void umulExtended_emu(uint2 x, uint2 y, out uint2 msb, out uint2 lsb)\n"
- "{\n"
- " umulExtended_emu(x.x, y.x, msb.x, lsb.x);\n"
- " umulExtended_emu(x.y, y.y, msb.y, lsb.y);\n"
- "}\n");
- emu->addEmulatedFunctionWithDependency(
- umulExtendedUint1, EOpUmulExtended, uint3, uint3, uint3, uint3,
- "void umulExtended_emu(uint3 x, uint3 y, out uint3 msb, out uint3 lsb)\n"
- "{\n"
- " umulExtended_emu(x.x, y.x, msb.x, lsb.x);\n"
- " umulExtended_emu(x.y, y.y, msb.y, lsb.y);\n"
- " umulExtended_emu(x.z, y.z, msb.z, lsb.z);\n"
- "}\n");
- emu->addEmulatedFunctionWithDependency(
- umulExtendedUint1, EOpUmulExtended, uint4, uint4, uint4, uint4,
- "void umulExtended_emu(uint4 x, uint4 y, out uint4 msb, out uint4 lsb)\n"
- "{\n"
- " umulExtended_emu(x.x, y.x, msb.x, lsb.x);\n"
- " umulExtended_emu(x.y, y.y, msb.y, lsb.y);\n"
- " umulExtended_emu(x.z, y.z, msb.z, lsb.z);\n"
- " umulExtended_emu(x.w, y.w, msb.w, lsb.w);\n"
- "}\n");
-
- // The imul emulation does two's complement negation on the lsb and msb manually in case the
- // result needs to be negative.
- // TODO(oetuaho): Note that this code doesn't take one edge case into account, where x or y is
- // -2^31. abs(-2^31) is undefined.
- FunctionId imulExtendedInt1 = emu->addEmulatedFunctionWithDependency(
- umulExtendedUint1, EOpImulExtended, int1, int1, int1, int1,
- "void imulExtended_emu(int x, int y, out int msb, out int lsb)\n"
- "{\n"
- " uint unsignedMsb;\n"
- " uint unsignedLsb;\n"
- " bool negative = (x < 0) != (y < 0);\n"
- " umulExtended_emu(uint(abs(x)), uint(abs(y)), unsignedMsb, unsignedLsb);\n"
- " lsb = asint(unsignedLsb);\n"
- " msb = asint(unsignedMsb);\n"
- " if (negative)\n"
- " {\n"
- " lsb = ~lsb;\n"
- " msb = ~msb;\n"
- " if (lsb == 0xffffffff)\n"
- " {\n"
- " lsb = 0;\n"
- " msb += 1;\n"
- " }\n"
- " else\n"
- " {\n"
- " lsb += 1;\n"
- " }\n"
- " }\n"
- "}\n");
- emu->addEmulatedFunctionWithDependency(
- imulExtendedInt1, EOpImulExtended, int2, int2, int2, int2,
- "void imulExtended_emu(int2 x, int2 y, out int2 msb, out int2 lsb)\n"
- "{\n"
- " imulExtended_emu(x.x, y.x, msb.x, lsb.x);\n"
- " imulExtended_emu(x.y, y.y, msb.y, lsb.y);\n"
- "}\n");
- emu->addEmulatedFunctionWithDependency(
- imulExtendedInt1, EOpImulExtended, int3, int3, int3, int3,
- "void imulExtended_emu(int3 x, int3 y, out int3 msb, out int3 lsb)\n"
- "{\n"
- " imulExtended_emu(x.x, y.x, msb.x, lsb.x);\n"
- " imulExtended_emu(x.y, y.y, msb.y, lsb.y);\n"
- " imulExtended_emu(x.z, y.z, msb.z, lsb.z);\n"
- "}\n");
- emu->addEmulatedFunctionWithDependency(
- imulExtendedInt1, EOpImulExtended, int4, int4, int4, int4,
- "void imulExtended_emu(int4 x, int4 y, out int4 msb, out int4 lsb)\n"
- "{\n"
- " imulExtended_emu(x.x, y.x, msb.x, lsb.x);\n"
- " imulExtended_emu(x.y, y.y, msb.y, lsb.y);\n"
- " imulExtended_emu(x.z, y.z, msb.z, lsb.z);\n"
- " imulExtended_emu(x.w, y.w, msb.w, lsb.w);\n"
- "}\n");
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorHLSL.h b/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorHLSL.h
deleted file mode 100644
index 48da73f58e..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulatorHLSL.h
+++ /dev/null
@@ -1,27 +0,0 @@
-//
-// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATORHLSL_H_
-#define COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATORHLSL_H_
-
-#include "GLSLANG/ShaderLang.h"
-
-namespace sh
-{
-
-class BuiltInFunctionEmulator;
-
-void InitBuiltInFunctionEmulatorForHLSL(BuiltInFunctionEmulator *emu);
-
-//
-// This works around isnan() bug on some Intel drivers.
-//
-void InitBuiltInIsnanFunctionEmulatorForHLSLWorkarounds(BuiltInFunctionEmulator *emu,
- int targetGLSLVersion);
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_BUILTINFUNCTIONEMULATORHLSL_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/Cache.cpp b/src/3rdparty/angle/src/compiler/translator/Cache.cpp
deleted file mode 100644
index 417e82403a..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/Cache.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-//
-// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// Cache.cpp: Implements a cache for various commonly created objects.
-
-#include <limits>
-
-#include "common/angleutils.h"
-#include "common/debug.h"
-#include "compiler/translator/Cache.h"
-
-namespace sh
-{
-
-namespace
-{
-
-class TScopedAllocator : angle::NonCopyable
-{
- public:
- TScopedAllocator(TPoolAllocator *allocator) : mPreviousAllocator(GetGlobalPoolAllocator())
- {
- SetGlobalPoolAllocator(allocator);
- }
- ~TScopedAllocator() { SetGlobalPoolAllocator(mPreviousAllocator); }
-
- private:
- TPoolAllocator *mPreviousAllocator;
-};
-
-} // namespace
-
-TCache::TypeKey::TypeKey(TBasicType basicType,
- TPrecision precision,
- TQualifier qualifier,
- unsigned char primarySize,
- unsigned char secondarySize)
-{
- static_assert(sizeof(components) <= sizeof(value), "TypeKey::value is too small");
-
- const size_t MaxEnumValue = std::numeric_limits<EnumComponentType>::max();
-
- // TODO: change to static_assert() once we deprecate MSVC 2013 support
- ASSERT(MaxEnumValue >= EbtLast && MaxEnumValue >= EbpLast && MaxEnumValue >= EvqLast &&
- "TypeKey::EnumComponentType is too small");
-
- value = 0;
- components.basicType = static_cast<EnumComponentType>(basicType);
- components.precision = static_cast<EnumComponentType>(precision);
- components.qualifier = static_cast<EnumComponentType>(qualifier);
- components.primarySize = primarySize;
- components.secondarySize = secondarySize;
-}
-
-TCache *TCache::sCache = nullptr;
-
-TCache::TCache()
-{
-}
-
-void TCache::initialize()
-{
- if (sCache == nullptr)
- {
- sCache = new TCache();
- }
-}
-
-void TCache::destroy()
-{
- SafeDelete(sCache);
-}
-
-const TType *TCache::getType(TBasicType basicType,
- TPrecision precision,
- TQualifier qualifier,
- unsigned char primarySize,
- unsigned char secondarySize)
-{
- TypeKey key(basicType, precision, qualifier, primarySize, secondarySize);
- auto it = sCache->mTypes.find(key);
- if (it != sCache->mTypes.end())
- {
- return it->second;
- }
-
- TScopedAllocator scopedAllocator(&sCache->mAllocator);
-
- TType *type = new TType(basicType, precision, qualifier, primarySize, secondarySize);
- type->realize();
- sCache->mTypes.insert(std::make_pair(key, type));
-
- return type;
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/Cache.h b/src/3rdparty/angle/src/compiler/translator/Cache.h
deleted file mode 100644
index a182b07f51..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/Cache.h
+++ /dev/null
@@ -1,84 +0,0 @@
-//
-// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// Cache.h: Implements a cache for various commonly created objects.
-
-#ifndef COMPILER_TRANSLATOR_CACHE_H_
-#define COMPILER_TRANSLATOR_CACHE_H_
-
-#include <stdint.h>
-#include <string.h>
-#include <map>
-
-#include "compiler/translator/Types.h"
-#include "compiler/translator/PoolAlloc.h"
-
-namespace sh
-{
-
-class TCache
-{
- public:
- static void initialize();
- static void destroy();
-
- static const TType *getType(TBasicType basicType, TPrecision precision)
- {
- return getType(basicType, precision, EvqTemporary, 1, 1);
- }
- static const TType *getType(TBasicType basicType,
- unsigned char primarySize = 1,
- unsigned char secondarySize = 1)
- {
- return getType(basicType, EbpUndefined, EvqGlobal, primarySize, secondarySize);
- }
- static const TType *getType(TBasicType basicType,
- TQualifier qualifier,
- unsigned char primarySize = 1,
- unsigned char secondarySize = 1)
- {
- return getType(basicType, EbpUndefined, qualifier, primarySize, secondarySize);
- }
- static const TType *getType(TBasicType basicType,
- TPrecision precision,
- TQualifier qualifier,
- unsigned char primarySize,
- unsigned char secondarySize);
-
- private:
- TCache();
-
- union TypeKey {
- TypeKey(TBasicType basicType,
- TPrecision precision,
- TQualifier qualifier,
- unsigned char primarySize,
- unsigned char secondarySize);
-
- typedef uint8_t EnumComponentType;
- struct
- {
- EnumComponentType basicType;
- EnumComponentType precision;
- EnumComponentType qualifier;
- unsigned char primarySize;
- unsigned char secondarySize;
- } components;
- uint64_t value;
-
- bool operator<(const TypeKey &other) const { return value < other.value; }
- };
- typedef std::map<TypeKey, const TType *> TypeMap;
-
- TypeMap mTypes;
- TPoolAllocator mAllocator;
-
- static TCache *sCache;
-};
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_CACHE_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/CallDAG.cpp b/src/3rdparty/angle/src/compiler/translator/CallDAG.cpp
deleted file mode 100644
index 5f54e80898..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/CallDAG.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-//
-// Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// CallDAG.h: Implements a call graph DAG of functions to be re-used accross
-// analyses, allows to efficiently traverse the functions in topological
-// order.
-
-#include "compiler/translator/CallDAG.h"
-
-#include "compiler/translator/Diagnostics.h"
-#include "compiler/translator/IntermTraverse.h"
-#include "compiler/translator/SymbolTable.h"
-
-namespace sh
-{
-
-// The CallDAGCreator does all the processing required to create the CallDAG
-// structure so that the latter contains only the necessary variables.
-class CallDAG::CallDAGCreator : public TIntermTraverser
-{
- public:
- CallDAGCreator(TDiagnostics *diagnostics)
- : TIntermTraverser(true, false, true),
- mDiagnostics(diagnostics),
- mCurrentFunction(nullptr),
- mCurrentIndex(0)
- {
- }
-
- InitResult assignIndices()
- {
- int skipped = 0;
- for (auto &it : mFunctions)
- {
- // Skip unimplemented functions
- if (it.second.node)
- {
- InitResult result = assignIndicesInternal(&it.second);
- if (result != INITDAG_SUCCESS)
- {
- return result;
- }
- }
- else
- {
- skipped++;
- }
- }
-
- ASSERT(mFunctions.size() == mCurrentIndex + skipped);
- return INITDAG_SUCCESS;
- }
-
- void fillDataStructures(std::vector<Record> *records, std::map<int, int> *idToIndex)
- {
- ASSERT(records->empty());
- ASSERT(idToIndex->empty());
-
- records->resize(mCurrentIndex);
-
- for (auto &it : mFunctions)
- {
- CreatorFunctionData &data = it.second;
- // Skip unimplemented functions
- if (!data.node)
- {
- continue;
- }
- ASSERT(data.index < records->size());
- Record &record = (*records)[data.index];
-
- record.name = data.name.data();
- record.node = data.node;
-
- record.callees.reserve(data.callees.size());
- for (auto &callee : data.callees)
- {
- record.callees.push_back(static_cast<int>(callee->index));
- }
-
- (*idToIndex)[data.node->getFunctionSymbolInfo()->getId().get()] =
- static_cast<int>(data.index);
- }
- }
-
- private:
- struct CreatorFunctionData
- {
- CreatorFunctionData() : node(nullptr), index(0), indexAssigned(false), visiting(false) {}
-
- std::set<CreatorFunctionData *> callees;
- TIntermFunctionDefinition *node;
- TString name;
- size_t index;
- bool indexAssigned;
- bool visiting;
- };
-
- bool visitFunctionDefinition(Visit visit, TIntermFunctionDefinition *node) override
- {
- // Create the record if need be and remember the node.
- if (visit == PreVisit)
- {
- auto it = mFunctions.find(node->getFunctionSymbolInfo()->getId().get());
-
- if (it == mFunctions.end())
- {
- mCurrentFunction = &mFunctions[node->getFunctionSymbolInfo()->getId().get()];
- mCurrentFunction->name = node->getFunctionSymbolInfo()->getName();
- }
- else
- {
- mCurrentFunction = &it->second;
- ASSERT(mCurrentFunction->name == node->getFunctionSymbolInfo()->getName());
- }
-
- mCurrentFunction->node = node;
- }
- else if (visit == PostVisit)
- {
- mCurrentFunction = nullptr;
- }
- return true;
- }
-
- bool visitFunctionPrototype(Visit visit, TIntermFunctionPrototype *node) override
- {
- ASSERT(visit == PreVisit);
- if (mCurrentFunction != nullptr)
- {
- return false;
- }
-
- // Function declaration, create an empty record.
- auto &record = mFunctions[node->getFunctionSymbolInfo()->getId().get()];
- record.name = node->getFunctionSymbolInfo()->getName();
-
- // No need to traverse the parameters.
- return false;
- }
-
- // Aggregates the AST node for each function as well as the name of the functions called by it
- bool visitAggregate(Visit visit, TIntermAggregate *node) override
- {
- if (visit == PreVisit && node->getOp() == EOpCallFunctionInAST)
- {
- // Function call, add the callees
- auto it = mFunctions.find(node->getFunctionSymbolInfo()->getId().get());
- ASSERT(it != mFunctions.end());
-
- // We might be traversing the initializer of a global variable. Even though function
- // calls in global scope are forbidden by the parser, some subsequent AST
- // transformations can add them to emulate particular features.
- if (mCurrentFunction)
- {
- mCurrentFunction->callees.insert(&it->second);
- }
- }
- return true;
- }
-
- // Recursively assigns indices to a sub DAG
- InitResult assignIndicesInternal(CreatorFunctionData *root)
- {
- // Iterative implementation of the index assignment algorithm. A recursive version
- // would be prettier but since the CallDAG creation runs before the limiting of the
- // call depth, we might get stack overflows (computation of the call depth uses the
- // CallDAG).
-
- ASSERT(root);
-
- if (root->indexAssigned)
- {
- return INITDAG_SUCCESS;
- }
-
- // If we didn't have to detect recursion, functionsToProcess could be a simple queue
- // in which we add the function being processed's callees. However in order to detect
- // recursion we need to know which functions we are currently visiting. For that reason
- // functionsToProcess will look like a concatenation of segments of the form
- // [F visiting = true, subset of F callees with visiting = false] and the following
- // segment (if any) will be start with a callee of F.
- // This way we can remember when we started visiting a function, to put visiting back
- // to false.
- TVector<CreatorFunctionData *> functionsToProcess;
- functionsToProcess.push_back(root);
-
- InitResult result = INITDAG_SUCCESS;
-
- std::stringstream errorStream;
-
- while (!functionsToProcess.empty())
- {
- CreatorFunctionData *function = functionsToProcess.back();
-
- if (function->visiting)
- {
- function->visiting = false;
- function->index = mCurrentIndex++;
- function->indexAssigned = true;
-
- functionsToProcess.pop_back();
- continue;
- }
-
- if (!function->node)
- {
- errorStream << "Undefined function '" << function->name
- << ")' used in the following call chain:";
- result = INITDAG_UNDEFINED;
- break;
- }
-
- if (function->indexAssigned)
- {
- functionsToProcess.pop_back();
- continue;
- }
-
- function->visiting = true;
-
- for (auto callee : function->callees)
- {
- functionsToProcess.push_back(callee);
-
- // Check if the callee is already being visited after pushing it so that it appears
- // in the chain printed in the info log.
- if (callee->visiting)
- {
- errorStream << "Recursive function call in the following call chain:";
- result = INITDAG_RECURSION;
- break;
- }
- }
-
- if (result != INITDAG_SUCCESS)
- {
- break;
- }
- }
-
- // The call chain is made of the function we were visiting when the error was detected.
- if (result != INITDAG_SUCCESS)
- {
- bool first = true;
- for (auto function : functionsToProcess)
- {
- if (function->visiting)
- {
- if (!first)
- {
- errorStream << " -> ";
- }
- errorStream << function->name << ")";
- first = false;
- }
- }
- if (mDiagnostics)
- {
- std::string errorStr = errorStream.str();
- mDiagnostics->globalError(errorStr.c_str());
- }
- }
-
- return result;
- }
-
- TDiagnostics *mDiagnostics;
-
- std::map<int, CreatorFunctionData> mFunctions;
- CreatorFunctionData *mCurrentFunction;
- size_t mCurrentIndex;
-};
-
-// CallDAG
-
-CallDAG::CallDAG()
-{
-}
-
-CallDAG::~CallDAG()
-{
-}
-
-const size_t CallDAG::InvalidIndex = std::numeric_limits<size_t>::max();
-
-size_t CallDAG::findIndex(const TFunctionSymbolInfo *functionInfo) const
-{
- auto it = mFunctionIdToIndex.find(functionInfo->getId().get());
-
- if (it == mFunctionIdToIndex.end())
- {
- return InvalidIndex;
- }
- else
- {
- return it->second;
- }
-}
-
-const CallDAG::Record &CallDAG::getRecordFromIndex(size_t index) const
-{
- ASSERT(index != InvalidIndex && index < mRecords.size());
- return mRecords[index];
-}
-
-const CallDAG::Record &CallDAG::getRecord(const TIntermAggregate *function) const
-{
- size_t index = findIndex(function->getFunctionSymbolInfo());
- ASSERT(index != InvalidIndex && index < mRecords.size());
- return mRecords[index];
-}
-
-size_t CallDAG::size() const
-{
- return mRecords.size();
-}
-
-void CallDAG::clear()
-{
- mRecords.clear();
- mFunctionIdToIndex.clear();
-}
-
-CallDAG::InitResult CallDAG::init(TIntermNode *root, TDiagnostics *diagnostics)
-{
- CallDAGCreator creator(diagnostics);
-
- // Creates the mapping of functions to callees
- root->traverse(&creator);
-
- // Does the topological sort and detects recursions
- InitResult result = creator.assignIndices();
- if (result != INITDAG_SUCCESS)
- {
- return result;
- }
-
- creator.fillDataStructures(&mRecords, &mFunctionIdToIndex);
- return INITDAG_SUCCESS;
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/CallDAG.h b/src/3rdparty/angle/src/compiler/translator/CallDAG.h
deleted file mode 100644
index 155081c9a2..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/CallDAG.h
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// CallDAG.h: Defines a call graph DAG of functions to be re-used accross
-// analyses, allows to efficiently traverse the functions in topological
-// order.
-
-#ifndef COMPILER_TRANSLATOR_CALLDAG_H_
-#define COMPILER_TRANSLATOR_CALLDAG_H_
-
-#include <map>
-
-#include "compiler/translator/IntermNode.h"
-
-namespace sh
-{
-
-// The translator needs to analyze the the graph of the function calls
-// to run checks and analyses; since in GLSL recursion is not allowed
-// that graph is a DAG.
-// This class is used to precompute that function call DAG so that it
-// can be reused by multiple analyses.
-//
-// It stores a vector of function records, with one record per function.
-// Records are accessed by index but a function symbol id can be converted
-// to the index of the corresponding record. The records mostly contain the
-// AST node of the function and the indices of the function's callees.
-//
-// In addition, records are in reverse topological order: a function F being
-// called by a function G will have index index(F) < index(G), that way
-// depth-first analysis becomes analysis in the order of indices.
-
-class CallDAG : angle::NonCopyable
-{
- public:
- CallDAG();
- ~CallDAG();
-
- struct Record
- {
- std::string name;
- TIntermFunctionDefinition *node;
- std::vector<int> callees;
- };
-
- enum InitResult
- {
- INITDAG_SUCCESS,
- INITDAG_RECURSION,
- INITDAG_UNDEFINED,
- };
-
- // Returns INITDAG_SUCCESS if it was able to create the DAG, otherwise prints
- // the initialization error in diagnostics, if present.
- InitResult init(TIntermNode *root, TDiagnostics *diagnostics);
-
- // Returns InvalidIndex if the function wasn't found
- size_t findIndex(const TFunctionSymbolInfo *functionInfo) const;
-
- const Record &getRecordFromIndex(size_t index) const;
- const Record &getRecord(const TIntermAggregate *function) const;
- size_t size() const;
- void clear();
-
- const static size_t InvalidIndex;
-
- private:
- std::vector<Record> mRecords;
- std::map<int, int> mFunctionIdToIndex;
-
- class CallDAGCreator;
-};
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_CALLDAG_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/ClampPointSize.cpp b/src/3rdparty/angle/src/compiler/translator/ClampPointSize.cpp
deleted file mode 100644
index 8598a137f5..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ClampPointSize.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// Copyright (c) 2017 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// ClampPointSize.cpp: Limit the value that is written to gl_PointSize.
-//
-
-#include "compiler/translator/ClampPointSize.h"
-
-#include "compiler/translator/FindSymbolNode.h"
-#include "compiler/translator/IntermNode_util.h"
-#include "compiler/translator/RunAtTheEndOfShader.h"
-#include "compiler/translator/SymbolTable.h"
-
-namespace sh
-{
-
-void ClampPointSize(TIntermBlock *root, float maxPointSize, TSymbolTable *symbolTable)
-{
- // Only clamp gl_PointSize if it's used in the shader.
- if (!FindSymbolNode(root, TString("gl_PointSize"), EbtFloat))
- {
- return;
- }
-
- TIntermSymbol *pointSizeNode = ReferenceBuiltInVariable("gl_PointSize", *symbolTable, 100);
-
- TConstantUnion *maxPointSizeConstant = new TConstantUnion();
- maxPointSizeConstant->setFConst(maxPointSize);
- TIntermConstantUnion *maxPointSizeNode =
- new TIntermConstantUnion(maxPointSizeConstant, TType(EbtFloat, EbpHigh, EvqConst));
-
- // min(gl_PointSize, maxPointSize)
- TIntermSequence *minArguments = new TIntermSequence();
- minArguments->push_back(pointSizeNode->deepCopy());
- minArguments->push_back(maxPointSizeNode);
- TIntermTyped *clampedPointSize =
- CreateBuiltInFunctionCallNode("min", minArguments, *symbolTable, 100);
-
- // gl_PointSize = min(gl_PointSize, maxPointSize)
- TIntermBinary *assignPointSize = new TIntermBinary(EOpAssign, pointSizeNode, clampedPointSize);
-
- RunAtTheEndOfShader(root, assignPointSize, symbolTable);
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/ClampPointSize.h b/src/3rdparty/angle/src/compiler/translator/ClampPointSize.h
deleted file mode 100644
index 0c71ae6b0d..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ClampPointSize.h
+++ /dev/null
@@ -1,22 +0,0 @@
-//
-// Copyright (c) 2017 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// ClampPointSize.h: Limit the value that is written to gl_PointSize.
-//
-
-#ifndef COMPILER_TRANSLATOR_CLAMPPOINTSIZE_H_
-#define COMPILER_TRANSLATOR_CLAMPPOINTSIZE_H_
-
-namespace sh
-{
-
-class TIntermBlock;
-class TSymbolTable;
-
-void ClampPointSize(TIntermBlock *root, float maxPointSize, TSymbolTable *symbolTable);
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_CLAMPPOINTSIZE_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/CodeGen.cpp b/src/3rdparty/angle/src/compiler/translator/CodeGen.cpp
deleted file mode 100644
index 3e25cc2339..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/CodeGen.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifdef ANGLE_ENABLE_ESSL
-#include "compiler/translator/TranslatorESSL.h"
-#endif // ANGLE_ENABLE_ESSL
-
-#ifdef ANGLE_ENABLE_GLSL
-#include "compiler/translator/TranslatorGLSL.h"
-#endif // ANGLE_ENABLE_GLSL
-
-#ifdef ANGLE_ENABLE_HLSL
-#include "compiler/translator/TranslatorHLSL.h"
-#endif // ANGLE_ENABLE_HLSL
-
-#ifdef ANGLE_ENABLE_VULKAN
-#include "compiler/translator/TranslatorVulkan.h"
-#endif // ANGLE_ENABLE_VULKAN
-
-#include "compiler/translator/util.h"
-
-namespace sh
-{
-
-//
-// This function must be provided to create the actual
-// compile object used by higher level code. It returns
-// a subclass of TCompiler.
-//
-TCompiler *ConstructCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
-{
-#ifdef ANGLE_ENABLE_ESSL
- if (IsOutputESSL(output))
- {
- return new TranslatorESSL(type, spec);
- }
-#endif // ANGLE_ENABLE_ESSL
-
-#ifdef ANGLE_ENABLE_GLSL
- if (IsOutputGLSL(output))
- {
- return new TranslatorGLSL(type, spec, output);
- }
-#endif // ANGLE_ENABLE_GLSL
-
-#ifdef ANGLE_ENABLE_HLSL
- if (IsOutputHLSL(output))
- {
- return new TranslatorHLSL(type, spec, output);
- }
-#endif // ANGLE_ENABLE_HLSL
-
-#ifdef ANGLE_ENABLE_VULKAN
- if (IsOutputVulkan(output))
- {
- return new TranslatorVulkan(type, spec);
- }
-#endif // ANGLE_ENABLE_VULKAN
-
- // Unsupported compiler or unknown format. Return nullptr per the sh::ConstructCompiler API.
- return nullptr;
-}
-
-//
-// Delete the compiler made by ConstructCompiler
-//
-void DeleteCompiler(TCompiler *compiler)
-{
- SafeDelete(compiler);
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/CollectVariables.cpp b/src/3rdparty/angle/src/compiler/translator/CollectVariables.cpp
deleted file mode 100644
index bd8cbc971a..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/CollectVariables.cpp
+++ /dev/null
@@ -1,869 +0,0 @@
-//
-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// CollectVariables.cpp: Collect lists of shader interface variables based on the AST.
-
-#include "compiler/translator/CollectVariables.h"
-
-#include "angle_gl.h"
-#include "common/utilities.h"
-#include "compiler/translator/HashNames.h"
-#include "compiler/translator/IntermTraverse.h"
-#include "compiler/translator/SymbolTable.h"
-#include "compiler/translator/util.h"
-
-namespace sh
-{
-
-namespace
-{
-
-BlockLayoutType GetBlockLayoutType(TLayoutBlockStorage blockStorage)
-{
- switch (blockStorage)
- {
- case EbsPacked:
- return BLOCKLAYOUT_PACKED;
- case EbsShared:
- return BLOCKLAYOUT_SHARED;
- case EbsStd140:
- return BLOCKLAYOUT_STD140;
- case EbsStd430:
- return BLOCKLAYOUT_STD430;
- default:
- UNREACHABLE();
- return BLOCKLAYOUT_SHARED;
- }
-}
-
-// TODO(jiawei.shao@intel.com): implement GL_OES_shader_io_blocks.
-BlockType GetBlockType(TQualifier qualifier)
-{
- switch (qualifier)
- {
- case EvqUniform:
- return BlockType::BLOCK_UNIFORM;
- case EvqBuffer:
- return BlockType::BLOCK_BUFFER;
- case EvqPerVertexIn:
- return BlockType::BLOCK_IN;
- default:
- UNREACHABLE();
- return BlockType::BLOCK_UNIFORM;
- }
-}
-
-template <class VarT>
-VarT *FindVariable(const TString &name, std::vector<VarT> *infoList)
-{
- // TODO(zmo): optimize this function.
- for (size_t ii = 0; ii < infoList->size(); ++ii)
- {
- if ((*infoList)[ii].name.c_str() == name)
- return &((*infoList)[ii]);
- }
-
- return nullptr;
-}
-
-// Note that this shouldn't be called for interface blocks - static use information is collected for
-// individual fields in case of interface blocks.
-void MarkStaticallyUsed(ShaderVariable *variable)
-{
- if (!variable->staticUse)
- {
- if (variable->isStruct())
- {
- // Conservatively assume all fields are statically used as well.
- for (auto &field : variable->fields)
- {
- MarkStaticallyUsed(&field);
- }
- }
- variable->staticUse = true;
- }
-}
-
-ShaderVariable *FindVariableInInterfaceBlock(const TString &name,
- const TInterfaceBlock *interfaceBlock,
- std::vector<InterfaceBlock> *infoList)
-{
- ASSERT(interfaceBlock);
- InterfaceBlock *namedBlock = FindVariable(interfaceBlock->name(), infoList);
- ASSERT(namedBlock);
-
- // Set static use on the parent interface block here
- namedBlock->staticUse = true;
- return FindVariable(name, &namedBlock->fields);
-}
-
-// Traverses the intermediate tree to collect all attributes, uniforms, varyings, fragment outputs,
-// and interface blocks.
-class CollectVariablesTraverser : public TIntermTraverser
-{
- public:
- CollectVariablesTraverser(std::vector<Attribute> *attribs,
- std::vector<OutputVariable> *outputVariables,
- std::vector<Uniform> *uniforms,
- std::vector<Varying> *inputVaryings,
- std::vector<Varying> *outputVaryings,
- std::vector<InterfaceBlock> *uniformBlocks,
- std::vector<InterfaceBlock> *shaderStorageBlocks,
- std::vector<InterfaceBlock> *inBlocks,
- ShHashFunction64 hashFunction,
- TSymbolTable *symbolTable,
- int shaderVersion,
- GLenum shaderType,
- const TExtensionBehavior &extensionBehavior);
-
- void visitSymbol(TIntermSymbol *symbol) override;
- bool visitDeclaration(Visit, TIntermDeclaration *node) override;
- bool visitBinary(Visit visit, TIntermBinary *binaryNode) override;
-
- private:
- std::string getMappedName(const TName &name) const;
-
- void setCommonVariableProperties(const TType &type,
- const TName &name,
- ShaderVariable *variableOut) const;
-
- Attribute recordAttribute(const TIntermSymbol &variable) const;
- OutputVariable recordOutputVariable(const TIntermSymbol &variable) const;
- Varying recordVarying(const TIntermSymbol &variable) const;
- void recordInterfaceBlock(const TType &interfaceBlockType,
- InterfaceBlock *interfaceBlock) const;
- Uniform recordUniform(const TIntermSymbol &variable) const;
-
- void setBuiltInInfoFromSymbolTable(const char *name, ShaderVariable *info);
-
- void recordBuiltInVaryingUsed(const char *name,
- bool *addedFlag,
- std::vector<Varying> *varyings);
- void recordBuiltInFragmentOutputUsed(const char *name, bool *addedFlag);
- void recordBuiltInAttributeUsed(const char *name, bool *addedFlag);
- InterfaceBlock *recordGLInUsed(const TType &glInType);
- InterfaceBlock *findNamedInterfaceBlock(const TString &name) const;
-
- std::vector<Attribute> *mAttribs;
- std::vector<OutputVariable> *mOutputVariables;
- std::vector<Uniform> *mUniforms;
- std::vector<Varying> *mInputVaryings;
- std::vector<Varying> *mOutputVaryings;
- std::vector<InterfaceBlock> *mUniformBlocks;
- std::vector<InterfaceBlock> *mShaderStorageBlocks;
- std::vector<InterfaceBlock> *mInBlocks;
-
- std::map<std::string, InterfaceBlockField *> mInterfaceBlockFields;
-
- // Shader uniforms
- bool mDepthRangeAdded;
-
- // Vertex Shader builtins
- bool mInstanceIDAdded;
- bool mVertexIDAdded;
- bool mPointSizeAdded;
-
- // Vertex Shader and Geometry Shader builtins
- bool mPositionAdded;
-
- // Fragment Shader builtins
- bool mPointCoordAdded;
- bool mFrontFacingAdded;
- bool mFragCoordAdded;
- bool mLastFragDataAdded;
- bool mFragColorAdded;
- bool mFragDataAdded;
- bool mFragDepthEXTAdded;
- bool mFragDepthAdded;
- bool mSecondaryFragColorEXTAdded;
- bool mSecondaryFragDataEXTAdded;
-
- // Geometry Shader builtins
- bool mPerVertexInAdded;
- bool mPrimitiveIDInAdded;
- bool mInvocationIDAdded;
-
- // Geometry Shader and Fragment Shader builtins
- bool mPrimitiveIDAdded;
- bool mLayerAdded;
-
- ShHashFunction64 mHashFunction;
-
- int mShaderVersion;
- GLenum mShaderType;
- const TExtensionBehavior &mExtensionBehavior;
-};
-
-CollectVariablesTraverser::CollectVariablesTraverser(
- std::vector<sh::Attribute> *attribs,
- std::vector<sh::OutputVariable> *outputVariables,
- std::vector<sh::Uniform> *uniforms,
- std::vector<sh::Varying> *inputVaryings,
- std::vector<sh::Varying> *outputVaryings,
- std::vector<sh::InterfaceBlock> *uniformBlocks,
- std::vector<sh::InterfaceBlock> *shaderStorageBlocks,
- std::vector<sh::InterfaceBlock> *inBlocks,
- ShHashFunction64 hashFunction,
- TSymbolTable *symbolTable,
- int shaderVersion,
- GLenum shaderType,
- const TExtensionBehavior &extensionBehavior)
- : TIntermTraverser(true, false, false, symbolTable),
- mAttribs(attribs),
- mOutputVariables(outputVariables),
- mUniforms(uniforms),
- mInputVaryings(inputVaryings),
- mOutputVaryings(outputVaryings),
- mUniformBlocks(uniformBlocks),
- mShaderStorageBlocks(shaderStorageBlocks),
- mInBlocks(inBlocks),
- mDepthRangeAdded(false),
- mInstanceIDAdded(false),
- mVertexIDAdded(false),
- mPointSizeAdded(false),
- mPositionAdded(false),
- mPointCoordAdded(false),
- mFrontFacingAdded(false),
- mFragCoordAdded(false),
- mLastFragDataAdded(false),
- mFragColorAdded(false),
- mFragDataAdded(false),
- mFragDepthEXTAdded(false),
- mFragDepthAdded(false),
- mSecondaryFragColorEXTAdded(false),
- mSecondaryFragDataEXTAdded(false),
- mPerVertexInAdded(false),
- mPrimitiveIDInAdded(false),
- mInvocationIDAdded(false),
- mPrimitiveIDAdded(false),
- mLayerAdded(false),
- mHashFunction(hashFunction),
- mShaderVersion(shaderVersion),
- mShaderType(shaderType),
- mExtensionBehavior(extensionBehavior)
-{
-}
-
-std::string CollectVariablesTraverser::getMappedName(const TName &name) const
-{
- return HashName(name, mHashFunction, nullptr).c_str();
-}
-
-void CollectVariablesTraverser::setBuiltInInfoFromSymbolTable(const char *name,
- ShaderVariable *info)
-{
- TVariable *symbolTableVar =
- reinterpret_cast<TVariable *>(mSymbolTable->findBuiltIn(name, mShaderVersion));
- ASSERT(symbolTableVar);
- const TType &type = symbolTableVar->getType();
-
- info->name = name;
- info->mappedName = name;
- info->type = GLVariableType(type);
- info->precision = GLVariablePrecision(type);
- if (auto *arraySizes = type.getArraySizes())
- {
- info->arraySizes.assign(arraySizes->begin(), arraySizes->end());
- }
-}
-
-void CollectVariablesTraverser::recordBuiltInVaryingUsed(const char *name,
- bool *addedFlag,
- std::vector<Varying> *varyings)
-{
- ASSERT(varyings);
- if (!(*addedFlag))
- {
- Varying info;
- setBuiltInInfoFromSymbolTable(name, &info);
- info.staticUse = true;
- info.isInvariant = mSymbolTable->isVaryingInvariant(name);
- varyings->push_back(info);
- (*addedFlag) = true;
- }
-}
-
-void CollectVariablesTraverser::recordBuiltInFragmentOutputUsed(const char *name, bool *addedFlag)
-{
- if (!(*addedFlag))
- {
- OutputVariable info;
- setBuiltInInfoFromSymbolTable(name, &info);
- info.staticUse = true;
- mOutputVariables->push_back(info);
- (*addedFlag) = true;
- }
-}
-
-void CollectVariablesTraverser::recordBuiltInAttributeUsed(const char *name, bool *addedFlag)
-{
- if (!(*addedFlag))
- {
- Attribute info;
- setBuiltInInfoFromSymbolTable(name, &info);
- info.staticUse = true;
- info.location = -1;
- mAttribs->push_back(info);
- (*addedFlag) = true;
- }
-}
-
-InterfaceBlock *CollectVariablesTraverser::recordGLInUsed(const TType &glInType)
-{
- if (!mPerVertexInAdded)
- {
- ASSERT(glInType.getQualifier() == EvqPerVertexIn);
- InterfaceBlock info;
- recordInterfaceBlock(glInType, &info);
- info.staticUse = true;
-
- mPerVertexInAdded = true;
- mInBlocks->push_back(info);
- return &mInBlocks->back();
- }
- else
- {
- return FindVariable("gl_PerVertex", mInBlocks);
- }
-}
-
-// We want to check whether a uniform/varying is statically used
-// because we only count the used ones in packing computing.
-// Also, gl_FragCoord, gl_PointCoord, and gl_FrontFacing count
-// toward varying counting if they are statically used in a fragment
-// shader.
-void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
-{
- ASSERT(symbol != nullptr);
-
- if (symbol->getName().isInternal())
- {
- // Internal variables are not collected.
- return;
- }
-
- ShaderVariable *var = nullptr;
- const TString &symbolName = symbol->getName().getString();
-
- if (IsVaryingIn(symbol->getQualifier()))
- {
- var = FindVariable(symbolName, mInputVaryings);
- }
- else if (IsVaryingOut(symbol->getQualifier()))
- {
- var = FindVariable(symbolName, mOutputVaryings);
- }
- else if (symbol->getType().getBasicType() == EbtInterfaceBlock)
- {
- UNREACHABLE();
- }
- else if (symbolName == "gl_DepthRange")
- {
- ASSERT(symbol->getQualifier() == EvqUniform);
-
- if (!mDepthRangeAdded)
- {
- Uniform info;
- const char kName[] = "gl_DepthRange";
- info.name = kName;
- info.mappedName = kName;
- info.type = GL_NONE;
- info.precision = GL_NONE;
- info.staticUse = true;
-
- ShaderVariable nearInfo(GL_FLOAT);
- const char kNearName[] = "near";
- nearInfo.name = kNearName;
- nearInfo.mappedName = kNearName;
- nearInfo.precision = GL_HIGH_FLOAT;
- nearInfo.staticUse = true;
-
- ShaderVariable farInfo(GL_FLOAT);
- const char kFarName[] = "far";
- farInfo.name = kFarName;
- farInfo.mappedName = kFarName;
- farInfo.precision = GL_HIGH_FLOAT;
- farInfo.staticUse = true;
-
- ShaderVariable diffInfo(GL_FLOAT);
- const char kDiffName[] = "diff";
- diffInfo.name = kDiffName;
- diffInfo.mappedName = kDiffName;
- diffInfo.precision = GL_HIGH_FLOAT;
- diffInfo.staticUse = true;
-
- info.fields.push_back(nearInfo);
- info.fields.push_back(farInfo);
- info.fields.push_back(diffInfo);
-
- mUniforms->push_back(info);
- mDepthRangeAdded = true;
- }
- }
- else
- {
- switch (symbol->getQualifier())
- {
- case EvqAttribute:
- case EvqVertexIn:
- var = FindVariable(symbolName, mAttribs);
- break;
- case EvqFragmentOut:
- var = FindVariable(symbolName, mOutputVariables);
- break;
- case EvqUniform:
- {
- const TInterfaceBlock *interfaceBlock = symbol->getType().getInterfaceBlock();
- if (interfaceBlock)
- {
- var = FindVariableInInterfaceBlock(symbolName, interfaceBlock, mUniformBlocks);
- }
- else
- {
- var = FindVariable(symbolName, mUniforms);
- }
-
- // It's an internal error to reference an undefined user uniform
- ASSERT(symbolName.compare(0, 3, "gl_") != 0 || var);
- }
- break;
- case EvqBuffer:
- {
- const TInterfaceBlock *interfaceBlock = symbol->getType().getInterfaceBlock();
- var =
- FindVariableInInterfaceBlock(symbolName, interfaceBlock, mShaderStorageBlocks);
- }
- break;
- case EvqFragCoord:
- recordBuiltInVaryingUsed("gl_FragCoord", &mFragCoordAdded, mInputVaryings);
- return;
- case EvqFrontFacing:
- recordBuiltInVaryingUsed("gl_FrontFacing", &mFrontFacingAdded, mInputVaryings);
- return;
- case EvqPointCoord:
- recordBuiltInVaryingUsed("gl_PointCoord", &mPointCoordAdded, mInputVaryings);
- return;
- case EvqInstanceID:
- // Whenever the SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW option is set,
- // gl_InstanceID is added inside expressions to initialize ViewID_OVR and
- // InstanceID. gl_InstanceID is not added to the symbol table for ESSL1 shaders
- // which makes it necessary to populate the type information explicitly instead of
- // extracting it from the symbol table.
- if (!mInstanceIDAdded)
- {
- Attribute info;
- const char kName[] = "gl_InstanceID";
- info.name = kName;
- info.mappedName = kName;
- info.type = GL_INT;
- info.precision = GL_HIGH_INT; // Defined by spec.
- info.staticUse = true;
- info.location = -1;
- mAttribs->push_back(info);
- mInstanceIDAdded = true;
- }
- return;
- case EvqVertexID:
- recordBuiltInAttributeUsed("gl_VertexID", &mVertexIDAdded);
- return;
- case EvqPosition:
- recordBuiltInVaryingUsed("gl_Position", &mPositionAdded, mOutputVaryings);
- return;
- case EvqPointSize:
- recordBuiltInVaryingUsed("gl_PointSize", &mPointSizeAdded, mOutputVaryings);
- return;
- case EvqLastFragData:
- recordBuiltInVaryingUsed("gl_LastFragData", &mLastFragDataAdded, mInputVaryings);
- return;
- case EvqFragColor:
- recordBuiltInFragmentOutputUsed("gl_FragColor", &mFragColorAdded);
- return;
- case EvqFragData:
- if (!mFragDataAdded)
- {
- OutputVariable info;
- setBuiltInInfoFromSymbolTable("gl_FragData", &info);
- if (!IsExtensionEnabled(mExtensionBehavior, TExtension::EXT_draw_buffers))
- {
- ASSERT(info.arraySizes.size() == 1u);
- info.arraySizes.back() = 1u;
- }
- info.staticUse = true;
- mOutputVariables->push_back(info);
- mFragDataAdded = true;
- }
- return;
- case EvqFragDepthEXT:
- recordBuiltInFragmentOutputUsed("gl_FragDepthEXT", &mFragDepthEXTAdded);
- return;
- case EvqFragDepth:
- recordBuiltInFragmentOutputUsed("gl_FragDepth", &mFragDepthAdded);
- return;
- case EvqSecondaryFragColorEXT:
- recordBuiltInFragmentOutputUsed("gl_SecondaryFragColorEXT",
- &mSecondaryFragColorEXTAdded);
- return;
- case EvqSecondaryFragDataEXT:
- recordBuiltInFragmentOutputUsed("gl_SecondaryFragDataEXT",
- &mSecondaryFragDataEXTAdded);
- return;
- case EvqInvocationID:
- recordBuiltInVaryingUsed("gl_InvocationID", &mInvocationIDAdded, mInputVaryings);
- break;
- case EvqPrimitiveIDIn:
- recordBuiltInVaryingUsed("gl_PrimitiveIDIn", &mPrimitiveIDInAdded, mInputVaryings);
- break;
- case EvqPrimitiveID:
- if (mShaderType == GL_GEOMETRY_SHADER_OES)
- {
- recordBuiltInVaryingUsed("gl_PrimitiveID", &mPrimitiveIDAdded, mOutputVaryings);
- }
- else
- {
- ASSERT(mShaderType == GL_FRAGMENT_SHADER);
- recordBuiltInVaryingUsed("gl_PrimitiveID", &mPrimitiveIDAdded, mInputVaryings);
- }
- break;
- case EvqLayer:
- if (mShaderType == GL_GEOMETRY_SHADER_OES)
- {
- recordBuiltInVaryingUsed("gl_Layer", &mLayerAdded, mOutputVaryings);
- }
- else if (mShaderType == GL_FRAGMENT_SHADER)
- {
- recordBuiltInVaryingUsed("gl_Layer", &mLayerAdded, mInputVaryings);
- }
- else
- {
- ASSERT(mShaderType == GL_VERTEX_SHADER &&
- IsExtensionEnabled(mExtensionBehavior, TExtension::OVR_multiview));
- }
- break;
- default:
- break;
- }
- }
- if (var)
- {
- MarkStaticallyUsed(var);
- }
-}
-
-void CollectVariablesTraverser::setCommonVariableProperties(const TType &type,
- const TName &name,
- ShaderVariable *variableOut) const
-{
- ASSERT(variableOut);
-
- const TStructure *structure = type.getStruct();
-
- if (!structure)
- {
- variableOut->type = GLVariableType(type);
- variableOut->precision = GLVariablePrecision(type);
- }
- else
- {
- // Structures use a NONE type that isn't exposed outside ANGLE.
- variableOut->type = GL_NONE;
- variableOut->structName = structure->name().c_str();
-
- const TFieldList &fields = structure->fields();
-
- for (TField *field : fields)
- {
- // Regardless of the variable type (uniform, in/out etc.) its fields are always plain
- // ShaderVariable objects.
- ShaderVariable fieldVariable;
- setCommonVariableProperties(*field->type(), TName(field->name()), &fieldVariable);
- variableOut->fields.push_back(fieldVariable);
- }
- }
- variableOut->name = name.getString().c_str();
- variableOut->mappedName = getMappedName(name);
-
- if (auto *arraySizes = type.getArraySizes())
- {
- variableOut->arraySizes.assign(arraySizes->begin(), arraySizes->end());
- }
-}
-
-Attribute CollectVariablesTraverser::recordAttribute(const TIntermSymbol &variable) const
-{
- const TType &type = variable.getType();
- ASSERT(!type.getStruct());
-
- Attribute attribute;
- setCommonVariableProperties(type, variable.getName(), &attribute);
-
- attribute.location = type.getLayoutQualifier().location;
- return attribute;
-}
-
-OutputVariable CollectVariablesTraverser::recordOutputVariable(const TIntermSymbol &variable) const
-{
- const TType &type = variable.getType();
- ASSERT(!type.getStruct());
-
- OutputVariable outputVariable;
- setCommonVariableProperties(type, variable.getName(), &outputVariable);
-
- outputVariable.location = type.getLayoutQualifier().location;
- return outputVariable;
-}
-
-Varying CollectVariablesTraverser::recordVarying(const TIntermSymbol &variable) const
-{
- const TType &type = variable.getType();
-
- Varying varying;
- setCommonVariableProperties(type, variable.getName(), &varying);
- varying.location = type.getLayoutQualifier().location;
-
- switch (type.getQualifier())
- {
- case EvqVaryingIn:
- case EvqVaryingOut:
- case EvqVertexOut:
- case EvqSmoothOut:
- case EvqFlatOut:
- case EvqCentroidOut:
- case EvqGeometryOut:
- if (mSymbolTable->isVaryingInvariant(std::string(variable.getSymbol().c_str())) ||
- type.isInvariant())
- {
- varying.isInvariant = true;
- }
- break;
- default:
- break;
- }
-
- varying.interpolation = GetInterpolationType(type.getQualifier());
- return varying;
-}
-
-// TODO(jiawei.shao@intel.com): implement GL_OES_shader_io_blocks.
-void CollectVariablesTraverser::recordInterfaceBlock(const TType &interfaceBlockType,
- InterfaceBlock *interfaceBlock) const
-{
- ASSERT(interfaceBlockType.getBasicType() == EbtInterfaceBlock);
- ASSERT(interfaceBlock);
-
- const TInterfaceBlock *blockType = interfaceBlockType.getInterfaceBlock();
- ASSERT(blockType);
-
- interfaceBlock->name = blockType->name().c_str();
- interfaceBlock->mappedName = getMappedName(TName(blockType->name()));
- interfaceBlock->instanceName =
- (blockType->hasInstanceName() ? blockType->instanceName().c_str() : "");
- ASSERT(!interfaceBlockType.isArrayOfArrays()); // Disallowed by GLSL ES 3.10 section 4.3.9
- interfaceBlock->arraySize = interfaceBlockType.isArray() ? interfaceBlockType.getOutermostArraySize() : 0;
-
- interfaceBlock->blockType = GetBlockType(interfaceBlockType.getQualifier());
- if (interfaceBlock->blockType == BlockType::BLOCK_UNIFORM ||
- interfaceBlock->blockType == BlockType::BLOCK_BUFFER)
- {
- interfaceBlock->isRowMajorLayout = (blockType->matrixPacking() == EmpRowMajor);
- interfaceBlock->binding = blockType->blockBinding();
- interfaceBlock->layout = GetBlockLayoutType(blockType->blockStorage());
- }
-
- // Gather field information
- for (const TField *field : blockType->fields())
- {
- const TType &fieldType = *field->type();
-
- InterfaceBlockField fieldVariable;
- setCommonVariableProperties(fieldType, TName(field->name()), &fieldVariable);
- fieldVariable.isRowMajorLayout =
- (fieldType.getLayoutQualifier().matrixPacking == EmpRowMajor);
- interfaceBlock->fields.push_back(fieldVariable);
- }
-}
-
-Uniform CollectVariablesTraverser::recordUniform(const TIntermSymbol &variable) const
-{
- Uniform uniform;
- setCommonVariableProperties(variable.getType(), variable.getName(), &uniform);
- uniform.binding = variable.getType().getLayoutQualifier().binding;
- uniform.location = variable.getType().getLayoutQualifier().location;
- uniform.offset = variable.getType().getLayoutQualifier().offset;
- return uniform;
-}
-
-bool CollectVariablesTraverser::visitDeclaration(Visit, TIntermDeclaration *node)
-{
- const TIntermSequence &sequence = *(node->getSequence());
- ASSERT(!sequence.empty());
-
- const TIntermTyped &typedNode = *(sequence.front()->getAsTyped());
- TQualifier qualifier = typedNode.getQualifier();
-
- bool isShaderVariable = qualifier == EvqAttribute || qualifier == EvqVertexIn ||
- qualifier == EvqFragmentOut || qualifier == EvqUniform ||
- IsVarying(qualifier);
-
- if (typedNode.getBasicType() != EbtInterfaceBlock && !isShaderVariable)
- {
- return true;
- }
-
- for (TIntermNode *variableNode : sequence)
- {
- // The only case in which the sequence will not contain a TIntermSymbol node is
- // initialization. It will contain a TInterBinary node in that case. Since attributes,
- // uniforms, varyings, outputs and interface blocks cannot be initialized in a shader, we
- // must have only TIntermSymbol nodes in the sequence in the cases we are interested in.
- const TIntermSymbol &variable = *variableNode->getAsSymbolNode();
- if (variable.getName().isInternal())
- {
- // Internal variables are not collected.
- continue;
- }
-
- // TODO(jiawei.shao@intel.com): implement GL_OES_shader_io_blocks.
- if (typedNode.getBasicType() == EbtInterfaceBlock)
- {
- InterfaceBlock interfaceBlock;
- recordInterfaceBlock(variable.getType(), &interfaceBlock);
-
- switch (qualifier)
- {
- case EvqUniform:
- mUniformBlocks->push_back(interfaceBlock);
- break;
- case EvqBuffer:
- mShaderStorageBlocks->push_back(interfaceBlock);
- break;
- default:
- UNREACHABLE();
- }
- }
- else
- {
- switch (qualifier)
- {
- case EvqAttribute:
- case EvqVertexIn:
- mAttribs->push_back(recordAttribute(variable));
- break;
- case EvqFragmentOut:
- mOutputVariables->push_back(recordOutputVariable(variable));
- break;
- case EvqUniform:
- mUniforms->push_back(recordUniform(variable));
- break;
- default:
- if (IsVaryingIn(qualifier))
- {
- mInputVaryings->push_back(recordVarying(variable));
- }
- else
- {
- ASSERT(IsVaryingOut(qualifier));
- mOutputVaryings->push_back(recordVarying(variable));
- }
- break;
- }
- }
- }
-
- // None of the recorded variables can have initializers, so we don't need to traverse the
- // declarators.
- return false;
-}
-
-// TODO(jiawei.shao@intel.com): add search on mInBlocks and mOutBlocks when implementing
-// GL_OES_shader_io_blocks.
-InterfaceBlock *CollectVariablesTraverser::findNamedInterfaceBlock(const TString &blockName) const
-{
- InterfaceBlock *namedBlock = FindVariable(blockName, mUniformBlocks);
- if (!namedBlock)
- {
- namedBlock = FindVariable(blockName, mShaderStorageBlocks);
- }
- return namedBlock;
-}
-
-bool CollectVariablesTraverser::visitBinary(Visit, TIntermBinary *binaryNode)
-{
- if (binaryNode->getOp() == EOpIndexDirectInterfaceBlock)
- {
- // NOTE: we do not determine static use for individual blocks of an array
- TIntermTyped *blockNode = binaryNode->getLeft()->getAsTyped();
- ASSERT(blockNode);
-
- TIntermConstantUnion *constantUnion = binaryNode->getRight()->getAsConstantUnion();
- ASSERT(constantUnion);
-
- InterfaceBlock *namedBlock = nullptr;
-
- bool traverseIndexExpression = false;
- TIntermBinary *interfaceIndexingNode = blockNode->getAsBinaryNode();
- if (interfaceIndexingNode)
- {
- TIntermTyped *interfaceNode = interfaceIndexingNode->getLeft()->getAsTyped();
- ASSERT(interfaceNode);
-
- const TType &interfaceType = interfaceNode->getType();
- if (interfaceType.getQualifier() == EvqPerVertexIn)
- {
- namedBlock = recordGLInUsed(interfaceType);
- ASSERT(namedBlock);
-
- // We need to continue traversing to collect useful variables in the index
- // expression of gl_in.
- traverseIndexExpression = true;
- }
- }
-
- const TInterfaceBlock *interfaceBlock = blockNode->getType().getInterfaceBlock();
- if (!namedBlock)
- {
- namedBlock = findNamedInterfaceBlock(interfaceBlock->name());
- }
- ASSERT(namedBlock);
- namedBlock->staticUse = true;
- unsigned int fieldIndex = static_cast<unsigned int>(constantUnion->getIConst(0));
- ASSERT(fieldIndex < namedBlock->fields.size());
- namedBlock->fields[fieldIndex].staticUse = true;
-
- if (traverseIndexExpression)
- {
- ASSERT(interfaceIndexingNode);
- interfaceIndexingNode->getRight()->traverse(this);
- }
- return false;
- }
-
- return true;
-}
-
-} // anonymous namespace
-
-void CollectVariables(TIntermBlock *root,
- std::vector<Attribute> *attributes,
- std::vector<OutputVariable> *outputVariables,
- std::vector<Uniform> *uniforms,
- std::vector<Varying> *inputVaryings,
- std::vector<Varying> *outputVaryings,
- std::vector<InterfaceBlock> *uniformBlocks,
- std::vector<InterfaceBlock> *shaderStorageBlocks,
- std::vector<InterfaceBlock> *inBlocks,
- ShHashFunction64 hashFunction,
- TSymbolTable *symbolTable,
- int shaderVersion,
- GLenum shaderType,
- const TExtensionBehavior &extensionBehavior)
-{
- CollectVariablesTraverser collect(attributes, outputVariables, uniforms, inputVaryings,
- outputVaryings, uniformBlocks, shaderStorageBlocks, inBlocks,
- hashFunction, symbolTable, shaderVersion, shaderType,
- extensionBehavior);
- root->traverse(&collect);
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/CollectVariables.h b/src/3rdparty/angle/src/compiler/translator/CollectVariables.h
deleted file mode 100644
index 4d0d1192e0..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/CollectVariables.h
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// CollectVariables.h: Collect lists of shader interface variables based on the AST.
-
-#ifndef COMPILER_TRANSLATOR_COLLECTVARIABLES_H_
-#define COMPILER_TRANSLATOR_COLLECTVARIABLES_H_
-
-#include <GLSLANG/ShaderLang.h>
-
-#include "compiler/translator/ExtensionBehavior.h"
-
-namespace sh
-{
-
-class TIntermBlock;
-class TSymbolTable;
-
-void CollectVariables(TIntermBlock *root,
- std::vector<Attribute> *attributes,
- std::vector<OutputVariable> *outputVariables,
- std::vector<Uniform> *uniforms,
- std::vector<Varying> *inputVaryings,
- std::vector<Varying> *outputVaryings,
- std::vector<InterfaceBlock> *uniformBlocks,
- std::vector<InterfaceBlock> *shaderStorageBlocks,
- std::vector<InterfaceBlock> *inBlocks,
- ShHashFunction64 hashFunction,
- TSymbolTable *symbolTable,
- int shaderVersion,
- GLenum shaderType,
- const TExtensionBehavior &extensionBehavior);
-}
-
-#endif // COMPILER_TRANSLATOR_COLLECTVARIABLES_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/Common.h b/src/3rdparty/angle/src/compiler/translator/Common.h
deleted file mode 100644
index cb3a680d85..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/Common.h
+++ /dev/null
@@ -1,138 +0,0 @@
-//
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_TRANSLATOR_COMMON_H_
-#define COMPILER_TRANSLATOR_COMMON_H_
-
-#include <map>
-#include <sstream>
-#include <string>
-#include <unordered_map>
-#include <vector>
-#include <limits>
-#include <stdio.h>
-
-#include "common/angleutils.h"
-#include "common/debug.h"
-#include "common/third_party/smhasher/src/PMurHash.h"
-#include "compiler/translator/PoolAlloc.h"
-
-namespace sh
-{
-
-struct TSourceLoc
-{
- int first_file;
- int first_line;
- int last_file;
- int last_line;
-};
-
-//
-// Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme.
-//
-#define POOL_ALLOCATOR_NEW_DELETE() \
- void *operator new(size_t s) { return GetGlobalPoolAllocator()->allocate(s); } \
- void *operator new(size_t, void *_Where) { return (_Where); } \
- void operator delete(void *) {} \
- void operator delete(void *, void *) {} \
- void *operator new[](size_t s) { return GetGlobalPoolAllocator()->allocate(s); } \
- void *operator new[](size_t, void *_Where) { return (_Where); } \
- void operator delete[](void *) {} \
- void operator delete[](void *, void *) {}
-
-//
-// Pool version of string.
-//
-typedef pool_allocator<char> TStringAllocator;
-typedef std::basic_string<char, std::char_traits<char>, TStringAllocator> TString;
-typedef std::basic_ostringstream<char, std::char_traits<char>, TStringAllocator> TStringStream;
-inline TString *NewPoolTString(const char *s)
-{
- void *memory = GetGlobalPoolAllocator()->allocate(sizeof(TString));
- return new (memory) TString(s);
-}
-
-//
-// Persistent string memory. Should only be used for strings that survive
-// across compiles.
-//
-#define TPersistString std::string
-#define TPersistStringStream std::ostringstream
-
-//
-// Pool allocator versions of vectors, lists, and maps
-//
-template <class T>
-class TVector : public std::vector<T, pool_allocator<T>>
-{
- public:
- POOL_ALLOCATOR_NEW_DELETE();
-
- typedef typename std::vector<T, pool_allocator<T>>::size_type size_type;
- TVector() : std::vector<T, pool_allocator<T>>() {}
- TVector(const pool_allocator<T> &a) : std::vector<T, pool_allocator<T>>(a) {}
- TVector(size_type i) : std::vector<T, pool_allocator<T>>(i) {}
-};
-
-template <class K, class D, class H = std::hash<K>, class CMP = std::equal_to<K>>
-class TUnorderedMap : public std::unordered_map<K, D, H, CMP, pool_allocator<std::pair<const K, D>>>
-{
- public:
- POOL_ALLOCATOR_NEW_DELETE();
- typedef pool_allocator<std::pair<const K, D>> tAllocator;
-
- TUnorderedMap() : std::unordered_map<K, D, H, CMP, tAllocator>() {}
- // use correct two-stage name lookup supported in gcc 3.4 and above
- TUnorderedMap(const tAllocator &a)
- : std::unordered_map<K, D, H, CMP, tAllocator>(
- std::unordered_map<K, D, H, CMP, tAllocator>::key_compare(),
- a)
- {
- }
-};
-
-template <class K, class D, class CMP = std::less<K>>
-class TMap : public std::map<K, D, CMP, pool_allocator<std::pair<const K, D>>>
-{
- public:
- POOL_ALLOCATOR_NEW_DELETE();
- typedef pool_allocator<std::pair<const K, D>> tAllocator;
-
- TMap() : std::map<K, D, CMP, tAllocator>() {}
- // use correct two-stage name lookup supported in gcc 3.4 and above
- TMap(const tAllocator &a)
- : std::map<K, D, CMP, tAllocator>(std::map<K, D, CMP, tAllocator>::key_compare(), a)
- {
- }
-};
-
-// Integer to TString conversion
-template <typename T>
-inline TString str(T i)
-{
- ASSERT(std::numeric_limits<T>::is_integer);
- char buffer[((8 * sizeof(T)) / 3) + 3];
- const char *formatStr = std::numeric_limits<T>::is_signed ? "%d" : "%u";
- snprintf(buffer, sizeof(buffer), formatStr, i);
- return buffer;
-}
-
-} // namespace sh
-
-namespace std
-{
-template <>
-struct hash<sh::TString>
-{
- size_t operator()(const sh::TString &s) const
- {
- return angle::PMurHash32(0, s.data(), static_cast<int>(s.length()));
- }
-};
-} // namespace std
-
-#endif // COMPILER_TRANSLATOR_COMMON_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/Compiler.cpp b/src/3rdparty/angle/src/compiler/translator/Compiler.cpp
deleted file mode 100644
index 2f411cb58c..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/Compiler.cpp
+++ /dev/null
@@ -1,1169 +0,0 @@
-//
-// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/translator/Compiler.h"
-
-#include <sstream>
-
-#include "angle_gl.h"
-#include "common/utilities.h"
-#include "compiler/translator/AddAndTrueToLoopCondition.h"
-#include "compiler/translator/Cache.h"
-#include "compiler/translator/CallDAG.h"
-#include "compiler/translator/ClampPointSize.h"
-#include "compiler/translator/CollectVariables.h"
-#include "compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.h"
-#include "compiler/translator/DeferGlobalInitializers.h"
-#include "compiler/translator/EmulateGLFragColorBroadcast.h"
-#include "compiler/translator/EmulatePrecision.h"
-#include "compiler/translator/Initialize.h"
-#include "compiler/translator/InitializeVariables.h"
-#include "compiler/translator/IntermNodePatternMatcher.h"
-#include "compiler/translator/IsASTDepthBelowLimit.h"
-#include "compiler/translator/OutputTree.h"
-#include "compiler/translator/ParseContext.h"
-#include "compiler/translator/PruneNoOps.h"
-#include "compiler/translator/RegenerateStructNames.h"
-#include "compiler/translator/RemoveArrayLengthMethod.h"
-#include "compiler/translator/RemoveEmptySwitchStatements.h"
-#include "compiler/translator/RemoveInvariantDeclaration.h"
-#include "compiler/translator/RemoveNoOpCasesFromEndOfSwitchStatements.h"
-#include "compiler/translator/RemovePow.h"
-#include "compiler/translator/RemoveUnreferencedVariables.h"
-#include "compiler/translator/RewriteDoWhile.h"
-#include "compiler/translator/ScalarizeVecAndMatConstructorArgs.h"
-#include "compiler/translator/SeparateDeclarations.h"
-#include "compiler/translator/SimplifyLoopConditions.h"
-#include "compiler/translator/SplitSequenceOperator.h"
-#include "compiler/translator/UnfoldShortCircuitAST.h"
-#include "compiler/translator/UseInterfaceBlockFields.h"
-#include "compiler/translator/ValidateLimitations.h"
-#include "compiler/translator/ValidateMaxParameters.h"
-#include "compiler/translator/ValidateOutputs.h"
-#include "compiler/translator/ValidateVaryingLocations.h"
-#include "compiler/translator/VariablePacker.h"
-#include "compiler/translator/VectorizeVectorScalarArithmetic.h"
-#include "compiler/translator/util.h"
-#include "third_party/compiler/ArrayBoundsClamper.h"
-
-namespace sh
-{
-
-namespace
-{
-
-#if defined(ANGLE_ENABLE_FUZZER_CORPUS_OUTPUT)
-void DumpFuzzerCase(char const *const *shaderStrings,
- size_t numStrings,
- uint32_t type,
- uint32_t spec,
- uint32_t output,
- uint64_t options)
-{
- static int fileIndex = 0;
-
- std::ostringstream o;
- o << "corpus/" << fileIndex++ << ".sample";
- std::string s = o.str();
-
- // Must match the input format of the fuzzer
- FILE *f = fopen(s.c_str(), "w");
- fwrite(&type, sizeof(type), 1, f);
- fwrite(&spec, sizeof(spec), 1, f);
- fwrite(&output, sizeof(output), 1, f);
- fwrite(&options, sizeof(options), 1, f);
-
- char zero[128 - 20] = {0};
- fwrite(&zero, 128 - 20, 1, f);
-
- for (size_t i = 0; i < numStrings; i++)
- {
- fwrite(shaderStrings[i], sizeof(char), strlen(shaderStrings[i]), f);
- }
- fwrite(&zero, 1, 1, f);
-
- fclose(f);
-}
-#endif // defined(ANGLE_ENABLE_FUZZER_CORPUS_OUTPUT)
-} // anonymous namespace
-
-bool IsWebGLBasedSpec(ShShaderSpec spec)
-{
- return (spec == SH_WEBGL_SPEC || spec == SH_WEBGL2_SPEC || spec == SH_WEBGL3_SPEC);
-}
-
-bool IsGLSL130OrNewer(ShShaderOutput output)
-{
- return (output == SH_GLSL_130_OUTPUT || output == SH_GLSL_140_OUTPUT ||
- output == SH_GLSL_150_CORE_OUTPUT || output == SH_GLSL_330_CORE_OUTPUT ||
- output == SH_GLSL_400_CORE_OUTPUT || output == SH_GLSL_410_CORE_OUTPUT ||
- output == SH_GLSL_420_CORE_OUTPUT || output == SH_GLSL_430_CORE_OUTPUT ||
- output == SH_GLSL_440_CORE_OUTPUT || output == SH_GLSL_450_CORE_OUTPUT);
-}
-
-bool IsGLSL420OrNewer(ShShaderOutput output)
-{
- return (output == SH_GLSL_420_CORE_OUTPUT || output == SH_GLSL_430_CORE_OUTPUT ||
- output == SH_GLSL_440_CORE_OUTPUT || output == SH_GLSL_450_CORE_OUTPUT);
-}
-
-bool IsGLSL410OrOlder(ShShaderOutput output)
-{
- return (output == SH_GLSL_130_OUTPUT || output == SH_GLSL_140_OUTPUT ||
- output == SH_GLSL_150_CORE_OUTPUT || output == SH_GLSL_330_CORE_OUTPUT ||
- output == SH_GLSL_400_CORE_OUTPUT || output == SH_GLSL_410_CORE_OUTPUT);
-}
-
-bool RemoveInvariant(sh::GLenum shaderType,
- int shaderVersion,
- ShShaderOutput outputType,
- ShCompileOptions compileOptions)
-{
- if ((compileOptions & SH_DONT_REMOVE_INVARIANT_FOR_FRAGMENT_INPUT) == 0 &&
- shaderType == GL_FRAGMENT_SHADER && IsGLSL420OrNewer(outputType))
- return true;
-
- if ((compileOptions & SH_REMOVE_INVARIANT_AND_CENTROID_FOR_ESSL3) != 0 &&
- shaderVersion >= 300 && shaderType == GL_VERTEX_SHADER)
- return true;
-
- return false;
-}
-
-size_t GetGlobalMaxTokenSize(ShShaderSpec spec)
-{
- // WebGL defines a max token length of 256, while ES2 leaves max token
- // size undefined. ES3 defines a max size of 1024 characters.
- switch (spec)
- {
- case SH_WEBGL_SPEC:
- return 256;
- default:
- return 1024;
- }
-}
-
-int GetMaxUniformVectorsForShaderType(GLenum shaderType, const ShBuiltInResources &resources)
-{
- switch (shaderType)
- {
- case GL_VERTEX_SHADER:
- return resources.MaxVertexUniformVectors;
- case GL_FRAGMENT_SHADER:
- return resources.MaxFragmentUniformVectors;
-
- // TODO (jiawei.shao@intel.com): check if we need finer-grained component counting
- case GL_COMPUTE_SHADER:
- return resources.MaxComputeUniformComponents / 4;
- case GL_GEOMETRY_SHADER_OES:
- return resources.MaxGeometryUniformComponents / 4;
- default:
- UNREACHABLE();
- return -1;
- }
-}
-
-namespace
-{
-
-class TScopedPoolAllocator
-{
- public:
- TScopedPoolAllocator(TPoolAllocator *allocator) : mAllocator(allocator)
- {
- mAllocator->push();
- SetGlobalPoolAllocator(mAllocator);
- }
- ~TScopedPoolAllocator()
- {
- SetGlobalPoolAllocator(nullptr);
- mAllocator->pop();
- }
-
- private:
- TPoolAllocator *mAllocator;
-};
-
-class TScopedSymbolTableLevel
-{
- public:
- TScopedSymbolTableLevel(TSymbolTable *table) : mTable(table)
- {
- ASSERT(mTable->atBuiltInLevel());
- mTable->push();
- }
- ~TScopedSymbolTableLevel()
- {
- while (!mTable->atBuiltInLevel())
- mTable->pop();
- }
-
- private:
- TSymbolTable *mTable;
-};
-
-int MapSpecToShaderVersion(ShShaderSpec spec)
-{
- switch (spec)
- {
- case SH_GLES2_SPEC:
- case SH_WEBGL_SPEC:
- return 100;
- case SH_GLES3_SPEC:
- case SH_WEBGL2_SPEC:
- return 300;
- case SH_GLES3_1_SPEC:
- case SH_WEBGL3_SPEC:
- return 310;
- default:
- UNREACHABLE();
- return 0;
- }
-}
-
-} // namespace
-
-TShHandleBase::TShHandleBase()
-{
- allocator.push();
- SetGlobalPoolAllocator(&allocator);
-}
-
-TShHandleBase::~TShHandleBase()
-{
- SetGlobalPoolAllocator(nullptr);
- allocator.popAll();
-}
-
-TCompiler::TCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
- : variablesCollected(false),
- mGLPositionInitialized(false),
- shaderType(type),
- shaderSpec(spec),
- outputType(output),
- maxUniformVectors(0),
- maxExpressionComplexity(0),
- maxCallStackDepth(0),
- maxFunctionParameters(0),
- fragmentPrecisionHigh(false),
- clampingStrategy(SH_CLAMP_WITH_CLAMP_INTRINSIC),
- builtInFunctionEmulator(),
- mDiagnostics(infoSink.info),
- mSourcePath(nullptr),
- mComputeShaderLocalSizeDeclared(false),
- mComputeShaderLocalSize(1),
- mGeometryShaderMaxVertices(-1),
- mGeometryShaderInvocations(0),
- mGeometryShaderInputPrimitiveType(EptUndefined),
- mGeometryShaderOutputPrimitiveType(EptUndefined)
-{
-}
-
-TCompiler::~TCompiler()
-{
-}
-
-bool TCompiler::shouldRunLoopAndIndexingValidation(ShCompileOptions compileOptions) const
-{
- // If compiling an ESSL 1.00 shader for WebGL, or if its been requested through the API,
- // validate loop and indexing as well (to verify that the shader only uses minimal functionality
- // of ESSL 1.00 as in Appendix A of the spec).
- return (IsWebGLBasedSpec(shaderSpec) && shaderVersion == 100) ||
- (compileOptions & SH_VALIDATE_LOOP_INDEXING);
-}
-
-bool TCompiler::Init(const ShBuiltInResources &resources)
-{
- shaderVersion = 100;
-
- maxUniformVectors = GetMaxUniformVectorsForShaderType(shaderType, resources);
-
- maxExpressionComplexity = resources.MaxExpressionComplexity;
- maxCallStackDepth = resources.MaxCallStackDepth;
- maxFunctionParameters = resources.MaxFunctionParameters;
-
- SetGlobalPoolAllocator(&allocator);
-
- // Generate built-in symbol table.
- if (!InitBuiltInSymbolTable(resources))
- return false;
- InitExtensionBehavior(resources, extensionBehavior);
- fragmentPrecisionHigh = resources.FragmentPrecisionHigh == 1;
-
- arrayBoundsClamper.SetClampingStrategy(resources.ArrayIndexClampingStrategy);
- clampingStrategy = resources.ArrayIndexClampingStrategy;
-
- hashFunction = resources.HashFunction;
-
- return true;
-}
-
-TIntermBlock *TCompiler::compileTreeForTesting(const char *const shaderStrings[],
- size_t numStrings,
- ShCompileOptions compileOptions)
-{
- return compileTreeImpl(shaderStrings, numStrings, compileOptions);
-}
-
-TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[],
- size_t numStrings,
- const ShCompileOptions compileOptions)
-{
- clearResults();
-
- ASSERT(numStrings > 0);
- ASSERT(GetGlobalPoolAllocator());
-
- // Reset the extension behavior for each compilation unit.
- ResetExtensionBehavior(extensionBehavior);
-
- // First string is path of source file if flag is set. The actual source follows.
- size_t firstSource = 0;
- if (compileOptions & SH_SOURCE_PATH)
- {
- mSourcePath = shaderStrings[0];
- ++firstSource;
- }
-
- TParseContext parseContext(symbolTable, extensionBehavior, shaderType, shaderSpec,
- compileOptions, true, &mDiagnostics, getResources());
-
- parseContext.setFragmentPrecisionHighOnESSL1(fragmentPrecisionHigh);
-
- // We preserve symbols at the built-in level from compile-to-compile.
- // Start pushing the user-defined symbols at global level.
- TScopedSymbolTableLevel scopedSymbolLevel(&symbolTable);
-
- // Parse shader.
- if (PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], nullptr,
- &parseContext) != 0)
- {
- return nullptr;
- }
-
- if (parseContext.getTreeRoot() == nullptr)
- {
- return nullptr;
- }
-
- setASTMetadata(parseContext);
-
- if (MapSpecToShaderVersion(shaderSpec) < shaderVersion)
- {
- mDiagnostics.globalError("unsupported shader version");
- return nullptr;
- }
-
- TIntermBlock *root = parseContext.getTreeRoot();
- if (!checkAndSimplifyAST(root, parseContext, compileOptions))
- {
- return nullptr;
- }
-
- return root;
-}
-
-void TCompiler::setASTMetadata(const TParseContext &parseContext)
-{
- shaderVersion = parseContext.getShaderVersion();
-
- mPragma = parseContext.pragma();
- symbolTable.setGlobalInvariant(mPragma.stdgl.invariantAll);
-
- mComputeShaderLocalSizeDeclared = parseContext.isComputeShaderLocalSizeDeclared();
- mComputeShaderLocalSize = parseContext.getComputeShaderLocalSize();
-
- mNumViews = parseContext.getNumViews();
-
- // Highp might have been auto-enabled based on shader version
- fragmentPrecisionHigh = parseContext.getFragmentPrecisionHigh();
-
- if (shaderType == GL_GEOMETRY_SHADER_OES)
- {
- mGeometryShaderInputPrimitiveType = parseContext.getGeometryShaderInputPrimitiveType();
- mGeometryShaderOutputPrimitiveType = parseContext.getGeometryShaderOutputPrimitiveType();
- mGeometryShaderMaxVertices = parseContext.getGeometryShaderMaxVertices();
- mGeometryShaderInvocations = parseContext.getGeometryShaderInvocations();
- }
-}
-
-bool TCompiler::checkAndSimplifyAST(TIntermBlock *root,
- const TParseContext &parseContext,
- ShCompileOptions compileOptions)
-{
- // Disallow expressions deemed too complex.
- if ((compileOptions & SH_LIMIT_EXPRESSION_COMPLEXITY) && !limitExpressionComplexity(root))
- {
- return false;
- }
-
- // We prune no-ops to work around driver bugs and to keep AST processing and output simple.
- // The following kinds of no-ops are pruned:
- // 1. Empty declarations "int;".
- // 2. Literal statements: "1.0;". The ESSL output doesn't define a default precision
- // for float, so float literal statements would end up with no precision which is
- // invalid ESSL.
- // After this empty declarations are not allowed in the AST.
- PruneNoOps(root);
-
- // In case the last case inside a switch statement is a certain type of no-op, GLSL
- // compilers in drivers may not accept it. In this case we clean up the dead code from the
- // end of switch statements. This is also required because PruneNoOps may have left switch
- // statements that only contained an empty declaration inside the final case in an invalid
- // state. Relies on that PruneNoOps has already been run.
- RemoveNoOpCasesFromEndOfSwitchStatements(root, &symbolTable);
-
- // Remove empty switch statements - this makes output simpler.
- RemoveEmptySwitchStatements(root);
-
- // Create the function DAG and check there is no recursion
- if (!initCallDag(root))
- {
- return false;
- }
-
- if ((compileOptions & SH_LIMIT_CALL_STACK_DEPTH) && !checkCallDepth())
- {
- return false;
- }
-
- // Checks which functions are used and if "main" exists
- functionMetadata.clear();
- functionMetadata.resize(mCallDag.size());
- if (!tagUsedFunctions())
- {
- return false;
- }
-
- if (!(compileOptions & SH_DONT_PRUNE_UNUSED_FUNCTIONS))
- {
- pruneUnusedFunctions(root);
- }
-
- if (shaderVersion >= 310 && !ValidateVaryingLocations(root, &mDiagnostics, shaderType))
- {
- return false;
- }
-
- if (shaderVersion >= 300 && shaderType == GL_FRAGMENT_SHADER &&
- !ValidateOutputs(root, getExtensionBehavior(), compileResources.MaxDrawBuffers,
- &mDiagnostics))
- {
- return false;
- }
-
- if (shouldRunLoopAndIndexingValidation(compileOptions) &&
- !ValidateLimitations(root, shaderType, &symbolTable, shaderVersion, &mDiagnostics))
- {
- return false;
- }
-
- // Fail compilation if precision emulation not supported.
- if (getResources().WEBGL_debug_shader_precision && getPragma().debugShaderPrecision &&
- !EmulatePrecision::SupportedInLanguage(outputType))
- {
- mDiagnostics.globalError("Precision emulation not supported for this output type.");
- return false;
- }
-
- // Clamping uniform array bounds needs to happen after validateLimitations pass.
- if (compileOptions & SH_CLAMP_INDIRECT_ARRAY_BOUNDS)
- {
- arrayBoundsClamper.MarkIndirectArrayBoundsForClamping(root);
- }
-
- if ((compileOptions & SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW) &&
- parseContext.isExtensionEnabled(TExtension::OVR_multiview) &&
- getShaderType() != GL_COMPUTE_SHADER)
- {
- DeclareAndInitBuiltinsForInstancedMultiview(root, mNumViews, shaderType, compileOptions,
- outputType, &symbolTable);
- }
-
- // This pass might emit short circuits so keep it before the short circuit unfolding
- if (compileOptions & SH_REWRITE_DO_WHILE_LOOPS)
- RewriteDoWhile(root, &symbolTable);
-
- if (compileOptions & SH_ADD_AND_TRUE_TO_LOOP_CONDITION)
- sh::AddAndTrueToLoopCondition(root);
-
- if (compileOptions & SH_UNFOLD_SHORT_CIRCUIT)
- {
- UnfoldShortCircuitAST unfoldShortCircuit;
- root->traverse(&unfoldShortCircuit);
- unfoldShortCircuit.updateTree();
- }
-
- if (compileOptions & SH_REMOVE_POW_WITH_CONSTANT_EXPONENT)
- {
- RemovePow(root);
- }
-
- if (compileOptions & SH_REGENERATE_STRUCT_NAMES)
- {
- RegenerateStructNames gen(&symbolTable, shaderVersion);
- root->traverse(&gen);
- }
-
- if (shaderType == GL_FRAGMENT_SHADER && shaderVersion == 100 &&
- compileResources.EXT_draw_buffers && compileResources.MaxDrawBuffers > 1 &&
- IsExtensionEnabled(extensionBehavior, TExtension::EXT_draw_buffers))
- {
- EmulateGLFragColorBroadcast(root, compileResources.MaxDrawBuffers, &outputVariables,
- &symbolTable, shaderVersion);
- }
-
- // Split multi declarations and remove calls to array length().
- // Note that SimplifyLoopConditions needs to be run before any other AST transformations
- // that may need to generate new statements from loop conditions or loop expressions.
- SimplifyLoopConditions(
- root,
- IntermNodePatternMatcher::kMultiDeclaration | IntermNodePatternMatcher::kArrayLengthMethod,
- &getSymbolTable(), getShaderVersion());
-
- // Note that separate declarations need to be run before other AST transformations that
- // generate new statements from expressions.
- SeparateDeclarations(root);
-
- SplitSequenceOperator(root, IntermNodePatternMatcher::kArrayLengthMethod, &getSymbolTable(),
- getShaderVersion());
-
- RemoveArrayLengthMethod(root);
-
- RemoveUnreferencedVariables(root, &symbolTable);
-
- // Built-in function emulation needs to happen after validateLimitations pass.
- // TODO(jmadill): Remove global pool allocator.
- GetGlobalPoolAllocator()->lock();
- initBuiltInFunctionEmulator(&builtInFunctionEmulator, compileOptions);
- GetGlobalPoolAllocator()->unlock();
- builtInFunctionEmulator.markBuiltInFunctionsForEmulation(root);
-
- if (compileOptions & SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS)
- {
- ScalarizeVecAndMatConstructorArgs(root, shaderType, fragmentPrecisionHigh, &symbolTable);
- }
-
- if (shouldCollectVariables(compileOptions))
- {
- ASSERT(!variablesCollected);
- CollectVariables(root, &attributes, &outputVariables, &uniforms, &inputVaryings,
- &outputVaryings, &uniformBlocks, &shaderStorageBlocks, &inBlocks,
- hashFunction, &symbolTable, shaderVersion, shaderType, extensionBehavior);
- collectInterfaceBlocks();
- variablesCollected = true;
- if (compileOptions & SH_USE_UNUSED_STANDARD_SHARED_BLOCKS)
- {
- useAllMembersInUnusedStandardAndSharedBlocks(root);
- }
- if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS)
- {
- // Returns true if, after applying the packing rules in the GLSL ES 1.00.17 spec
- // Appendix A, section 7, the shader does not use too many uniforms.
- if (!CheckVariablesInPackingLimits(maxUniformVectors, uniforms))
- {
- mDiagnostics.globalError("too many uniforms");
- return false;
- }
- }
- if (compileOptions & SH_INIT_OUTPUT_VARIABLES)
- {
- initializeOutputVariables(root);
- }
- }
-
- // Removing invariant declarations must be done after collecting variables.
- // Otherwise, built-in invariant declarations don't apply.
- if (RemoveInvariant(shaderType, shaderVersion, outputType, compileOptions))
- {
- RemoveInvariantDeclaration(root);
- }
-
- // gl_Position is always written in compatibility output mode.
- // It may have been already initialized among other output variables, in that case we don't
- // need to initialize it twice.
- if (shaderType == GL_VERTEX_SHADER && !mGLPositionInitialized &&
- ((compileOptions & SH_INIT_GL_POSITION) || (outputType == SH_GLSL_COMPATIBILITY_OUTPUT)))
- {
- initializeGLPosition(root);
- mGLPositionInitialized = true;
- }
-
- // DeferGlobalInitializers needs to be run before other AST transformations that generate new
- // statements from expressions. But it's fine to run DeferGlobalInitializers after the above
- // SplitSequenceOperator and RemoveArrayLengthMethod since they only have an effect on the AST
- // on ESSL >= 3.00, and the initializers that need to be deferred can only exist in ESSL < 3.00.
- bool initializeLocalsAndGlobals =
- (compileOptions & SH_INITIALIZE_UNINITIALIZED_LOCALS) && !IsOutputHLSL(getOutputType());
- bool canUseLoopsToInitialize = !(compileOptions & SH_DONT_USE_LOOPS_TO_INITIALIZE_VARIABLES);
- DeferGlobalInitializers(root, initializeLocalsAndGlobals, canUseLoopsToInitialize, &symbolTable);
-
- if (initializeLocalsAndGlobals)
- {
- // Initialize uninitialized local variables.
- // In some cases initializing can generate extra statements in the parent block, such as
- // when initializing nameless structs or initializing arrays in ESSL 1.00. In that case
- // we need to first simplify loop conditions. We've already separated declarations
- // earlier, which is also required. If we don't follow the Appendix A limitations, loop
- // init statements can declare arrays or nameless structs and have multiple
- // declarations.
-
- if (!shouldRunLoopAndIndexingValidation(compileOptions))
- {
- SimplifyLoopConditions(root,
- IntermNodePatternMatcher::kArrayDeclaration |
- IntermNodePatternMatcher::kNamelessStructDeclaration,
- &getSymbolTable(), getShaderVersion());
- }
-
- InitializeUninitializedLocals(root, getShaderVersion(), canUseLoopsToInitialize,
- &getSymbolTable());
- }
-
- if (getShaderType() == GL_VERTEX_SHADER && (compileOptions & SH_CLAMP_POINT_SIZE))
- {
- ClampPointSize(root, compileResources.MaxPointSize, &getSymbolTable());
- }
-
- if (compileOptions & SH_REWRITE_VECTOR_SCALAR_ARITHMETIC)
- {
- VectorizeVectorScalarArithmetic(root, &getSymbolTable());
- }
-
- return true;
-}
-
-bool TCompiler::compile(const char *const shaderStrings[],
- size_t numStrings,
- ShCompileOptions compileOptionsIn)
-{
-#if defined(ANGLE_ENABLE_FUZZER_CORPUS_OUTPUT)
- DumpFuzzerCase(shaderStrings, numStrings, shaderType, shaderSpec, outputType, compileOptionsIn);
-#endif // defined(ANGLE_ENABLE_FUZZER_CORPUS_OUTPUT)
-
- if (numStrings == 0)
- return true;
-
- ShCompileOptions compileOptions = compileOptionsIn;
-
- // Apply key workarounds.
- if (shouldFlattenPragmaStdglInvariantAll())
- {
- // This should be harmless to do in all cases, but for the moment, do it only conditionally.
- compileOptions |= SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL;
- }
-
- TScopedPoolAllocator scopedAlloc(&allocator);
- TIntermBlock *root = compileTreeImpl(shaderStrings, numStrings, compileOptions);
-
- if (root)
- {
- if (compileOptions & SH_INTERMEDIATE_TREE)
- OutputTree(root, infoSink.info);
-
- if (compileOptions & SH_OBJECT_CODE)
- {
- PerformanceDiagnostics perfDiagnostics(&mDiagnostics);
- translate(root, compileOptions, &perfDiagnostics);
- }
-
- // The IntermNode tree doesn't need to be deleted here, since the
- // memory will be freed in a big chunk by the PoolAllocator.
- return true;
- }
- return false;
-}
-
-bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
-{
- if (resources.MaxDrawBuffers < 1)
- {
- return false;
- }
- if (resources.EXT_blend_func_extended && resources.MaxDualSourceDrawBuffers < 1)
- {
- return false;
- }
-
- compileResources = resources;
- setResourceString();
-
- ASSERT(symbolTable.isEmpty());
- symbolTable.push(); // COMMON_BUILTINS
- symbolTable.push(); // ESSL1_BUILTINS
- symbolTable.push(); // ESSL3_BUILTINS
- symbolTable.push(); // ESSL3_1_BUILTINS
- symbolTable.push(); // GLSL_BUILTINS
-
- switch (shaderType)
- {
- case GL_FRAGMENT_SHADER:
- symbolTable.setDefaultPrecision(EbtInt, EbpMedium);
- break;
- case GL_VERTEX_SHADER:
- case GL_COMPUTE_SHADER:
- case GL_GEOMETRY_SHADER_OES:
- symbolTable.setDefaultPrecision(EbtInt, EbpHigh);
- symbolTable.setDefaultPrecision(EbtFloat, EbpHigh);
- break;
- default:
- UNREACHABLE();
- }
- // Set defaults for sampler types that have default precision, even those that are
- // only available if an extension exists.
- // New sampler types in ESSL3 don't have default precision. ESSL1 types do.
- initSamplerDefaultPrecision(EbtSampler2D);
- initSamplerDefaultPrecision(EbtSamplerCube);
- // SamplerExternalOES is specified in the extension to have default precision.
- initSamplerDefaultPrecision(EbtSamplerExternalOES);
- // SamplerExternal2DY2YEXT is specified in the extension to have default precision.
- initSamplerDefaultPrecision(EbtSamplerExternal2DY2YEXT);
- // It isn't specified whether Sampler2DRect has default precision.
- initSamplerDefaultPrecision(EbtSampler2DRect);
-
- symbolTable.setDefaultPrecision(EbtAtomicCounter, EbpHigh);
-
- InsertBuiltInFunctions(shaderType, shaderSpec, resources, symbolTable);
-
- IdentifyBuiltIns(shaderType, shaderSpec, resources, symbolTable);
-
- return true;
-}
-
-void TCompiler::initSamplerDefaultPrecision(TBasicType samplerType)
-{
- ASSERT(samplerType > EbtGuardSamplerBegin && samplerType < EbtGuardSamplerEnd);
- symbolTable.setDefaultPrecision(samplerType, EbpLow);
-}
-
-void TCompiler::setResourceString()
-{
- std::ostringstream strstream;
-
- // clang-format off
- strstream << ":MaxVertexAttribs:" << compileResources.MaxVertexAttribs
- << ":MaxVertexUniformVectors:" << compileResources.MaxVertexUniformVectors
- << ":MaxVaryingVectors:" << compileResources.MaxVaryingVectors
- << ":MaxVertexTextureImageUnits:" << compileResources.MaxVertexTextureImageUnits
- << ":MaxCombinedTextureImageUnits:" << compileResources.MaxCombinedTextureImageUnits
- << ":MaxTextureImageUnits:" << compileResources.MaxTextureImageUnits
- << ":MaxFragmentUniformVectors:" << compileResources.MaxFragmentUniformVectors
- << ":MaxDrawBuffers:" << compileResources.MaxDrawBuffers
- << ":OES_standard_derivatives:" << compileResources.OES_standard_derivatives
- << ":OES_EGL_image_external:" << compileResources.OES_EGL_image_external
- << ":OES_EGL_image_external_essl3:" << compileResources.OES_EGL_image_external_essl3
- << ":NV_EGL_stream_consumer_external:" << compileResources.NV_EGL_stream_consumer_external
- << ":ARB_texture_rectangle:" << compileResources.ARB_texture_rectangle
- << ":EXT_draw_buffers:" << compileResources.EXT_draw_buffers
- << ":FragmentPrecisionHigh:" << compileResources.FragmentPrecisionHigh
- << ":MaxExpressionComplexity:" << compileResources.MaxExpressionComplexity
- << ":MaxCallStackDepth:" << compileResources.MaxCallStackDepth
- << ":MaxFunctionParameters:" << compileResources.MaxFunctionParameters
- << ":EXT_blend_func_extended:" << compileResources.EXT_blend_func_extended
- << ":EXT_frag_depth:" << compileResources.EXT_frag_depth
- << ":EXT_shader_texture_lod:" << compileResources.EXT_shader_texture_lod
- << ":EXT_shader_framebuffer_fetch:" << compileResources.EXT_shader_framebuffer_fetch
- << ":NV_shader_framebuffer_fetch:" << compileResources.NV_shader_framebuffer_fetch
- << ":ARM_shader_framebuffer_fetch:" << compileResources.ARM_shader_framebuffer_fetch
- << ":OVR_multiview:" << compileResources.OVR_multiview
- << ":EXT_YUV_target:" << compileResources.EXT_YUV_target
- << ":OES_geometry_shader:" << compileResources.OES_geometry_shader
- << ":MaxVertexOutputVectors:" << compileResources.MaxVertexOutputVectors
- << ":MaxFragmentInputVectors:" << compileResources.MaxFragmentInputVectors
- << ":MinProgramTexelOffset:" << compileResources.MinProgramTexelOffset
- << ":MaxProgramTexelOffset:" << compileResources.MaxProgramTexelOffset
- << ":MaxDualSourceDrawBuffers:" << compileResources.MaxDualSourceDrawBuffers
- << ":MaxViewsOVR:" << compileResources.MaxViewsOVR
- << ":NV_draw_buffers:" << compileResources.NV_draw_buffers
- << ":WEBGL_debug_shader_precision:" << compileResources.WEBGL_debug_shader_precision
- << ":MinProgramTextureGatherOffset:" << compileResources.MinProgramTextureGatherOffset
- << ":MaxProgramTextureGatherOffset:" << compileResources.MaxProgramTextureGatherOffset
- << ":MaxImageUnits:" << compileResources.MaxImageUnits
- << ":MaxVertexImageUniforms:" << compileResources.MaxVertexImageUniforms
- << ":MaxFragmentImageUniforms:" << compileResources.MaxFragmentImageUniforms
- << ":MaxComputeImageUniforms:" << compileResources.MaxComputeImageUniforms
- << ":MaxCombinedImageUniforms:" << compileResources.MaxCombinedImageUniforms
- << ":MaxCombinedShaderOutputResources:" << compileResources.MaxCombinedShaderOutputResources
- << ":MaxComputeWorkGroupCountX:" << compileResources.MaxComputeWorkGroupCount[0]
- << ":MaxComputeWorkGroupCountY:" << compileResources.MaxComputeWorkGroupCount[1]
- << ":MaxComputeWorkGroupCountZ:" << compileResources.MaxComputeWorkGroupCount[2]
- << ":MaxComputeWorkGroupSizeX:" << compileResources.MaxComputeWorkGroupSize[0]
- << ":MaxComputeWorkGroupSizeY:" << compileResources.MaxComputeWorkGroupSize[1]
- << ":MaxComputeWorkGroupSizeZ:" << compileResources.MaxComputeWorkGroupSize[2]
- << ":MaxComputeUniformComponents:" << compileResources.MaxComputeUniformComponents
- << ":MaxComputeTextureImageUnits:" << compileResources.MaxComputeTextureImageUnits
- << ":MaxComputeAtomicCounters:" << compileResources.MaxComputeAtomicCounters
- << ":MaxComputeAtomicCounterBuffers:" << compileResources.MaxComputeAtomicCounterBuffers
- << ":MaxVertexAtomicCounters:" << compileResources.MaxVertexAtomicCounters
- << ":MaxFragmentAtomicCounters:" << compileResources.MaxFragmentAtomicCounters
- << ":MaxCombinedAtomicCounters:" << compileResources.MaxCombinedAtomicCounters
- << ":MaxAtomicCounterBindings:" << compileResources.MaxAtomicCounterBindings
- << ":MaxVertexAtomicCounterBuffers:" << compileResources.MaxVertexAtomicCounterBuffers
- << ":MaxFragmentAtomicCounterBuffers:" << compileResources.MaxFragmentAtomicCounterBuffers
- << ":MaxCombinedAtomicCounterBuffers:" << compileResources.MaxCombinedAtomicCounterBuffers
- << ":MaxAtomicCounterBufferSize:" << compileResources.MaxAtomicCounterBufferSize
- << ":MaxGeometryUniformComponents:" << compileResources.MaxGeometryUniformComponents
- << ":MaxGeometryUniformBlocks:" << compileResources.MaxGeometryUniformBlocks
- << ":MaxGeometryInputComponents:" << compileResources.MaxGeometryInputComponents
- << ":MaxGeometryOutputComponents:" << compileResources.MaxGeometryOutputComponents
- << ":MaxGeometryOutputVertices:" << compileResources.MaxGeometryOutputVertices
- << ":MaxGeometryTotalOutputComponents:" << compileResources.MaxGeometryTotalOutputComponents
- << ":MaxGeometryTextureImageUnits:" << compileResources.MaxGeometryTextureImageUnits
- << ":MaxGeometryAtomicCounterBuffers:" << compileResources.MaxGeometryAtomicCounterBuffers
- << ":MaxGeometryAtomicCounters:" << compileResources.MaxGeometryAtomicCounters
- << ":MaxGeometryShaderStorageBlocks:" << compileResources.MaxGeometryShaderStorageBlocks
- << ":MaxGeometryShaderInvocations:" << compileResources.MaxGeometryShaderInvocations
- << ":MaxGeometryImageUniforms:" << compileResources.MaxGeometryImageUniforms;
- // clang-format on
-
- builtInResourcesString = strstream.str();
-}
-
-void TCompiler::collectInterfaceBlocks()
-{
- ASSERT(interfaceBlocks.empty());
- interfaceBlocks.reserve(uniformBlocks.size() + shaderStorageBlocks.size() + inBlocks.size());
- interfaceBlocks.insert(interfaceBlocks.end(), uniformBlocks.begin(), uniformBlocks.end());
- interfaceBlocks.insert(interfaceBlocks.end(), shaderStorageBlocks.begin(),
- shaderStorageBlocks.end());
- interfaceBlocks.insert(interfaceBlocks.end(), inBlocks.begin(), inBlocks.end());
-}
-
-void TCompiler::clearResults()
-{
- arrayBoundsClamper.Cleanup();
- infoSink.info.erase();
- infoSink.obj.erase();
- infoSink.debug.erase();
- mDiagnostics.resetErrorCount();
-
- attributes.clear();
- outputVariables.clear();
- uniforms.clear();
- inputVaryings.clear();
- outputVaryings.clear();
- interfaceBlocks.clear();
- uniformBlocks.clear();
- shaderStorageBlocks.clear();
- inBlocks.clear();
- variablesCollected = false;
- mGLPositionInitialized = false;
-
- mNumViews = -1;
-
- mGeometryShaderInputPrimitiveType = EptUndefined;
- mGeometryShaderOutputPrimitiveType = EptUndefined;
- mGeometryShaderInvocations = 0;
- mGeometryShaderMaxVertices = -1;
-
- builtInFunctionEmulator.cleanup();
-
- nameMap.clear();
-
- mSourcePath = nullptr;
-}
-
-bool TCompiler::initCallDag(TIntermNode *root)
-{
- mCallDag.clear();
-
- switch (mCallDag.init(root, &mDiagnostics))
- {
- case CallDAG::INITDAG_SUCCESS:
- return true;
- case CallDAG::INITDAG_RECURSION:
- case CallDAG::INITDAG_UNDEFINED:
- // Error message has already been written out.
- ASSERT(mDiagnostics.numErrors() > 0);
- return false;
- }
-
- UNREACHABLE();
- return true;
-}
-
-bool TCompiler::checkCallDepth()
-{
- std::vector<int> depths(mCallDag.size());
-
- for (size_t i = 0; i < mCallDag.size(); i++)
- {
- int depth = 0;
- auto &record = mCallDag.getRecordFromIndex(i);
-
- for (auto &calleeIndex : record.callees)
- {
- depth = std::max(depth, depths[calleeIndex] + 1);
- }
-
- depths[i] = depth;
-
- if (depth >= maxCallStackDepth)
- {
- // Trace back the function chain to have a meaningful info log.
- std::stringstream errorStream;
- errorStream << "Call stack too deep (larger than " << maxCallStackDepth
- << ") with the following call chain: " << record.name;
-
- int currentFunction = static_cast<int>(i);
- int currentDepth = depth;
-
- while (currentFunction != -1)
- {
- errorStream << " -> " << mCallDag.getRecordFromIndex(currentFunction).name;
-
- int nextFunction = -1;
- for (auto &calleeIndex : mCallDag.getRecordFromIndex(currentFunction).callees)
- {
- if (depths[calleeIndex] == currentDepth - 1)
- {
- currentDepth--;
- nextFunction = calleeIndex;
- }
- }
-
- currentFunction = nextFunction;
- }
-
- std::string errorStr = errorStream.str();
- mDiagnostics.globalError(errorStr.c_str());
-
- return false;
- }
- }
-
- return true;
-}
-
-bool TCompiler::tagUsedFunctions()
-{
- // Search from main, starting from the end of the DAG as it usually is the root.
- for (size_t i = mCallDag.size(); i-- > 0;)
- {
- if (mCallDag.getRecordFromIndex(i).name == "main")
- {
- internalTagUsedFunction(i);
- return true;
- }
- }
-
- mDiagnostics.globalError("Missing main()");
- return false;
-}
-
-void TCompiler::internalTagUsedFunction(size_t index)
-{
- if (functionMetadata[index].used)
- {
- return;
- }
-
- functionMetadata[index].used = true;
-
- for (int calleeIndex : mCallDag.getRecordFromIndex(index).callees)
- {
- internalTagUsedFunction(calleeIndex);
- }
-}
-
-// A predicate for the stl that returns if a top-level node is unused
-class TCompiler::UnusedPredicate
-{
- public:
- UnusedPredicate(const CallDAG *callDag, const std::vector<FunctionMetadata> *metadatas)
- : mCallDag(callDag), mMetadatas(metadatas)
- {
- }
-
- bool operator()(TIntermNode *node)
- {
- const TIntermFunctionPrototype *asFunctionPrototype = node->getAsFunctionPrototypeNode();
- const TIntermFunctionDefinition *asFunctionDefinition = node->getAsFunctionDefinition();
-
- const TFunctionSymbolInfo *functionInfo = nullptr;
-
- if (asFunctionDefinition)
- {
- functionInfo = asFunctionDefinition->getFunctionSymbolInfo();
- }
- else if (asFunctionPrototype)
- {
- functionInfo = asFunctionPrototype->getFunctionSymbolInfo();
- }
- if (functionInfo == nullptr)
- {
- return false;
- }
-
- size_t callDagIndex = mCallDag->findIndex(functionInfo);
- if (callDagIndex == CallDAG::InvalidIndex)
- {
- // This happens only for unimplemented prototypes which are thus unused
- ASSERT(asFunctionPrototype);
- return true;
- }
-
- ASSERT(callDagIndex < mMetadatas->size());
- return !(*mMetadatas)[callDagIndex].used;
- }
-
- private:
- const CallDAG *mCallDag;
- const std::vector<FunctionMetadata> *mMetadatas;
-};
-
-void TCompiler::pruneUnusedFunctions(TIntermBlock *root)
-{
- UnusedPredicate isUnused(&mCallDag, &functionMetadata);
- TIntermSequence *sequence = root->getSequence();
-
- if (!sequence->empty())
- {
- sequence->erase(std::remove_if(sequence->begin(), sequence->end(), isUnused),
- sequence->end());
- }
-}
-
-bool TCompiler::limitExpressionComplexity(TIntermBlock *root)
-{
- if (!IsASTDepthBelowLimit(root, maxExpressionComplexity))
- {
- mDiagnostics.globalError("Expression too complex.");
- return false;
- }
-
- if (!ValidateMaxParameters(root, maxFunctionParameters))
- {
- mDiagnostics.globalError("Function has too many parameters.");
- return false;
- }
-
- return true;
-}
-
-bool TCompiler::shouldCollectVariables(ShCompileOptions compileOptions)
-{
- return (compileOptions & SH_VARIABLES) != 0;
-}
-
-bool TCompiler::wereVariablesCollected() const
-{
- return variablesCollected;
-}
-
-void TCompiler::initializeGLPosition(TIntermBlock *root)
-{
- InitVariableList list;
- sh::ShaderVariable var(GL_FLOAT_VEC4);
- var.name = "gl_Position";
- list.push_back(var);
- InitializeVariables(root, list, &symbolTable, shaderVersion, extensionBehavior, false);
-}
-
-void TCompiler::useAllMembersInUnusedStandardAndSharedBlocks(TIntermBlock *root)
-{
- sh::InterfaceBlockList list;
-
- for (auto block : uniformBlocks)
- {
- if (!block.staticUse &&
- (block.layout == sh::BLOCKLAYOUT_STD140 || block.layout == sh::BLOCKLAYOUT_SHARED))
- {
- list.push_back(block);
- }
- }
-
- sh::UseInterfaceBlockFields(root, list, symbolTable);
-}
-
-void TCompiler::initializeOutputVariables(TIntermBlock *root)
-{
- InitVariableList list;
- if (shaderType == GL_VERTEX_SHADER || shaderType == GL_GEOMETRY_SHADER_OES)
- {
- for (auto var : outputVaryings)
- {
- list.push_back(var);
- if (var.name == "gl_Position")
- {
- ASSERT(!mGLPositionInitialized);
- mGLPositionInitialized = true;
- }
- }
- }
- else
- {
- ASSERT(shaderType == GL_FRAGMENT_SHADER);
- for (auto var : outputVariables)
- {
- list.push_back(var);
- }
- }
- InitializeVariables(root, list, &symbolTable, shaderVersion, extensionBehavior, false);
-}
-
-const TExtensionBehavior &TCompiler::getExtensionBehavior() const
-{
- return extensionBehavior;
-}
-
-const char *TCompiler::getSourcePath() const
-{
- return mSourcePath;
-}
-
-const ShBuiltInResources &TCompiler::getResources() const
-{
- return compileResources;
-}
-
-const ArrayBoundsClamper &TCompiler::getArrayBoundsClamper() const
-{
- return arrayBoundsClamper;
-}
-
-ShArrayIndexClampingStrategy TCompiler::getArrayIndexClampingStrategy() const
-{
- return clampingStrategy;
-}
-
-const BuiltInFunctionEmulator &TCompiler::getBuiltInFunctionEmulator() const
-{
- return builtInFunctionEmulator;
-}
-
-void TCompiler::writePragma(ShCompileOptions compileOptions)
-{
- if (!(compileOptions & SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL))
- {
- TInfoSinkBase &sink = infoSink.obj;
- if (mPragma.stdgl.invariantAll)
- sink << "#pragma STDGL invariant(all)\n";
- }
-}
-
-bool TCompiler::isVaryingDefined(const char *varyingName)
-{
- ASSERT(variablesCollected);
- for (size_t ii = 0; ii < inputVaryings.size(); ++ii)
- {
- if (inputVaryings[ii].name == varyingName)
- {
- return true;
- }
- }
- for (size_t ii = 0; ii < outputVaryings.size(); ++ii)
- {
- if (outputVaryings[ii].name == varyingName)
- {
- return true;
- }
- }
-
- return false;
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/Compiler.h b/src/3rdparty/angle/src/compiler/translator/Compiler.h
deleted file mode 100644
index 753cfb8e7b..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/Compiler.h
+++ /dev/null
@@ -1,308 +0,0 @@
-//
-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_TRANSLATOR_COMPILER_H_
-#define COMPILER_TRANSLATOR_COMPILER_H_
-
-//
-// Machine independent part of the compiler private objects
-// sent as ShHandle to the driver.
-//
-// This should not be included by driver code.
-//
-
-#include <GLSLANG/ShaderVars.h>
-
-#include "compiler/translator/BuiltInFunctionEmulator.h"
-#include "compiler/translator/CallDAG.h"
-#include "compiler/translator/Diagnostics.h"
-#include "compiler/translator/ExtensionBehavior.h"
-#include "compiler/translator/HashNames.h"
-#include "compiler/translator/InfoSink.h"
-#include "compiler/translator/Pragma.h"
-#include "compiler/translator/SymbolTable.h"
-#include "third_party/compiler/ArrayBoundsClamper.h"
-
-namespace sh
-{
-
-class TCompiler;
-class TParseContext;
-#ifdef ANGLE_ENABLE_HLSL
-class TranslatorHLSL;
-#endif // ANGLE_ENABLE_HLSL
-
-//
-// Helper function to identify specs that are based on the WebGL spec.
-//
-bool IsWebGLBasedSpec(ShShaderSpec spec);
-
-//
-// Helper function to check if the shader type is GLSL.
-//
-bool IsGLSL130OrNewer(ShShaderOutput output);
-bool IsGLSL420OrNewer(ShShaderOutput output);
-bool IsGLSL410OrOlder(ShShaderOutput output);
-
-//
-// Helper function to check if the invariant qualifier can be removed.
-//
-bool RemoveInvariant(sh::GLenum shaderType,
- int shaderVersion,
- ShShaderOutput outputType,
- ShCompileOptions compileOptions);
-
-//
-// The base class used to back handles returned to the driver.
-//
-class TShHandleBase
-{
- public:
- TShHandleBase();
- virtual ~TShHandleBase();
- virtual TCompiler *getAsCompiler() { return 0; }
-#ifdef ANGLE_ENABLE_HLSL
- virtual TranslatorHLSL *getAsTranslatorHLSL() { return 0; }
-#endif // ANGLE_ENABLE_HLSL
-
- protected:
- // Memory allocator. Allocates and tracks memory required by the compiler.
- // Deallocates all memory when compiler is destructed.
- TPoolAllocator allocator;
-};
-
-//
-// The base class for the machine dependent compiler to derive from
-// for managing object code from the compile.
-//
-class TCompiler : public TShHandleBase
-{
- public:
- TCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output);
- ~TCompiler() override;
- TCompiler *getAsCompiler() override { return this; }
-
- bool Init(const ShBuiltInResources &resources);
-
- // compileTreeForTesting should be used only when tests require access to
- // the AST. Users of this function need to manually manage the global pool
- // allocator. Returns nullptr whenever there are compilation errors.
- TIntermBlock *compileTreeForTesting(const char *const shaderStrings[],
- size_t numStrings,
- ShCompileOptions compileOptions);
-
- bool compile(const char *const shaderStrings[],
- size_t numStrings,
- ShCompileOptions compileOptions);
-
- // Get results of the last compilation.
- int getShaderVersion() const { return shaderVersion; }
- TInfoSink &getInfoSink() { return infoSink; }
-
- bool isComputeShaderLocalSizeDeclared() const { return mComputeShaderLocalSizeDeclared; }
- const sh::WorkGroupSize &getComputeShaderLocalSize() const { return mComputeShaderLocalSize; }
- int getNumViews() const { return mNumViews; }
-
- // Clears the results from the previous compilation.
- void clearResults();
-
- const std::vector<sh::Attribute> &getAttributes() const { return attributes; }
- const std::vector<sh::OutputVariable> &getOutputVariables() const { return outputVariables; }
- const std::vector<sh::Uniform> &getUniforms() const { return uniforms; }
- const std::vector<sh::Varying> &getInputVaryings() const { return inputVaryings; }
- const std::vector<sh::Varying> &getOutputVaryings() const { return outputVaryings; }
- const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return interfaceBlocks; }
- const std::vector<sh::InterfaceBlock> &getUniformBlocks() const { return uniformBlocks; }
- const std::vector<sh::InterfaceBlock> &getShaderStorageBlocks() const
- {
- return shaderStorageBlocks;
- }
- const std::vector<sh::InterfaceBlock> &getInBlocks() const { return inBlocks; }
-
- ShHashFunction64 getHashFunction() const { return hashFunction; }
- NameMap &getNameMap() { return nameMap; }
- TSymbolTable &getSymbolTable() { return symbolTable; }
- ShShaderSpec getShaderSpec() const { return shaderSpec; }
- ShShaderOutput getOutputType() const { return outputType; }
- const std::string &getBuiltInResourcesString() const { return builtInResourcesString; }
-
- bool shouldRunLoopAndIndexingValidation(ShCompileOptions compileOptions) const;
-
- // Get the resources set by InitBuiltInSymbolTable
- const ShBuiltInResources &getResources() const;
-
- int getGeometryShaderMaxVertices() const { return mGeometryShaderMaxVertices; }
- int getGeometryShaderInvocations() const { return mGeometryShaderInvocations; }
- TLayoutPrimitiveType getGeometryShaderInputPrimitiveType() const
- {
- return mGeometryShaderInputPrimitiveType;
- }
- TLayoutPrimitiveType getGeometryShaderOutputPrimitiveType() const
- {
- return mGeometryShaderOutputPrimitiveType;
- }
-
- sh::GLenum getShaderType() const { return shaderType; }
-
- protected:
- // Initialize symbol-table with built-in symbols.
- bool InitBuiltInSymbolTable(const ShBuiltInResources &resources);
- // Compute the string representation of the built-in resources
- void setResourceString();
- // Return false if the call depth is exceeded.
- bool checkCallDepth();
- // Add emulated functions to the built-in function emulator.
- virtual void initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu,
- ShCompileOptions compileOptions){};
- // Translate to object code. May generate performance warnings through the diagnostics.
- virtual void translate(TIntermBlock *root,
- ShCompileOptions compileOptions,
- PerformanceDiagnostics *perfDiagnostics) = 0;
- // Insert statements to reference all members in unused uniform blocks with standard and shared
- // layout. This is to work around a Mac driver that treats unused standard/shared
- // uniform blocks as inactive.
- void useAllMembersInUnusedStandardAndSharedBlocks(TIntermBlock *root);
- // Insert statements to initialize output variables in the beginning of main().
- // This is to avoid undefined behaviors.
- void initializeOutputVariables(TIntermBlock *root);
- // Insert gl_Position = vec4(0,0,0,0) to the beginning of main().
- // It is to work around a Linux driver bug where missing this causes compile failure
- // while spec says it is allowed.
- // This function should only be applied to vertex shaders.
- void initializeGLPosition(TIntermBlock *root);
- // Return true if the maximum expression complexity is below the limit.
- bool limitExpressionComplexity(TIntermBlock *root);
- // Get built-in extensions with default behavior.
- const TExtensionBehavior &getExtensionBehavior() const;
- const char *getSourcePath() const;
- const TPragma &getPragma() const { return mPragma; }
- void writePragma(ShCompileOptions compileOptions);
- // Relies on collectVariables having been called.
- bool isVaryingDefined(const char *varyingName);
-
- const ArrayBoundsClamper &getArrayBoundsClamper() const;
- ShArrayIndexClampingStrategy getArrayIndexClampingStrategy() const;
- const BuiltInFunctionEmulator &getBuiltInFunctionEmulator() const;
-
- virtual bool shouldFlattenPragmaStdglInvariantAll() = 0;
- virtual bool shouldCollectVariables(ShCompileOptions compileOptions);
-
- bool wereVariablesCollected() const;
- std::vector<sh::Attribute> attributes;
- std::vector<sh::OutputVariable> outputVariables;
- std::vector<sh::Uniform> uniforms;
- std::vector<sh::Varying> inputVaryings;
- std::vector<sh::Varying> outputVaryings;
- std::vector<sh::InterfaceBlock> interfaceBlocks;
- std::vector<sh::InterfaceBlock> uniformBlocks;
- std::vector<sh::InterfaceBlock> shaderStorageBlocks;
- std::vector<sh::InterfaceBlock> inBlocks;
-
- private:
- // Creates the function call DAG for further analysis, returning false if there is a recursion
- bool initCallDag(TIntermNode *root);
- // Return false if "main" doesn't exist
- bool tagUsedFunctions();
- void internalTagUsedFunction(size_t index);
-
- void initSamplerDefaultPrecision(TBasicType samplerType);
-
- void collectInterfaceBlocks();
-
- bool variablesCollected;
-
- bool mGLPositionInitialized;
-
- // Removes unused function declarations and prototypes from the AST
- class UnusedPredicate;
- void pruneUnusedFunctions(TIntermBlock *root);
-
- TIntermBlock *compileTreeImpl(const char *const shaderStrings[],
- size_t numStrings,
- const ShCompileOptions compileOptions);
-
- // Fetches and stores shader metadata that is not stored within the AST itself, such as shader
- // version.
- void setASTMetadata(const TParseContext &parseContext);
-
- // Does checks that need to be run after parsing is complete and returns true if they pass.
- bool checkAndSimplifyAST(TIntermBlock *root,
- const TParseContext &parseContext,
- ShCompileOptions compileOptions);
-
- sh::GLenum shaderType;
- ShShaderSpec shaderSpec;
- ShShaderOutput outputType;
-
- struct FunctionMetadata
- {
- FunctionMetadata() : used(false) {}
- bool used;
- };
-
- CallDAG mCallDag;
- std::vector<FunctionMetadata> functionMetadata;
-
- int maxUniformVectors;
- int maxExpressionComplexity;
- int maxCallStackDepth;
- int maxFunctionParameters;
-
- ShBuiltInResources compileResources;
- std::string builtInResourcesString;
-
- // Built-in symbol table for the given language, spec, and resources.
- // It is preserved from compile-to-compile.
- TSymbolTable symbolTable;
- // Built-in extensions with default behavior.
- TExtensionBehavior extensionBehavior;
- bool fragmentPrecisionHigh;
-
- ArrayBoundsClamper arrayBoundsClamper;
- ShArrayIndexClampingStrategy clampingStrategy;
- BuiltInFunctionEmulator builtInFunctionEmulator;
-
- // Results of compilation.
- int shaderVersion;
- TInfoSink infoSink; // Output sink.
- TDiagnostics mDiagnostics;
- const char *mSourcePath; // Path of source file or NULL
-
- // compute shader local group size
- bool mComputeShaderLocalSizeDeclared;
- sh::WorkGroupSize mComputeShaderLocalSize;
-
- // GL_OVR_multiview num_views.
- int mNumViews;
-
- // geometry shader parameters.
- int mGeometryShaderMaxVertices;
- int mGeometryShaderInvocations;
- TLayoutPrimitiveType mGeometryShaderInputPrimitiveType;
- TLayoutPrimitiveType mGeometryShaderOutputPrimitiveType;
-
- // name hashing.
- ShHashFunction64 hashFunction;
- NameMap nameMap;
-
- TPragma mPragma;
-};
-
-//
-// This is the interface between the machine independent code
-// and the machine dependent code.
-//
-// The machine dependent code should derive from the classes
-// above. Then Construct*() and Delete*() will create and
-// destroy the machine dependent objects, which contain the
-// above machine independent information.
-//
-TCompiler *ConstructCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output);
-void DeleteCompiler(TCompiler *);
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_COMPILER_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/ConstantUnion.cpp b/src/3rdparty/angle/src/compiler/translator/ConstantUnion.cpp
deleted file mode 100644
index 7004aedee3..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ConstantUnion.cpp
+++ /dev/null
@@ -1,681 +0,0 @@
-//
-// Copyright 2016 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// ConstantUnion: Constant folding helper class.
-
-#include "compiler/translator/ConstantUnion.h"
-
-#include "common/mathutil.h"
-#include "compiler/translator/Diagnostics.h"
-
-namespace sh
-{
-
-namespace
-{
-
-float CheckedSum(float lhs, float rhs, TDiagnostics *diag, const TSourceLoc &line)
-{
- float result = lhs + rhs;
- if (gl::isNaN(result) && !gl::isNaN(lhs) && !gl::isNaN(rhs))
- {
- diag->warning(line, "Constant folded undefined addition generated NaN", "+");
- }
- else if (gl::isInf(result) && !gl::isInf(lhs) && !gl::isInf(rhs))
- {
- diag->warning(line, "Constant folded addition overflowed to infinity", "+");
- }
- return result;
-}
-
-float CheckedDiff(float lhs, float rhs, TDiagnostics *diag, const TSourceLoc &line)
-{
- float result = lhs - rhs;
- if (gl::isNaN(result) && !gl::isNaN(lhs) && !gl::isNaN(rhs))
- {
- diag->warning(line, "Constant folded undefined subtraction generated NaN", "-");
- }
- else if (gl::isInf(result) && !gl::isInf(lhs) && !gl::isInf(rhs))
- {
- diag->warning(line, "Constant folded subtraction overflowed to infinity", "-");
- }
- return result;
-}
-
-float CheckedMul(float lhs, float rhs, TDiagnostics *diag, const TSourceLoc &line)
-{
- float result = lhs * rhs;
- if (gl::isNaN(result) && !gl::isNaN(lhs) && !gl::isNaN(rhs))
- {
- diag->warning(line, "Constant folded undefined multiplication generated NaN", "*");
- }
- else if (gl::isInf(result) && !gl::isInf(lhs) && !gl::isInf(rhs))
- {
- diag->warning(line, "Constant folded multiplication overflowed to infinity", "*");
- }
- return result;
-}
-
-bool IsValidShiftOffset(const TConstantUnion &rhs)
-{
- return (rhs.getType() == EbtInt && (rhs.getIConst() >= 0 && rhs.getIConst() <= 31)) ||
- (rhs.getType() == EbtUInt && rhs.getUConst() <= 31u);
-}
-
-} // anonymous namespace
-
-TConstantUnion::TConstantUnion()
-{
- iConst = 0;
- type = EbtVoid;
-}
-
-int TConstantUnion::getIConst() const
-{
- ASSERT(type == EbtInt);
- return iConst;
-}
-
-unsigned int TConstantUnion::getUConst() const
-{
- ASSERT(type == EbtUInt);
- return uConst;
-}
-
-float TConstantUnion::getFConst() const
-{
- ASSERT(type == EbtFloat);
- return fConst;
-}
-
-bool TConstantUnion::getBConst() const
-{
- ASSERT(type == EbtBool);
- return bConst;
-}
-
-TYuvCscStandardEXT TConstantUnion::getYuvCscStandardEXTConst() const
-{
- ASSERT(type == EbtYuvCscStandardEXT);
- return yuvCscStandardEXTConst;
-}
-
-bool TConstantUnion::cast(TBasicType newType, const TConstantUnion &constant)
-{
- switch (newType)
- {
- case EbtFloat:
- switch (constant.type)
- {
- case EbtInt:
- setFConst(static_cast<float>(constant.getIConst()));
- break;
- case EbtUInt:
- setFConst(static_cast<float>(constant.getUConst()));
- break;
- case EbtBool:
- setFConst(static_cast<float>(constant.getBConst()));
- break;
- case EbtFloat:
- setFConst(static_cast<float>(constant.getFConst()));
- break;
- default:
- return false;
- }
- break;
- case EbtInt:
- switch (constant.type)
- {
- case EbtInt:
- setIConst(static_cast<int>(constant.getIConst()));
- break;
- case EbtUInt:
- setIConst(static_cast<int>(constant.getUConst()));
- break;
- case EbtBool:
- setIConst(static_cast<int>(constant.getBConst()));
- break;
- case EbtFloat:
- setIConst(static_cast<int>(constant.getFConst()));
- break;
- default:
- return false;
- }
- break;
- case EbtUInt:
- switch (constant.type)
- {
- case EbtInt:
- setUConst(static_cast<unsigned int>(constant.getIConst()));
- break;
- case EbtUInt:
- setUConst(static_cast<unsigned int>(constant.getUConst()));
- break;
- case EbtBool:
- setUConst(static_cast<unsigned int>(constant.getBConst()));
- break;
- case EbtFloat:
- setUConst(static_cast<unsigned int>(constant.getFConst()));
- break;
- default:
- return false;
- }
- break;
- case EbtBool:
- switch (constant.type)
- {
- case EbtInt:
- setBConst(constant.getIConst() != 0);
- break;
- case EbtUInt:
- setBConst(constant.getUConst() != 0);
- break;
- case EbtBool:
- setBConst(constant.getBConst());
- break;
- case EbtFloat:
- setBConst(constant.getFConst() != 0.0f);
- break;
- default:
- return false;
- }
- break;
- case EbtStruct: // Struct fields don't get cast
- switch (constant.type)
- {
- case EbtInt:
- setIConst(constant.getIConst());
- break;
- case EbtUInt:
- setUConst(constant.getUConst());
- break;
- case EbtBool:
- setBConst(constant.getBConst());
- break;
- case EbtFloat:
- setFConst(constant.getFConst());
- break;
- default:
- return false;
- }
- break;
- default:
- return false;
- }
-
- return true;
-}
-
-bool TConstantUnion::operator==(const int i) const
-{
- return i == iConst;
-}
-
-bool TConstantUnion::operator==(const unsigned int u) const
-{
- return u == uConst;
-}
-
-bool TConstantUnion::operator==(const float f) const
-{
- return f == fConst;
-}
-
-bool TConstantUnion::operator==(const bool b) const
-{
- return b == bConst;
-}
-
-bool TConstantUnion::operator==(const TYuvCscStandardEXT s) const
-{
- return s == yuvCscStandardEXTConst;
-}
-
-bool TConstantUnion::operator==(const TConstantUnion &constant) const
-{
- if (constant.type != type)
- return false;
-
- switch (type)
- {
- case EbtInt:
- return constant.iConst == iConst;
- case EbtUInt:
- return constant.uConst == uConst;
- case EbtFloat:
- return constant.fConst == fConst;
- case EbtBool:
- return constant.bConst == bConst;
- case EbtYuvCscStandardEXT:
- return constant.yuvCscStandardEXTConst == yuvCscStandardEXTConst;
- default:
- return false;
- }
-}
-
-bool TConstantUnion::operator!=(const int i) const
-{
- return !operator==(i);
-}
-
-bool TConstantUnion::operator!=(const unsigned int u) const
-{
- return !operator==(u);
-}
-
-bool TConstantUnion::operator!=(const float f) const
-{
- return !operator==(f);
-}
-
-bool TConstantUnion::operator!=(const bool b) const
-{
- return !operator==(b);
-}
-
-bool TConstantUnion::operator!=(const TYuvCscStandardEXT s) const
-{
- return !operator==(s);
-}
-
-bool TConstantUnion::operator!=(const TConstantUnion &constant) const
-{
- return !operator==(constant);
-}
-
-bool TConstantUnion::operator>(const TConstantUnion &constant) const
-{
- ASSERT(type == constant.type);
- switch (type)
- {
- case EbtInt:
- return iConst > constant.iConst;
- case EbtUInt:
- return uConst > constant.uConst;
- case EbtFloat:
- return fConst > constant.fConst;
- default:
- return false; // Invalid operation, handled at semantic analysis
- }
-}
-
-bool TConstantUnion::operator<(const TConstantUnion &constant) const
-{
- ASSERT(type == constant.type);
- switch (type)
- {
- case EbtInt:
- return iConst < constant.iConst;
- case EbtUInt:
- return uConst < constant.uConst;
- case EbtFloat:
- return fConst < constant.fConst;
- default:
- return false; // Invalid operation, handled at semantic analysis
- }
-}
-
-// static
-TConstantUnion TConstantUnion::add(const TConstantUnion &lhs,
- const TConstantUnion &rhs,
- TDiagnostics *diag,
- const TSourceLoc &line)
-{
- TConstantUnion returnValue;
- ASSERT(lhs.type == rhs.type);
- switch (lhs.type)
- {
- case EbtInt:
- returnValue.setIConst(gl::WrappingSum<int>(lhs.iConst, rhs.iConst));
- break;
- case EbtUInt:
- returnValue.setUConst(gl::WrappingSum<unsigned int>(lhs.uConst, rhs.uConst));
- break;
- case EbtFloat:
- returnValue.setFConst(CheckedSum(lhs.fConst, rhs.fConst, diag, line));
- break;
- default:
- UNREACHABLE();
- }
-
- return returnValue;
-}
-
-// static
-TConstantUnion TConstantUnion::sub(const TConstantUnion &lhs,
- const TConstantUnion &rhs,
- TDiagnostics *diag,
- const TSourceLoc &line)
-{
- TConstantUnion returnValue;
- ASSERT(lhs.type == rhs.type);
- switch (lhs.type)
- {
- case EbtInt:
- returnValue.setIConst(gl::WrappingDiff<int>(lhs.iConst, rhs.iConst));
- break;
- case EbtUInt:
- returnValue.setUConst(gl::WrappingDiff<unsigned int>(lhs.uConst, rhs.uConst));
- break;
- case EbtFloat:
- returnValue.setFConst(CheckedDiff(lhs.fConst, rhs.fConst, diag, line));
- break;
- default:
- UNREACHABLE();
- }
-
- return returnValue;
-}
-
-// static
-TConstantUnion TConstantUnion::mul(const TConstantUnion &lhs,
- const TConstantUnion &rhs,
- TDiagnostics *diag,
- const TSourceLoc &line)
-{
- TConstantUnion returnValue;
- ASSERT(lhs.type == rhs.type);
- switch (lhs.type)
- {
- case EbtInt:
- returnValue.setIConst(gl::WrappingMul(lhs.iConst, rhs.iConst));
- break;
- case EbtUInt:
- // Unsigned integer math in C++ is defined to be done in modulo 2^n, so we rely on that
- // to implement wrapping multiplication.
- returnValue.setUConst(lhs.uConst * rhs.uConst);
- break;
- case EbtFloat:
- returnValue.setFConst(CheckedMul(lhs.fConst, rhs.fConst, diag, line));
- break;
- default:
- UNREACHABLE();
- }
-
- return returnValue;
-}
-
-TConstantUnion TConstantUnion::operator%(const TConstantUnion &constant) const
-{
- TConstantUnion returnValue;
- ASSERT(type == constant.type);
- switch (type)
- {
- case EbtInt:
- returnValue.setIConst(iConst % constant.iConst);
- break;
- case EbtUInt:
- returnValue.setUConst(uConst % constant.uConst);
- break;
- default:
- UNREACHABLE();
- }
-
- return returnValue;
-}
-
-// static
-TConstantUnion TConstantUnion::rshift(const TConstantUnion &lhs,
- const TConstantUnion &rhs,
- TDiagnostics *diag,
- const TSourceLoc &line)
-{
- TConstantUnion returnValue;
- ASSERT(lhs.type == EbtInt || lhs.type == EbtUInt);
- ASSERT(rhs.type == EbtInt || rhs.type == EbtUInt);
- if (!IsValidShiftOffset(rhs))
- {
- diag->warning(line, "Undefined shift (operand out of range)", ">>");
- switch (lhs.type)
- {
- case EbtInt:
- returnValue.setIConst(0);
- break;
- case EbtUInt:
- returnValue.setUConst(0u);
- break;
- default:
- UNREACHABLE();
- }
- return returnValue;
- }
-
- switch (lhs.type)
- {
- case EbtInt:
- {
- unsigned int shiftOffset = 0;
- switch (rhs.type)
- {
- case EbtInt:
- shiftOffset = static_cast<unsigned int>(rhs.iConst);
- break;
- case EbtUInt:
- shiftOffset = rhs.uConst;
- break;
- default:
- UNREACHABLE();
- }
- if (shiftOffset > 0)
- {
- // ESSL 3.00.6 section 5.9: "If E1 is a signed integer, the right-shift will extend
- // the sign bit." In C++ shifting negative integers is undefined, so we implement
- // extending the sign bit manually.
- int lhsSafe = lhs.iConst;
- if (lhsSafe == std::numeric_limits<int>::min())
- {
- // The min integer needs special treatment because only bit it has set is the
- // sign bit, which we clear later to implement safe right shift of negative
- // numbers.
- lhsSafe = -0x40000000;
- --shiftOffset;
- }
- if (shiftOffset > 0)
- {
- bool extendSignBit = false;
- if (lhsSafe < 0)
- {
- extendSignBit = true;
- // Clear the sign bit so that bitshift right is defined in C++.
- lhsSafe &= 0x7fffffff;
- ASSERT(lhsSafe > 0);
- }
- returnValue.setIConst(lhsSafe >> shiftOffset);
-
- // Manually fill in the extended sign bit if necessary.
- if (extendSignBit)
- {
- int extendedSignBit = static_cast<int>(0xffffffffu << (31 - shiftOffset));
- returnValue.setIConst(returnValue.getIConst() | extendedSignBit);
- }
- }
- else
- {
- returnValue.setIConst(lhsSafe);
- }
- }
- else
- {
- returnValue.setIConst(lhs.iConst);
- }
- break;
- }
- case EbtUInt:
- switch (rhs.type)
- {
- case EbtInt:
- returnValue.setUConst(lhs.uConst >> rhs.iConst);
- break;
- case EbtUInt:
- returnValue.setUConst(lhs.uConst >> rhs.uConst);
- break;
- default:
- UNREACHABLE();
- }
- break;
-
- default:
- UNREACHABLE();
- }
- return returnValue;
-}
-
-// static
-TConstantUnion TConstantUnion::lshift(const TConstantUnion &lhs,
- const TConstantUnion &rhs,
- TDiagnostics *diag,
- const TSourceLoc &line)
-{
- TConstantUnion returnValue;
- ASSERT(lhs.type == EbtInt || lhs.type == EbtUInt);
- ASSERT(rhs.type == EbtInt || rhs.type == EbtUInt);
- if (!IsValidShiftOffset(rhs))
- {
- diag->warning(line, "Undefined shift (operand out of range)", "<<");
- switch (lhs.type)
- {
- case EbtInt:
- returnValue.setIConst(0);
- break;
- case EbtUInt:
- returnValue.setUConst(0u);
- break;
- default:
- UNREACHABLE();
- }
- return returnValue;
- }
-
- switch (lhs.type)
- {
- case EbtInt:
- switch (rhs.type)
- {
- // Cast to unsigned integer before shifting, since ESSL 3.00.6 section 5.9 says that
- // lhs is "interpreted as a bit pattern". This also avoids the possibility of signed
- // integer overflow or undefined shift of a negative integer.
- case EbtInt:
- returnValue.setIConst(
- static_cast<int>(static_cast<uint32_t>(lhs.iConst) << rhs.iConst));
- break;
- case EbtUInt:
- returnValue.setIConst(
- static_cast<int>(static_cast<uint32_t>(lhs.iConst) << rhs.uConst));
- break;
- default:
- UNREACHABLE();
- }
- break;
-
- case EbtUInt:
- switch (rhs.type)
- {
- case EbtInt:
- returnValue.setUConst(lhs.uConst << rhs.iConst);
- break;
- case EbtUInt:
- returnValue.setUConst(lhs.uConst << rhs.uConst);
- break;
- default:
- UNREACHABLE();
- }
- break;
-
- default:
- UNREACHABLE();
- }
- return returnValue;
-}
-
-TConstantUnion TConstantUnion::operator&(const TConstantUnion &constant) const
-{
- TConstantUnion returnValue;
- ASSERT(constant.type == EbtInt || constant.type == EbtUInt);
- switch (type)
- {
- case EbtInt:
- returnValue.setIConst(iConst & constant.iConst);
- break;
- case EbtUInt:
- returnValue.setUConst(uConst & constant.uConst);
- break;
- default:
- UNREACHABLE();
- }
-
- return returnValue;
-}
-
-TConstantUnion TConstantUnion::operator|(const TConstantUnion &constant) const
-{
- TConstantUnion returnValue;
- ASSERT(type == constant.type);
- switch (type)
- {
- case EbtInt:
- returnValue.setIConst(iConst | constant.iConst);
- break;
- case EbtUInt:
- returnValue.setUConst(uConst | constant.uConst);
- break;
- default:
- UNREACHABLE();
- }
-
- return returnValue;
-}
-
-TConstantUnion TConstantUnion::operator^(const TConstantUnion &constant) const
-{
- TConstantUnion returnValue;
- ASSERT(type == constant.type);
- switch (type)
- {
- case EbtInt:
- returnValue.setIConst(iConst ^ constant.iConst);
- break;
- case EbtUInt:
- returnValue.setUConst(uConst ^ constant.uConst);
- break;
- default:
- UNREACHABLE();
- }
-
- return returnValue;
-}
-
-TConstantUnion TConstantUnion::operator&&(const TConstantUnion &constant) const
-{
- TConstantUnion returnValue;
- ASSERT(type == constant.type);
- switch (type)
- {
- case EbtBool:
- returnValue.setBConst(bConst && constant.bConst);
- break;
- default:
- UNREACHABLE();
- }
-
- return returnValue;
-}
-
-TConstantUnion TConstantUnion::operator||(const TConstantUnion &constant) const
-{
- TConstantUnion returnValue;
- ASSERT(type == constant.type);
- switch (type)
- {
- case EbtBool:
- returnValue.setBConst(bConst || constant.bConst);
- break;
- default:
- UNREACHABLE();
- }
-
- return returnValue;
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/ConstantUnion.h b/src/3rdparty/angle/src/compiler/translator/ConstantUnion.h
deleted file mode 100644
index c1b3db9070..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ConstantUnion.h
+++ /dev/null
@@ -1,117 +0,0 @@
-//
-// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_TRANSLATOR_CONSTANTUNION_H_
-#define COMPILER_TRANSLATOR_CONSTANTUNION_H_
-
-#include <assert.h>
-
-#include "compiler/translator/Common.h"
-#include "compiler/translator/BaseTypes.h"
-
-namespace sh
-{
-
-class TDiagnostics;
-
-class TConstantUnion
-{
- public:
- POOL_ALLOCATOR_NEW_DELETE();
- TConstantUnion();
-
- bool cast(TBasicType newType, const TConstantUnion &constant);
-
- void setIConst(int i)
- {
- iConst = i;
- type = EbtInt;
- }
- void setUConst(unsigned int u)
- {
- uConst = u;
- type = EbtUInt;
- }
- void setFConst(float f)
- {
- fConst = f;
- type = EbtFloat;
- }
- void setBConst(bool b)
- {
- bConst = b;
- type = EbtBool;
- }
-
- void setYuvCscStandardEXTConst(TYuvCscStandardEXT s)
- {
- yuvCscStandardEXTConst = s;
- type = EbtYuvCscStandardEXT;
- }
-
- int getIConst() const;
- unsigned int getUConst() const;
- float getFConst() const;
- bool getBConst() const;
- TYuvCscStandardEXT getYuvCscStandardEXTConst() const;
-
- bool operator==(const int i) const;
- bool operator==(const unsigned int u) const;
- bool operator==(const float f) const;
- bool operator==(const bool b) const;
- bool operator==(const TYuvCscStandardEXT s) const;
- bool operator==(const TConstantUnion &constant) const;
- bool operator!=(const int i) const;
- bool operator!=(const unsigned int u) const;
- bool operator!=(const float f) const;
- bool operator!=(const bool b) const;
- bool operator!=(const TYuvCscStandardEXT s) const;
- bool operator!=(const TConstantUnion &constant) const;
- bool operator>(const TConstantUnion &constant) const;
- bool operator<(const TConstantUnion &constant) const;
- static TConstantUnion add(const TConstantUnion &lhs,
- const TConstantUnion &rhs,
- TDiagnostics *diag,
- const TSourceLoc &line);
- static TConstantUnion sub(const TConstantUnion &lhs,
- const TConstantUnion &rhs,
- TDiagnostics *diag,
- const TSourceLoc &line);
- static TConstantUnion mul(const TConstantUnion &lhs,
- const TConstantUnion &rhs,
- TDiagnostics *diag,
- const TSourceLoc &line);
- TConstantUnion operator%(const TConstantUnion &constant) const;
- static TConstantUnion rshift(const TConstantUnion &lhs,
- const TConstantUnion &rhs,
- TDiagnostics *diag,
- const TSourceLoc &line);
- static TConstantUnion lshift(const TConstantUnion &lhs,
- const TConstantUnion &rhs,
- TDiagnostics *diag,
- const TSourceLoc &line);
- TConstantUnion operator&(const TConstantUnion &constant) const;
- TConstantUnion operator|(const TConstantUnion &constant) const;
- TConstantUnion operator^(const TConstantUnion &constant) const;
- TConstantUnion operator&&(const TConstantUnion &constant) const;
- TConstantUnion operator||(const TConstantUnion &constant) const;
-
- TBasicType getType() const { return type; }
- private:
- union {
- int iConst; // used for ivec, scalar ints
- unsigned int uConst; // used for uvec, scalar uints
- bool bConst; // used for bvec, scalar bools
- float fConst; // used for vec, mat, scalar floats
- TYuvCscStandardEXT yuvCscStandardEXTConst;
- };
-
- TBasicType type;
-};
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_CONSTANTUNION_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.cpp b/src/3rdparty/angle/src/compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.cpp
deleted file mode 100644
index ce9828f1f9..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-//
-// Copyright (c) 2017 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// Applies the necessary AST transformations to support multiview rendering through instancing.
-// Check the header file For more information.
-//
-
-#include "compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.h"
-
-#include "compiler/translator/FindMain.h"
-#include "compiler/translator/InitializeVariables.h"
-#include "compiler/translator/IntermNode_util.h"
-#include "compiler/translator/IntermTraverse.h"
-#include "compiler/translator/SymbolTable.h"
-#include "compiler/translator/util.h"
-
-namespace sh
-{
-
-namespace
-{
-
-class ReplaceVariableTraverser : public TIntermTraverser
-{
- public:
- ReplaceVariableTraverser(const TString &symbolName, TIntermSymbol *newSymbol)
- : TIntermTraverser(true, false, false), mSymbolName(symbolName), mNewSymbol(newSymbol)
- {
- }
-
- void visitSymbol(TIntermSymbol *node) override
- {
- TName &name = node->getName();
- if (name.getString() == mSymbolName)
- {
- queueReplacement(mNewSymbol->deepCopy(), OriginalNode::IS_DROPPED);
- }
- }
-
- private:
- TString mSymbolName;
- TIntermSymbol *mNewSymbol;
-};
-
-TIntermSymbol *CreateGLInstanceIDSymbol(const TSymbolTable &symbolTable)
-{
- return ReferenceBuiltInVariable("gl_InstanceID", symbolTable, 300);
-}
-
-// Adds the InstanceID and ViewID_OVR initializers to the end of the initializers' sequence.
-void InitializeViewIDAndInstanceID(TIntermTyped *viewIDSymbol,
- TIntermTyped *instanceIDSymbol,
- unsigned numberOfViews,
- const TSymbolTable &symbolTable,
- TIntermSequence *initializers)
-{
- // Create an unsigned numberOfViews node.
- TConstantUnion *numberOfViewsUnsignedConstant = new TConstantUnion();
- numberOfViewsUnsignedConstant->setUConst(numberOfViews);
- TIntermConstantUnion *numberOfViewsUint =
- new TIntermConstantUnion(numberOfViewsUnsignedConstant, TType(EbtUInt, EbpHigh, EvqConst));
-
- // Create a uint(gl_InstanceID) node.
- TIntermSequence *glInstanceIDSymbolCastArguments = new TIntermSequence();
- glInstanceIDSymbolCastArguments->push_back(CreateGLInstanceIDSymbol(symbolTable));
- TIntermAggregate *glInstanceIDAsUint = TIntermAggregate::CreateConstructor(
- TType(EbtUInt, EbpHigh, EvqTemporary), glInstanceIDSymbolCastArguments);
-
- // Create a uint(gl_InstanceID) / numberOfViews node.
- TIntermBinary *normalizedInstanceID =
- new TIntermBinary(EOpDiv, glInstanceIDAsUint, numberOfViewsUint);
-
- // Create an int(uint(gl_InstanceID) / numberOfViews) node.
- TIntermSequence *normalizedInstanceIDCastArguments = new TIntermSequence();
- normalizedInstanceIDCastArguments->push_back(normalizedInstanceID);
- TIntermAggregate *normalizedInstanceIDAsInt = TIntermAggregate::CreateConstructor(
- TType(EbtInt, EbpHigh, EvqTemporary), normalizedInstanceIDCastArguments);
-
- // Create an InstanceID = int(uint(gl_InstanceID) / numberOfViews) node.
- TIntermBinary *instanceIDInitializer =
- new TIntermBinary(EOpAssign, instanceIDSymbol->deepCopy(), normalizedInstanceIDAsInt);
- initializers->push_back(instanceIDInitializer);
-
- // Create a uint(gl_InstanceID) % numberOfViews node.
- TIntermBinary *normalizedViewID =
- new TIntermBinary(EOpIMod, glInstanceIDAsUint->deepCopy(), numberOfViewsUint->deepCopy());
-
- // Create a ViewID_OVR = uint(gl_InstanceID) % numberOfViews node.
- TIntermBinary *viewIDInitializer =
- new TIntermBinary(EOpAssign, viewIDSymbol->deepCopy(), normalizedViewID);
- initializers->push_back(viewIDInitializer);
-}
-
-// Replaces every occurrence of a symbol with the name specified in symbolName with newSymbolNode.
-void ReplaceSymbol(TIntermBlock *root, const TString &symbolName, TIntermSymbol *newSymbolNode)
-{
- ReplaceVariableTraverser traverser(symbolName, newSymbolNode);
- root->traverse(&traverser);
- traverser.updateTree();
-}
-
-void DeclareGlobalVariable(TIntermBlock *root, TIntermTyped *typedNode)
-{
- TIntermSequence *globalSequence = root->getSequence();
- TIntermDeclaration *declaration = new TIntermDeclaration();
- declaration->appendDeclarator(typedNode->deepCopy());
- globalSequence->insert(globalSequence->begin(), declaration);
-}
-
-// Adds a branch to write int(ViewID_OVR) to either gl_ViewportIndex or gl_Layer. The branch is
-// added to the end of the initializers' sequence.
-void SelectViewIndexInVertexShader(TIntermTyped *viewIDSymbol,
- TIntermTyped *multiviewBaseViewLayerIndexSymbol,
- TIntermSequence *initializers,
- const TSymbolTable &symbolTable)
-{
- // Create an int(ViewID_OVR) node.
- TIntermSequence *viewIDSymbolCastArguments = new TIntermSequence();
- viewIDSymbolCastArguments->push_back(viewIDSymbol);
- TIntermAggregate *viewIDAsInt = TIntermAggregate::CreateConstructor(
- TType(EbtInt, EbpHigh, EvqTemporary), viewIDSymbolCastArguments);
-
- // Create a gl_ViewportIndex node.
- TIntermSymbol *viewportIndexSymbol =
- ReferenceBuiltInVariable("gl_ViewportIndex", symbolTable, 0);
-
- // Create a { gl_ViewportIndex = int(ViewID_OVR) } node.
- TIntermBlock *viewportIndexInitializerInBlock = new TIntermBlock();
- viewportIndexInitializerInBlock->appendStatement(
- new TIntermBinary(EOpAssign, viewportIndexSymbol, viewIDAsInt));
-
- // Create a gl_Layer node.
- TIntermSymbol *layerSymbol = ReferenceBuiltInVariable("gl_Layer", symbolTable, 0);
-
- // Create an int(ViewID_OVR) + multiviewBaseViewLayerIndex node
- TIntermBinary *sumOfViewIDAndBaseViewIndex =
- new TIntermBinary(EOpAdd, viewIDAsInt->deepCopy(), multiviewBaseViewLayerIndexSymbol);
-
- // Create a { gl_Layer = int(ViewID_OVR) + multiviewBaseViewLayerIndex } node.
- TIntermBlock *layerInitializerInBlock = new TIntermBlock();
- layerInitializerInBlock->appendStatement(
- new TIntermBinary(EOpAssign, layerSymbol, sumOfViewIDAndBaseViewIndex));
-
- // Create a node to compare whether the base view index uniform is less than zero.
- TIntermBinary *multiviewBaseViewLayerIndexZeroComparison =
- new TIntermBinary(EOpLessThan, multiviewBaseViewLayerIndexSymbol->deepCopy(),
- CreateZeroNode(TType(EbtInt, EbpHigh, EvqConst)));
-
- // Create an if-else statement to select the code path.
- TIntermIfElse *multiviewBranch =
- new TIntermIfElse(multiviewBaseViewLayerIndexZeroComparison,
- viewportIndexInitializerInBlock, layerInitializerInBlock);
-
- initializers->push_back(multiviewBranch);
-}
-
-} // namespace
-
-void DeclareAndInitBuiltinsForInstancedMultiview(TIntermBlock *root,
- unsigned numberOfViews,
- GLenum shaderType,
- ShCompileOptions compileOptions,
- ShShaderOutput shaderOutput,
- TSymbolTable *symbolTable)
-{
- ASSERT(shaderType == GL_VERTEX_SHADER || shaderType == GL_FRAGMENT_SHADER);
-
- TQualifier viewIDQualifier = (shaderType == GL_VERTEX_SHADER) ? EvqFlatOut : EvqFlatIn;
- TIntermSymbol *viewIDSymbol = new TIntermSymbol(symbolTable->nextUniqueId(), "ViewID_OVR",
- TType(EbtUInt, EbpHigh, viewIDQualifier));
- viewIDSymbol->setInternal(true);
-
- DeclareGlobalVariable(root, viewIDSymbol);
- ReplaceSymbol(root, "gl_ViewID_OVR", viewIDSymbol);
- if (shaderType == GL_VERTEX_SHADER)
- {
- // Replacing gl_InstanceID with InstanceID should happen before adding the initializers of
- // InstanceID and ViewID.
- TIntermSymbol *instanceIDSymbol = new TIntermSymbol(
- symbolTable->nextUniqueId(), "InstanceID", TType(EbtInt, EbpHigh, EvqGlobal));
- instanceIDSymbol->setInternal(true);
- DeclareGlobalVariable(root, instanceIDSymbol);
- ReplaceSymbol(root, "gl_InstanceID", instanceIDSymbol);
-
- TIntermSequence *initializers = new TIntermSequence();
- InitializeViewIDAndInstanceID(viewIDSymbol, instanceIDSymbol, numberOfViews, *symbolTable,
- initializers);
-
- // The AST transformation which adds the expression to select the viewport index should
- // be done only for the GLSL and ESSL output.
- const bool selectView = (compileOptions & SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER) != 0u;
- // Assert that if the view is selected in the vertex shader, then the output is
- // either GLSL or ESSL.
- ASSERT(!selectView || IsOutputGLSL(shaderOutput) || IsOutputESSL(shaderOutput));
- if (selectView)
- {
- // Add a uniform to switch between side-by-side and layered rendering.
- TIntermSymbol *multiviewBaseViewLayerIndexSymbol =
- new TIntermSymbol(symbolTable->nextUniqueId(), "multiviewBaseViewLayerIndex",
- TType(EbtInt, EbpHigh, EvqUniform));
- multiviewBaseViewLayerIndexSymbol->setInternal(true);
- DeclareGlobalVariable(root, multiviewBaseViewLayerIndexSymbol);
-
- // Setting a value to gl_ViewportIndex or gl_Layer should happen after ViewID_OVR's
- // initialization.
- SelectViewIndexInVertexShader(viewIDSymbol->deepCopy(),
- multiviewBaseViewLayerIndexSymbol->deepCopy(),
- initializers, *symbolTable);
- }
-
- // Insert initializers at the beginning of main().
- TIntermBlock *initializersBlock = new TIntermBlock();
- initializersBlock->getSequence()->swap(*initializers);
- TIntermBlock *mainBody = FindMainBody(root);
- mainBody->getSequence()->insert(mainBody->getSequence()->begin(), initializersBlock);
- }
-}
-
-} // namespace sh \ No newline at end of file
diff --git a/src/3rdparty/angle/src/compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.h b/src/3rdparty/angle/src/compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.h
deleted file mode 100644
index b4ab05fd0e..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.h
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// Copyright (c) 2017 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// Regardless of the shader type, the following AST transformations are applied:
-// - Add declaration of View_ID_OVR.
-// - Replace every occurrence of gl_ViewID_OVR with ViewID_OVR, mark ViewID_OVR as internal and
-// declare it as a flat varying.
-//
-// If the shader type is a vertex shader, the following AST transformations are applied:
-// - Replace every occurrence of gl_InstanceID with InstanceID, mark InstanceID as internal and set
-// its qualifier to EvqTemporary.
-// - Add initializers of ViewID_OVR and InstanceID to the beginning of the body of main. The pass
-// should be executed before any variables get collected so that usage of gl_InstanceID is recorded.
-// - If the output is ESSL or GLSL and the SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER option is
-// enabled, the expression
-// "if (multiviewBaseViewLayerIndex < 0) {
-// gl_ViewportIndex = int(ViewID_OVR);
-// } else {
-// gl_Layer = int(ViewID_OVR) + multiviewBaseViewLayerIndex;
-// }"
-// is added after ViewID and InstanceID are initialized. Also, MultiviewRenderPath is added as a
-// uniform.
-//
-
-#ifndef COMPILER_TRANSLATOR_DECLAREANDINITBUILTINSFORINSTANCEDMULTIVIEW_H_
-#define COMPILER_TRANSLATOR_DECLAREANDINITBUILTINSFORINSTANCEDMULTIVIEW_H_
-
-#include "GLSLANG/ShaderLang.h"
-#include "angle_gl.h"
-
-namespace sh
-{
-
-class TIntermBlock;
-class TSymbolTable;
-
-void DeclareAndInitBuiltinsForInstancedMultiview(TIntermBlock *root,
- unsigned numberOfViews,
- GLenum shaderType,
- ShCompileOptions compileOptions,
- ShShaderOutput shaderOutput,
- TSymbolTable *symbolTable);
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_DECLAREANDINITBUILTINSFORINSTANCEDMULTIVIEW_H_ \ No newline at end of file
diff --git a/src/3rdparty/angle/src/compiler/translator/DeferGlobalInitializers.cpp b/src/3rdparty/angle/src/compiler/translator/DeferGlobalInitializers.cpp
deleted file mode 100644
index 67d51ea87b..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/DeferGlobalInitializers.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-//
-// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// DeferGlobalInitializers is an AST traverser that moves global initializers into a separate
-// function that is called in the beginning of main(). This enables initialization of globals with
-// uniforms or non-constant globals, as allowed by the WebGL spec. Some initializers referencing
-// non-constants may need to be unfolded into if statements in HLSL - this kind of steps should be
-// done after DeferGlobalInitializers is run. Note that it's important that the function definition
-// is at the end of the shader, as some globals may be declared after main().
-//
-// It can also initialize all uninitialized globals.
-//
-
-#include "compiler/translator/DeferGlobalInitializers.h"
-
-#include "compiler/translator/FindMain.h"
-#include "compiler/translator/InitializeVariables.h"
-#include "compiler/translator/IntermNode.h"
-#include "compiler/translator/IntermNode_util.h"
-#include "compiler/translator/SymbolTable.h"
-
-namespace sh
-{
-
-namespace
-{
-
-void GetDeferredInitializers(TIntermDeclaration *declaration,
- bool initializeUninitializedGlobals,
- bool canUseLoopsToInitialize,
- TIntermSequence *deferredInitializersOut,
- TSymbolTable *symbolTable)
-{
- // SeparateDeclarations should have already been run.
- ASSERT(declaration->getSequence()->size() == 1);
-
- TIntermNode *declarator = declaration->getSequence()->back();
- TIntermBinary *init = declarator->getAsBinaryNode();
- if (init)
- {
- TIntermSymbol *symbolNode = init->getLeft()->getAsSymbolNode();
- ASSERT(symbolNode);
- TIntermTyped *expression = init->getRight();
-
- if ((expression->getQualifier() != EvqConst ||
- (expression->getAsConstantUnion() == nullptr &&
- !expression->isConstructorWithOnlyConstantUnionParameters())))
- {
- // For variables which are not constant, defer their real initialization until
- // after we initialize uniforms.
- // Deferral is done also in any cases where the variable has not been constant
- // folded, since otherwise there's a chance that HLSL output will generate extra
- // statements from the initializer expression.
-
- // Change const global to a regular global if its initialization is deferred.
- // This can happen if ANGLE has not been able to fold the constant expression used
- // as an initializer.
- ASSERT(symbolNode->getQualifier() == EvqConst ||
- symbolNode->getQualifier() == EvqGlobal);
- if (symbolNode->getQualifier() == EvqConst)
- {
- symbolNode->getTypePointer()->setQualifier(EvqGlobal);
- }
-
- TIntermBinary *deferredInit =
- new TIntermBinary(EOpAssign, symbolNode->deepCopy(), init->getRight());
- deferredInitializersOut->push_back(deferredInit);
-
- // Remove the initializer from the global scope and just declare the global instead.
- declaration->replaceChildNode(init, symbolNode);
- }
- }
- else if (initializeUninitializedGlobals)
- {
- TIntermSymbol *symbolNode = declarator->getAsSymbolNode();
- ASSERT(symbolNode);
-
- // Ignore ANGLE internal variables.
- if (symbolNode->getName().isInternal())
- return;
-
- if (symbolNode->getQualifier() == EvqGlobal && symbolNode->getSymbol() != "")
- {
- TIntermSequence *initCode =
- CreateInitCode(symbolNode, canUseLoopsToInitialize, symbolTable);
- deferredInitializersOut->insert(deferredInitializersOut->end(), initCode->begin(),
- initCode->end());
- }
- }
-}
-
-void InsertInitCallToMain(TIntermBlock *root,
- TIntermSequence *deferredInitializers,
- TSymbolTable *symbolTable)
-{
- TIntermBlock *initGlobalsBlock = new TIntermBlock();
- initGlobalsBlock->getSequence()->swap(*deferredInitializers);
-
- TSymbolUniqueId initGlobalsFunctionId(symbolTable);
-
- const char *kInitGlobalsFunctionName = "initGlobals";
-
- TIntermFunctionPrototype *initGlobalsFunctionPrototype =
- CreateInternalFunctionPrototypeNode(TType(), kInitGlobalsFunctionName, initGlobalsFunctionId);
- root->getSequence()->insert(root->getSequence()->begin(), initGlobalsFunctionPrototype);
- TIntermFunctionDefinition *initGlobalsFunctionDefinition = CreateInternalFunctionDefinitionNode(
- TType(), kInitGlobalsFunctionName, initGlobalsBlock, initGlobalsFunctionId);
- root->appendStatement(initGlobalsFunctionDefinition);
-
- TIntermAggregate *initGlobalsCall = CreateInternalFunctionCallNode(
- TType(), kInitGlobalsFunctionName, initGlobalsFunctionId, new TIntermSequence());
-
- TIntermBlock *mainBody = FindMainBody(root);
- mainBody->getSequence()->insert(mainBody->getSequence()->begin(), initGlobalsCall);
-}
-
-} // namespace
-
-void DeferGlobalInitializers(TIntermBlock *root,
- bool initializeUninitializedGlobals,
- bool canUseLoopsToInitialize,
- TSymbolTable *symbolTable)
-{
- TIntermSequence *deferredInitializers = new TIntermSequence();
-
- // Loop over all global statements and process the declarations. This is simpler than using a
- // traverser.
- for (TIntermNode *statement : *root->getSequence())
- {
- TIntermDeclaration *declaration = statement->getAsDeclarationNode();
- if (declaration)
- {
- GetDeferredInitializers(declaration, initializeUninitializedGlobals,
- canUseLoopsToInitialize, deferredInitializers, symbolTable);
- }
- }
-
- // Add the function with initialization and the call to that.
- if (!deferredInitializers->empty())
- {
- InsertInitCallToMain(root, deferredInitializers, symbolTable);
- }
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/DeferGlobalInitializers.h b/src/3rdparty/angle/src/compiler/translator/DeferGlobalInitializers.h
deleted file mode 100644
index 86930a585f..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/DeferGlobalInitializers.h
+++ /dev/null
@@ -1,32 +0,0 @@
-//
-// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// DeferGlobalInitializers is an AST traverser that moves global initializers into a separate
-// function that is called in the beginning of main(). This enables initialization of globals with
-// uniforms or non-constant globals, as allowed by the WebGL spec. Some initializers referencing
-// non-constants may need to be unfolded into if statements in HLSL - this kind of steps should be
-// done after DeferGlobalInitializers is run. Note that it's important that the function definition
-// is at the end of the shader, as some globals may be declared after main().
-//
-// It can also initialize all uninitialized globals.
-//
-
-#ifndef COMPILER_TRANSLATOR_DEFERGLOBALINITIALIZERS_H_
-#define COMPILER_TRANSLATOR_DEFERGLOBALINITIALIZERS_H_
-
-namespace sh
-{
-
-class TIntermBlock;
-class TSymbolTable;
-
-void DeferGlobalInitializers(TIntermBlock *root,
- bool initializeUninitializedGlobals,
- bool canUseLoopsToInitialize,
- TSymbolTable *symbolTable);
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_DEFERGLOBALINITIALIZERS_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/Diagnostics.cpp b/src/3rdparty/angle/src/compiler/translator/Diagnostics.cpp
deleted file mode 100644
index 1744e5ab3e..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/Diagnostics.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-//
-// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/translator/Diagnostics.h"
-
-#include "common/debug.h"
-#include "compiler/preprocessor/SourceLocation.h"
-#include "compiler/translator/Common.h"
-#include "compiler/translator/InfoSink.h"
-
-namespace sh
-{
-
-TDiagnostics::TDiagnostics(TInfoSinkBase &infoSink)
- : mInfoSink(infoSink), mNumErrors(0), mNumWarnings(0)
-{
-}
-
-TDiagnostics::~TDiagnostics()
-{
-}
-
-void TDiagnostics::writeInfo(Severity severity,
- const pp::SourceLocation &loc,
- const char *reason,
- const char *token)
-{
- switch (severity)
- {
- case SH_ERROR:
- ++mNumErrors;
- break;
- case SH_WARNING:
- ++mNumWarnings;
- break;
- default:
- UNREACHABLE();
- break;
- }
-
- /* VC++ format: file(linenum) : error #: 'token' : extrainfo */
- mInfoSink.prefix(severity);
- mInfoSink.location(loc.file, loc.line);
- mInfoSink << "'" << token << "' : " << reason << "\n";
-}
-
-void TDiagnostics::globalError(const char *message)
-{
- ++mNumErrors;
- mInfoSink.prefix(SH_ERROR);
- mInfoSink << message << "\n";
-}
-
-void TDiagnostics::error(const pp::SourceLocation &loc, const char *reason, const char *token)
-{
- writeInfo(SH_ERROR, loc, reason, token);
-}
-
-void TDiagnostics::warning(const pp::SourceLocation &loc, const char *reason, const char *token)
-{
- writeInfo(SH_WARNING, loc, reason, token);
-}
-
-void TDiagnostics::error(const TSourceLoc &loc, const char *reason, const char *token)
-{
- pp::SourceLocation srcLoc;
- srcLoc.file = loc.first_file;
- srcLoc.line = loc.first_line;
- error(srcLoc, reason, token);
-}
-
-void TDiagnostics::warning(const TSourceLoc &loc, const char *reason, const char *token)
-{
- pp::SourceLocation srcLoc;
- srcLoc.file = loc.first_file;
- srcLoc.line = loc.first_line;
- warning(srcLoc, reason, token);
-}
-
-void TDiagnostics::print(ID id, const pp::SourceLocation &loc, const std::string &text)
-{
- writeInfo(isError(id) ? SH_ERROR : SH_WARNING, loc, message(id), text.c_str());
-}
-
-void TDiagnostics::resetErrorCount()
-{
- mNumErrors = 0;
- mNumWarnings = 0;
-}
-
-PerformanceDiagnostics::PerformanceDiagnostics(TDiagnostics *diagnostics)
- : mDiagnostics(diagnostics)
-{
- ASSERT(diagnostics);
-}
-
-void PerformanceDiagnostics::warning(const TSourceLoc &loc, const char *reason, const char *token)
-{
- mDiagnostics->warning(loc, reason, token);
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/Diagnostics.h b/src/3rdparty/angle/src/compiler/translator/Diagnostics.h
deleted file mode 100644
index 55b88991df..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/Diagnostics.h
+++ /dev/null
@@ -1,67 +0,0 @@
-//
-// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_TRANSLATOR_DIAGNOSTICS_H_
-#define COMPILER_TRANSLATOR_DIAGNOSTICS_H_
-
-#include "common/angleutils.h"
-#include "compiler/preprocessor/DiagnosticsBase.h"
-#include "compiler/translator/Severity.h"
-
-namespace sh
-{
-
-class TInfoSinkBase;
-struct TSourceLoc;
-
-class TDiagnostics : public pp::Diagnostics, angle::NonCopyable
-{
- public:
- TDiagnostics(TInfoSinkBase &infoSink);
- ~TDiagnostics() override;
-
- int numErrors() const { return mNumErrors; }
- int numWarnings() const { return mNumWarnings; }
-
- void error(const pp::SourceLocation &loc, const char *reason, const char *token);
- void warning(const pp::SourceLocation &loc, const char *reason, const char *token);
-
- void error(const TSourceLoc &loc, const char *reason, const char *token);
- void warning(const TSourceLoc &loc, const char *reason, const char *token);
-
- void globalError(const char *message);
-
- void resetErrorCount();
-
- protected:
- void writeInfo(Severity severity,
- const pp::SourceLocation &loc,
- const char *reason,
- const char *token);
-
- void print(ID id, const pp::SourceLocation &loc, const std::string &text) override;
-
- private:
- TInfoSinkBase &mInfoSink;
- int mNumErrors;
- int mNumWarnings;
-};
-
-// Diagnostics wrapper to use when the code is only allowed to generate warnings.
-class PerformanceDiagnostics : public angle::NonCopyable
-{
- public:
- PerformanceDiagnostics(TDiagnostics *diagnostics);
-
- void warning(const TSourceLoc &loc, const char *reason, const char *token);
-
- private:
- TDiagnostics *mDiagnostics;
-};
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_DIAGNOSTICS_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/DirectiveHandler.cpp b/src/3rdparty/angle/src/compiler/translator/DirectiveHandler.cpp
deleted file mode 100644
index 485e66670c..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/DirectiveHandler.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-//
-// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/translator/DirectiveHandler.h"
-
-#include <sstream>
-
-#include "angle_gl.h"
-#include "common/debug.h"
-#include "compiler/translator/Diagnostics.h"
-
-namespace sh
-{
-
-static TBehavior getBehavior(const std::string &str)
-{
- const char kRequire[] = "require";
- const char kEnable[] = "enable";
- const char kDisable[] = "disable";
- const char kWarn[] = "warn";
-
- if (str == kRequire)
- return EBhRequire;
- else if (str == kEnable)
- return EBhEnable;
- else if (str == kDisable)
- return EBhDisable;
- else if (str == kWarn)
- return EBhWarn;
- return EBhUndefined;
-}
-
-TDirectiveHandler::TDirectiveHandler(TExtensionBehavior &extBehavior,
- TDiagnostics &diagnostics,
- int &shaderVersion,
- sh::GLenum shaderType,
- bool debugShaderPrecisionSupported)
- : mExtensionBehavior(extBehavior),
- mDiagnostics(diagnostics),
- mShaderVersion(shaderVersion),
- mShaderType(shaderType),
- mDebugShaderPrecisionSupported(debugShaderPrecisionSupported)
-{
-}
-
-TDirectiveHandler::~TDirectiveHandler()
-{
-}
-
-void TDirectiveHandler::handleError(const pp::SourceLocation &loc, const std::string &msg)
-{
- mDiagnostics.error(loc, msg.c_str(), "");
-}
-
-void TDirectiveHandler::handlePragma(const pp::SourceLocation &loc,
- const std::string &name,
- const std::string &value,
- bool stdgl)
-{
- if (stdgl)
- {
- const char kInvariant[] = "invariant";
- const char kAll[] = "all";
-
- if (name == kInvariant && value == kAll)
- {
- if (mShaderVersion == 300 && mShaderType == GL_FRAGMENT_SHADER)
- {
- // ESSL 3.00.4 section 4.6.1
- mDiagnostics.error(
- loc, "#pragma STDGL invariant(all) can not be used in fragment shader",
- name.c_str());
- }
- mPragma.stdgl.invariantAll = true;
- }
- // The STDGL pragma is used to reserve pragmas for use by future
- // revisions of GLSL. Do not generate an error on unexpected
- // name and value.
- return;
- }
- else
- {
- const char kOptimize[] = "optimize";
- const char kDebug[] = "debug";
- const char kDebugShaderPrecision[] = "webgl_debug_shader_precision";
- const char kOn[] = "on";
- const char kOff[] = "off";
-
- bool invalidValue = false;
- if (name == kOptimize)
- {
- if (value == kOn)
- mPragma.optimize = true;
- else if (value == kOff)
- mPragma.optimize = false;
- else
- invalidValue = true;
- }
- else if (name == kDebug)
- {
- if (value == kOn)
- mPragma.debug = true;
- else if (value == kOff)
- mPragma.debug = false;
- else
- invalidValue = true;
- }
- else if (name == kDebugShaderPrecision && mDebugShaderPrecisionSupported)
- {
- if (value == kOn)
- mPragma.debugShaderPrecision = true;
- else if (value == kOff)
- mPragma.debugShaderPrecision = false;
- else
- invalidValue = true;
- }
- else
- {
- mDiagnostics.report(pp::Diagnostics::PP_UNRECOGNIZED_PRAGMA, loc, name);
- return;
- }
-
- if (invalidValue)
- {
- mDiagnostics.error(loc, "invalid pragma value - 'on' or 'off' expected", value.c_str());
- }
- }
-}
-
-void TDirectiveHandler::handleExtension(const pp::SourceLocation &loc,
- const std::string &name,
- const std::string &behavior)
-{
- const char kExtAll[] = "all";
-
- TBehavior behaviorVal = getBehavior(behavior);
- if (behaviorVal == EBhUndefined)
- {
- mDiagnostics.error(loc, "behavior invalid", name.c_str());
- return;
- }
-
- if (name == kExtAll)
- {
- if (behaviorVal == EBhRequire)
- {
- mDiagnostics.error(loc, "extension cannot have 'require' behavior", name.c_str());
- }
- else if (behaviorVal == EBhEnable)
- {
- mDiagnostics.error(loc, "extension cannot have 'enable' behavior", name.c_str());
- }
- else
- {
- for (TExtensionBehavior::iterator iter = mExtensionBehavior.begin();
- iter != mExtensionBehavior.end(); ++iter)
- iter->second = behaviorVal;
- }
- return;
- }
-
- TExtensionBehavior::iterator iter = mExtensionBehavior.find(GetExtensionByName(name.c_str()));
- if (iter != mExtensionBehavior.end())
- {
- iter->second = behaviorVal;
- return;
- }
-
- switch (behaviorVal)
- {
- case EBhRequire:
- mDiagnostics.error(loc, "extension is not supported", name.c_str());
- break;
- case EBhEnable:
- case EBhWarn:
- case EBhDisable:
- mDiagnostics.warning(loc, "extension is not supported", name.c_str());
- break;
- default:
- UNREACHABLE();
- break;
- }
-}
-
-void TDirectiveHandler::handleVersion(const pp::SourceLocation &loc, int version)
-{
- if (version == 100 || version == 300 || version == 310)
- {
- mShaderVersion = version;
- }
- else
- {
- std::stringstream stream;
- stream << version;
- std::string str = stream.str();
- mDiagnostics.error(loc, "version number not supported", str.c_str());
- }
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/DirectiveHandler.h b/src/3rdparty/angle/src/compiler/translator/DirectiveHandler.h
deleted file mode 100644
index 8e8cb9bbf6..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/DirectiveHandler.h
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_TRANSLATOR_DIRECTIVEHANDLER_H_
-#define COMPILER_TRANSLATOR_DIRECTIVEHANDLER_H_
-
-#include "common/angleutils.h"
-#include "compiler/translator/ExtensionBehavior.h"
-#include "compiler/translator/Pragma.h"
-#include "compiler/preprocessor/DirectiveHandlerBase.h"
-#include "GLSLANG/ShaderLang.h"
-
-namespace sh
-{
-class TDiagnostics;
-
-class TDirectiveHandler : public pp::DirectiveHandler, angle::NonCopyable
-{
- public:
- TDirectiveHandler(TExtensionBehavior &extBehavior,
- TDiagnostics &diagnostics,
- int &shaderVersion,
- sh::GLenum shaderType,
- bool debugShaderPrecisionSupported);
- ~TDirectiveHandler() override;
-
- const TPragma &pragma() const { return mPragma; }
- const TExtensionBehavior &extensionBehavior() const { return mExtensionBehavior; }
-
- void handleError(const pp::SourceLocation &loc, const std::string &msg) override;
-
- void handlePragma(const pp::SourceLocation &loc,
- const std::string &name,
- const std::string &value,
- bool stdgl) override;
-
- void handleExtension(const pp::SourceLocation &loc,
- const std::string &name,
- const std::string &behavior) override;
-
- void handleVersion(const pp::SourceLocation &loc, int version) override;
-
- private:
- TPragma mPragma;
- TExtensionBehavior &mExtensionBehavior;
- TDiagnostics &mDiagnostics;
- int &mShaderVersion;
- sh::GLenum mShaderType;
- bool mDebugShaderPrecisionSupported;
-};
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_DIRECTIVEHANDLER_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/EmulateGLFragColorBroadcast.cpp b/src/3rdparty/angle/src/compiler/translator/EmulateGLFragColorBroadcast.cpp
deleted file mode 100644
index 189ea341eb..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/EmulateGLFragColorBroadcast.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-//
-// Copyright (c) 2002-2016 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// gl_FragColor needs to broadcast to all color buffers in ES2 if
-// GL_EXT_draw_buffers is explicitly enabled in a fragment shader.
-//
-// We emulate this by replacing all gl_FragColor with gl_FragData[0], and in the end
-// of main() function, assigning gl_FragData[1], ..., gl_FragData[maxDrawBuffers-1]
-// with gl_FragData[0].
-//
-
-#include "compiler/translator/EmulateGLFragColorBroadcast.h"
-
-#include "compiler/translator/IntermNode_util.h"
-#include "compiler/translator/IntermTraverse.h"
-#include "compiler/translator/RunAtTheEndOfShader.h"
-
-namespace sh
-{
-
-namespace
-{
-
-class GLFragColorBroadcastTraverser : public TIntermTraverser
-{
- public:
- GLFragColorBroadcastTraverser(int maxDrawBuffers, TSymbolTable *symbolTable, int shaderVersion)
- : TIntermTraverser(true, false, false, symbolTable),
- mGLFragColorUsed(false),
- mMaxDrawBuffers(maxDrawBuffers),
- mShaderVersion(shaderVersion)
- {
- }
-
- void broadcastGLFragColor(TIntermBlock *root);
-
- bool isGLFragColorUsed() const { return mGLFragColorUsed; }
-
- protected:
- void visitSymbol(TIntermSymbol *node) override;
-
- TIntermBinary *constructGLFragDataNode(int index) const;
- TIntermBinary *constructGLFragDataAssignNode(int index) const;
-
- private:
- bool mGLFragColorUsed;
- int mMaxDrawBuffers;
- const int mShaderVersion;
-};
-
-TIntermBinary *GLFragColorBroadcastTraverser::constructGLFragDataNode(int index) const
-{
- TIntermSymbol *symbol =
- ReferenceBuiltInVariable(TString("gl_FragData"), *mSymbolTable, mShaderVersion);
- TIntermTyped *indexNode = CreateIndexNode(index);
-
- TIntermBinary *binary = new TIntermBinary(EOpIndexDirect, symbol, indexNode);
- return binary;
-}
-
-TIntermBinary *GLFragColorBroadcastTraverser::constructGLFragDataAssignNode(int index) const
-{
- TIntermTyped *fragDataIndex = constructGLFragDataNode(index);
- TIntermTyped *fragDataZero = constructGLFragDataNode(0);
-
- return new TIntermBinary(EOpAssign, fragDataIndex, fragDataZero);
-}
-
-void GLFragColorBroadcastTraverser::visitSymbol(TIntermSymbol *node)
-{
- if (node->getSymbol() == "gl_FragColor")
- {
- queueReplacement(constructGLFragDataNode(0), OriginalNode::IS_DROPPED);
- mGLFragColorUsed = true;
- }
-}
-
-void GLFragColorBroadcastTraverser::broadcastGLFragColor(TIntermBlock *root)
-{
- ASSERT(mMaxDrawBuffers > 1);
- if (!mGLFragColorUsed)
- {
- return;
- }
-
- TIntermBlock *broadcastBlock = new TIntermBlock();
- // Now insert statements
- // gl_FragData[1] = gl_FragData[0];
- // ...
- // gl_FragData[maxDrawBuffers - 1] = gl_FragData[0];
- for (int colorIndex = 1; colorIndex < mMaxDrawBuffers; ++colorIndex)
- {
- broadcastBlock->appendStatement(constructGLFragDataAssignNode(colorIndex));
- }
- RunAtTheEndOfShader(root, broadcastBlock, mSymbolTable);
-}
-
-} // namespace anonymous
-
-void EmulateGLFragColorBroadcast(TIntermBlock *root,
- int maxDrawBuffers,
- std::vector<sh::OutputVariable> *outputVariables,
- TSymbolTable *symbolTable,
- int shaderVersion)
-{
- ASSERT(maxDrawBuffers > 1);
- GLFragColorBroadcastTraverser traverser(maxDrawBuffers, symbolTable, shaderVersion);
- root->traverse(&traverser);
- if (traverser.isGLFragColorUsed())
- {
- traverser.updateTree();
- traverser.broadcastGLFragColor(root);
- for (auto &var : *outputVariables)
- {
- if (var.name == "gl_FragColor")
- {
- // TODO(zmo): Find a way to keep the original variable information.
- var.name = "gl_FragData";
- var.mappedName = "gl_FragData";
- var.arraySizes.push_back(maxDrawBuffers);
- ASSERT(var.arraySizes.size() == 1u);
- }
- }
- }
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/EmulateGLFragColorBroadcast.h b/src/3rdparty/angle/src/compiler/translator/EmulateGLFragColorBroadcast.h
deleted file mode 100644
index e652b7e07e..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/EmulateGLFragColorBroadcast.h
+++ /dev/null
@@ -1,31 +0,0 @@
-//
-// Copyright (c) 2002-2016 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// Emulate gl_FragColor broadcast behaviors in ES2 where
-// GL_EXT_draw_buffers is explicitly enabled in a fragment shader.
-//
-
-#ifndef COMPILER_TRANSLATOR_EMULATEGLFRAGCOLORBROADCAST_H_
-#define COMPILER_TRANSLATOR_EMULATEGLFRAGCOLORBROADCAST_H_
-
-#include <vector>
-
-namespace sh
-{
-struct OutputVariable;
-class TIntermBlock;
-class TSymbolTable;
-
-// Replace all gl_FragColor with gl_FragData[0], and in the end of main() function,
-// assign gl_FragData[1] ... gl_FragData[maxDrawBuffers - 1] with gl_FragData[0].
-// If gl_FragColor is in outputVariables, it is replaced by gl_FragData.
-void EmulateGLFragColorBroadcast(TIntermBlock *root,
- int maxDrawBuffers,
- std::vector<OutputVariable> *outputVariables,
- TSymbolTable *symbolTable,
- int shaderVersion);
-}
-
-#endif // COMPILER_TRANSLATOR_EMULATEGLFRAGCOLORBROADCAST_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/EmulatePrecision.cpp b/src/3rdparty/angle/src/compiler/translator/EmulatePrecision.cpp
deleted file mode 100644
index ba09fd77df..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/EmulatePrecision.cpp
+++ /dev/null
@@ -1,751 +0,0 @@
-//
-// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/translator/EmulatePrecision.h"
-
-#include <memory>
-
-namespace sh
-{
-
-namespace
-{
-
-class RoundingHelperWriter : angle::NonCopyable
-{
- public:
- static RoundingHelperWriter *createHelperWriter(const ShShaderOutput outputLanguage);
-
- void writeCommonRoundingHelpers(TInfoSinkBase &sink, const int shaderVersion);
- void writeCompoundAssignmentHelper(TInfoSinkBase &sink,
- const char *lType,
- const char *rType,
- const char *opStr,
- const char *opNameStr);
-
- virtual ~RoundingHelperWriter() {}
-
- protected:
- RoundingHelperWriter(const ShShaderOutput outputLanguage) : mOutputLanguage(outputLanguage) {}
- RoundingHelperWriter() = delete;
-
- const ShShaderOutput mOutputLanguage;
-
- private:
- virtual std::string getTypeString(const char *glslType) = 0;
- virtual void writeFloatRoundingHelpers(TInfoSinkBase &sink) = 0;
- virtual void writeVectorRoundingHelpers(TInfoSinkBase &sink, const unsigned int size) = 0;
- virtual void writeMatrixRoundingHelper(TInfoSinkBase &sink,
- const unsigned int columns,
- const unsigned int rows,
- const char *functionName) = 0;
-};
-
-class RoundingHelperWriterGLSL : public RoundingHelperWriter
-{
- public:
- RoundingHelperWriterGLSL(const ShShaderOutput outputLanguage)
- : RoundingHelperWriter(outputLanguage)
- {
- }
-
- private:
- std::string getTypeString(const char *glslType) override;
- void writeFloatRoundingHelpers(TInfoSinkBase &sink) override;
- void writeVectorRoundingHelpers(TInfoSinkBase &sink, const unsigned int size) override;
- void writeMatrixRoundingHelper(TInfoSinkBase &sink,
- const unsigned int columns,
- const unsigned int rows,
- const char *functionName) override;
-};
-
-class RoundingHelperWriterESSL : public RoundingHelperWriterGLSL
-{
- public:
- RoundingHelperWriterESSL(const ShShaderOutput outputLanguage)
- : RoundingHelperWriterGLSL(outputLanguage)
- {
- }
-
- private:
- std::string getTypeString(const char *glslType) override;
-};
-
-class RoundingHelperWriterHLSL : public RoundingHelperWriter
-{
- public:
- RoundingHelperWriterHLSL(const ShShaderOutput outputLanguage)
- : RoundingHelperWriter(outputLanguage)
- {
- }
-
- private:
- std::string getTypeString(const char *glslType) override;
- void writeFloatRoundingHelpers(TInfoSinkBase &sink) override;
- void writeVectorRoundingHelpers(TInfoSinkBase &sink, const unsigned int size) override;
- void writeMatrixRoundingHelper(TInfoSinkBase &sink,
- const unsigned int columns,
- const unsigned int rows,
- const char *functionName) override;
-};
-
-RoundingHelperWriter *RoundingHelperWriter::createHelperWriter(const ShShaderOutput outputLanguage)
-{
- ASSERT(EmulatePrecision::SupportedInLanguage(outputLanguage));
- switch (outputLanguage)
- {
- case SH_HLSL_4_1_OUTPUT:
- return new RoundingHelperWriterHLSL(outputLanguage);
- case SH_ESSL_OUTPUT:
- return new RoundingHelperWriterESSL(outputLanguage);
- default:
- return new RoundingHelperWriterGLSL(outputLanguage);
- }
-}
-
-void RoundingHelperWriter::writeCommonRoundingHelpers(TInfoSinkBase &sink, const int shaderVersion)
-{
- // Write the angle_frm functions that round floating point numbers to
- // half precision, and angle_frl functions that round them to minimum lowp
- // precision.
-
- writeFloatRoundingHelpers(sink);
- writeVectorRoundingHelpers(sink, 2);
- writeVectorRoundingHelpers(sink, 3);
- writeVectorRoundingHelpers(sink, 4);
- if (shaderVersion > 100)
- {
- for (unsigned int columns = 2; columns <= 4; ++columns)
- {
- for (unsigned int rows = 2; rows <= 4; ++rows)
- {
- writeMatrixRoundingHelper(sink, columns, rows, "angle_frm");
- writeMatrixRoundingHelper(sink, columns, rows, "angle_frl");
- }
- }
- }
- else
- {
- for (unsigned int size = 2; size <= 4; ++size)
- {
- writeMatrixRoundingHelper(sink, size, size, "angle_frm");
- writeMatrixRoundingHelper(sink, size, size, "angle_frl");
- }
- }
-}
-
-void RoundingHelperWriter::writeCompoundAssignmentHelper(TInfoSinkBase &sink,
- const char *lType,
- const char *rType,
- const char *opStr,
- const char *opNameStr)
-{
- std::string lTypeStr = getTypeString(lType);
- std::string rTypeStr = getTypeString(rType);
-
- // Note that y should be passed through angle_frm at the function call site,
- // but x can't be passed through angle_frm there since it is an inout parameter.
- // So only pass x and the result through angle_frm here.
- // clang-format off
- sink <<
- lTypeStr << " angle_compound_" << opNameStr << "_frm(inout " << lTypeStr << " x, in " << rTypeStr << " y) {\n"
- " x = angle_frm(angle_frm(x) " << opStr << " y);\n"
- " return x;\n"
- "}\n";
- sink <<
- lTypeStr << " angle_compound_" << opNameStr << "_frl(inout " << lTypeStr << " x, in " << rTypeStr << " y) {\n"
- " x = angle_frl(angle_frl(x) " << opStr << " y);\n"
- " return x;\n"
- "}\n";
- // clang-format on
-}
-
-std::string RoundingHelperWriterGLSL::getTypeString(const char *glslType)
-{
- return glslType;
-}
-
-std::string RoundingHelperWriterESSL::getTypeString(const char *glslType)
-{
- std::stringstream typeStrStr;
- typeStrStr << "highp " << glslType;
- return typeStrStr.str();
-}
-
-void RoundingHelperWriterGLSL::writeFloatRoundingHelpers(TInfoSinkBase &sink)
-{
- // Unoptimized version of angle_frm for single floats:
- //
- // int webgl_maxNormalExponent(in int exponentBits)
- // {
- // int possibleExponents = int(exp2(float(exponentBits)));
- // int exponentBias = possibleExponents / 2 - 1;
- // int allExponentBitsOne = possibleExponents - 1;
- // return (allExponentBitsOne - 1) - exponentBias;
- // }
- //
- // float angle_frm(in float x)
- // {
- // int mantissaBits = 10;
- // int exponentBits = 5;
- // float possibleMantissas = exp2(float(mantissaBits));
- // float mantissaMax = 2.0 - 1.0 / possibleMantissas;
- // int maxNE = webgl_maxNormalExponent(exponentBits);
- // float max = exp2(float(maxNE)) * mantissaMax;
- // if (x > max)
- // {
- // return max;
- // }
- // if (x < -max)
- // {
- // return -max;
- // }
- // float exponent = floor(log2(abs(x)));
- // if (abs(x) == 0.0 || exponent < -float(maxNE))
- // {
- // return 0.0 * sign(x)
- // }
- // x = x * exp2(-(exponent - float(mantissaBits)));
- // x = sign(x) * floor(abs(x));
- // return x * exp2(exponent - float(mantissaBits));
- // }
-
- // All numbers with a magnitude less than 2^-15 are subnormal, and are
- // flushed to zero.
-
- // Note the constant numbers below:
- // a) 65504 is the maximum possible mantissa (1.1111111111 in binary) times
- // 2^15, the maximum normal exponent.
- // b) 10.0 is the number of mantissa bits.
- // c) -25.0 is the minimum normal half-float exponent -15.0 minus the number
- // of mantissa bits.
- // d) + 1e-30 is to make sure the argument of log2() won't be zero. It can
- // only affect the result of log2 on x where abs(x) < 1e-22. Since these
- // numbers will be flushed to zero either way (2^-15 is the smallest
- // normal positive number), this does not introduce any error.
-
- std::string floatType = getTypeString("float");
-
- // clang-format off
- sink <<
- floatType << " angle_frm(in " << floatType << " x) {\n"
- " x = clamp(x, -65504.0, 65504.0);\n"
- " " << floatType << " exponent = floor(log2(abs(x) + 1e-30)) - 10.0;\n"
- " bool isNonZero = (exponent >= -25.0);\n"
- " x = x * exp2(-exponent);\n"
- " x = sign(x) * floor(abs(x));\n"
- " return x * exp2(exponent) * float(isNonZero);\n"
- "}\n";
-
- sink <<
- floatType << " angle_frl(in " << floatType << " x) {\n"
- " x = clamp(x, -2.0, 2.0);\n"
- " x = x * 256.0;\n"
- " x = sign(x) * floor(abs(x));\n"
- " return x * 0.00390625;\n"
- "}\n";
- // clang-format on
-}
-
-void RoundingHelperWriterGLSL::writeVectorRoundingHelpers(TInfoSinkBase &sink,
- const unsigned int size)
-{
- std::stringstream vecTypeStrStr;
- vecTypeStrStr << "vec" << size;
- std::string vecType = getTypeString(vecTypeStrStr.str().c_str());
-
- // clang-format off
- sink <<
- vecType << " angle_frm(in " << vecType << " v) {\n"
- " v = clamp(v, -65504.0, 65504.0);\n"
- " " << vecType << " exponent = floor(log2(abs(v) + 1e-30)) - 10.0;\n"
- " bvec" << size << " isNonZero = greaterThanEqual(exponent, vec" << size << "(-25.0));\n"
- " v = v * exp2(-exponent);\n"
- " v = sign(v) * floor(abs(v));\n"
- " return v * exp2(exponent) * vec" << size << "(isNonZero);\n"
- "}\n";
-
- sink <<
- vecType << " angle_frl(in " << vecType << " v) {\n"
- " v = clamp(v, -2.0, 2.0);\n"
- " v = v * 256.0;\n"
- " v = sign(v) * floor(abs(v));\n"
- " return v * 0.00390625;\n"
- "}\n";
- // clang-format on
-}
-
-void RoundingHelperWriterGLSL::writeMatrixRoundingHelper(TInfoSinkBase &sink,
- const unsigned int columns,
- const unsigned int rows,
- const char *functionName)
-{
- std::stringstream matTypeStrStr;
- matTypeStrStr << "mat" << columns;
- if (rows != columns)
- {
- matTypeStrStr << "x" << rows;
- }
- std::string matType = getTypeString(matTypeStrStr.str().c_str());
-
- sink << matType << " " << functionName << "(in " << matType << " m) {\n"
- << " " << matType << " rounded;\n";
-
- for (unsigned int i = 0; i < columns; ++i)
- {
- sink << " rounded[" << i << "] = " << functionName << "(m[" << i << "]);\n";
- }
-
- sink << " return rounded;\n"
- "}\n";
-}
-
-static const char *GetHLSLTypeStr(const char *floatTypeStr)
-{
- if (strcmp(floatTypeStr, "float") == 0)
- {
- return "float";
- }
- if (strcmp(floatTypeStr, "vec2") == 0)
- {
- return "float2";
- }
- if (strcmp(floatTypeStr, "vec3") == 0)
- {
- return "float3";
- }
- if (strcmp(floatTypeStr, "vec4") == 0)
- {
- return "float4";
- }
- if (strcmp(floatTypeStr, "mat2") == 0)
- {
- return "float2x2";
- }
- if (strcmp(floatTypeStr, "mat3") == 0)
- {
- return "float3x3";
- }
- if (strcmp(floatTypeStr, "mat4") == 0)
- {
- return "float4x4";
- }
- if (strcmp(floatTypeStr, "mat2x3") == 0)
- {
- return "float2x3";
- }
- if (strcmp(floatTypeStr, "mat2x4") == 0)
- {
- return "float2x4";
- }
- if (strcmp(floatTypeStr, "mat3x2") == 0)
- {
- return "float3x2";
- }
- if (strcmp(floatTypeStr, "mat3x4") == 0)
- {
- return "float3x4";
- }
- if (strcmp(floatTypeStr, "mat4x2") == 0)
- {
- return "float4x2";
- }
- if (strcmp(floatTypeStr, "mat4x3") == 0)
- {
- return "float4x3";
- }
- UNREACHABLE();
- return nullptr;
-}
-
-std::string RoundingHelperWriterHLSL::getTypeString(const char *glslType)
-{
- return GetHLSLTypeStr(glslType);
-}
-
-void RoundingHelperWriterHLSL::writeFloatRoundingHelpers(TInfoSinkBase &sink)
-{
- // In HLSL scalars are the same as 1-vectors.
- writeVectorRoundingHelpers(sink, 1);
-}
-
-void RoundingHelperWriterHLSL::writeVectorRoundingHelpers(TInfoSinkBase &sink,
- const unsigned int size)
-{
- std::stringstream vecTypeStrStr;
- vecTypeStrStr << "float" << size;
- std::string vecType = vecTypeStrStr.str();
-
- // clang-format off
- sink <<
- vecType << " angle_frm(" << vecType << " v) {\n"
- " v = clamp(v, -65504.0, 65504.0);\n"
- " " << vecType << " exponent = floor(log2(abs(v) + 1e-30)) - 10.0;\n"
- " bool" << size << " isNonZero = exponent < -25.0;\n"
- " v = v * exp2(-exponent);\n"
- " v = sign(v) * floor(abs(v));\n"
- " return v * exp2(exponent) * (float" << size << ")(isNonZero);\n"
- "}\n";
-
- sink <<
- vecType << " angle_frl(" << vecType << " v) {\n"
- " v = clamp(v, -2.0, 2.0);\n"
- " v = v * 256.0;\n"
- " v = sign(v) * floor(abs(v));\n"
- " return v * 0.00390625;\n"
- "}\n";
- // clang-format on
-}
-
-void RoundingHelperWriterHLSL::writeMatrixRoundingHelper(TInfoSinkBase &sink,
- const unsigned int columns,
- const unsigned int rows,
- const char *functionName)
-{
- std::stringstream matTypeStrStr;
- matTypeStrStr << "float" << columns << "x" << rows;
- std::string matType = matTypeStrStr.str();
-
- sink << matType << " " << functionName << "(" << matType << " m) {\n"
- << " " << matType << " rounded;\n";
-
- for (unsigned int i = 0; i < columns; ++i)
- {
- sink << " rounded[" << i << "] = " << functionName << "(m[" << i << "]);\n";
- }
-
- sink << " return rounded;\n"
- "}\n";
-}
-
-bool canRoundFloat(const TType &type)
-{
- return type.getBasicType() == EbtFloat && !type.isArray() &&
- (type.getPrecision() == EbpLow || type.getPrecision() == EbpMedium);
-}
-
-TIntermAggregate *createInternalFunctionCallNode(const TType &type,
- TString name,
- TIntermSequence *arguments)
-{
- TName nameObj(name);
- nameObj.setInternal(true);
- TIntermAggregate *callNode =
- TIntermAggregate::Create(type, EOpCallInternalRawFunction, arguments);
- callNode->getFunctionSymbolInfo()->setNameObj(nameObj);
- return callNode;
-}
-
-TIntermAggregate *createRoundingFunctionCallNode(TIntermTyped *roundedChild)
-{
- TString roundFunctionName;
- if (roundedChild->getPrecision() == EbpMedium)
- roundFunctionName = "angle_frm";
- else
- roundFunctionName = "angle_frl";
- TIntermSequence *arguments = new TIntermSequence();
- arguments->push_back(roundedChild);
- TIntermAggregate *callNode =
- createInternalFunctionCallNode(roundedChild->getType(), roundFunctionName, arguments);
- callNode->getFunctionSymbolInfo()->setKnownToNotHaveSideEffects(true);
- return callNode;
-}
-
-TIntermAggregate *createCompoundAssignmentFunctionCallNode(TIntermTyped *left,
- TIntermTyped *right,
- const char *opNameStr)
-{
- std::stringstream strstr;
- if (left->getPrecision() == EbpMedium)
- strstr << "angle_compound_" << opNameStr << "_frm";
- else
- strstr << "angle_compound_" << opNameStr << "_frl";
- TString functionName = strstr.str().c_str();
- TIntermSequence *arguments = new TIntermSequence();
- arguments->push_back(left);
- arguments->push_back(right);
- return createInternalFunctionCallNode(left->getType(), functionName, arguments);
-}
-
-bool ParentUsesResult(TIntermNode *parent, TIntermTyped *node)
-{
- if (!parent)
- {
- return false;
- }
-
- TIntermBlock *blockParent = parent->getAsBlock();
- // If the parent is a block, the result is not assigned anywhere,
- // so rounding it is not needed. In particular, this can avoid a lot of
- // unnecessary rounding of unused return values of assignment.
- if (blockParent)
- {
- return false;
- }
- TIntermBinary *binaryParent = parent->getAsBinaryNode();
- if (binaryParent && binaryParent->getOp() == EOpComma && (binaryParent->getRight() != node))
- {
- return false;
- }
- return true;
-}
-
-bool ParentConstructorTakesCareOfRounding(TIntermNode *parent, TIntermTyped *node)
-{
- if (!parent)
- {
- return false;
- }
- TIntermAggregate *parentConstructor = parent->getAsAggregate();
- if (!parentConstructor || parentConstructor->getOp() != EOpConstruct)
- {
- return false;
- }
- if (parentConstructor->getPrecision() != node->getPrecision())
- {
- return false;
- }
- return canRoundFloat(parentConstructor->getType());
-}
-
-} // namespace anonymous
-
-EmulatePrecision::EmulatePrecision(TSymbolTable *symbolTable, int shaderVersion)
- : TLValueTrackingTraverser(true, true, true, symbolTable, shaderVersion),
- mDeclaringVariables(false)
-{
-}
-
-void EmulatePrecision::visitSymbol(TIntermSymbol *node)
-{
- TIntermNode *parent = getParentNode();
- if (canRoundFloat(node->getType()) && ParentUsesResult(parent, node) &&
- !ParentConstructorTakesCareOfRounding(parent, node) && !mDeclaringVariables &&
- !isLValueRequiredHere())
- {
- TIntermNode *replacement = createRoundingFunctionCallNode(node);
- queueReplacement(replacement, OriginalNode::BECOMES_CHILD);
- }
-}
-
-bool EmulatePrecision::visitBinary(Visit visit, TIntermBinary *node)
-{
- bool visitChildren = true;
-
- TOperator op = node->getOp();
-
- // RHS of initialize is not being declared.
- if (op == EOpInitialize && visit == InVisit)
- mDeclaringVariables = false;
-
- if ((op == EOpIndexDirectStruct) && visit == InVisit)
- visitChildren = false;
-
- if (visit != PreVisit)
- return visitChildren;
-
- const TType &type = node->getType();
- bool roundFloat = canRoundFloat(type);
-
- if (roundFloat)
- {
- switch (op)
- {
- // Math operators that can result in a float may need to apply rounding to the return
- // value. Note that in the case of assignment, the rounding is applied to its return
- // value here, not the value being assigned.
- case EOpAssign:
- case EOpAdd:
- case EOpSub:
- case EOpMul:
- case EOpDiv:
- case EOpVectorTimesScalar:
- case EOpVectorTimesMatrix:
- case EOpMatrixTimesVector:
- case EOpMatrixTimesScalar:
- case EOpMatrixTimesMatrix:
- {
- TIntermNode *parent = getParentNode();
- if (!ParentUsesResult(parent, node) ||
- ParentConstructorTakesCareOfRounding(parent, node))
- {
- break;
- }
- TIntermNode *replacement = createRoundingFunctionCallNode(node);
- queueReplacement(replacement, OriginalNode::BECOMES_CHILD);
- break;
- }
-
- // Compound assignment cases need to replace the operator with a function call.
- case EOpAddAssign:
- {
- mEmulateCompoundAdd.insert(
- TypePair(type.getBuiltInTypeNameString(),
- node->getRight()->getType().getBuiltInTypeNameString()));
- TIntermNode *replacement = createCompoundAssignmentFunctionCallNode(
- node->getLeft(), node->getRight(), "add");
- queueReplacement(replacement, OriginalNode::IS_DROPPED);
- break;
- }
- case EOpSubAssign:
- {
- mEmulateCompoundSub.insert(
- TypePair(type.getBuiltInTypeNameString(),
- node->getRight()->getType().getBuiltInTypeNameString()));
- TIntermNode *replacement = createCompoundAssignmentFunctionCallNode(
- node->getLeft(), node->getRight(), "sub");
- queueReplacement(replacement, OriginalNode::IS_DROPPED);
- break;
- }
- case EOpMulAssign:
- case EOpVectorTimesMatrixAssign:
- case EOpVectorTimesScalarAssign:
- case EOpMatrixTimesScalarAssign:
- case EOpMatrixTimesMatrixAssign:
- {
- mEmulateCompoundMul.insert(
- TypePair(type.getBuiltInTypeNameString(),
- node->getRight()->getType().getBuiltInTypeNameString()));
- TIntermNode *replacement = createCompoundAssignmentFunctionCallNode(
- node->getLeft(), node->getRight(), "mul");
- queueReplacement(replacement, OriginalNode::IS_DROPPED);
- break;
- }
- case EOpDivAssign:
- {
- mEmulateCompoundDiv.insert(
- TypePair(type.getBuiltInTypeNameString(),
- node->getRight()->getType().getBuiltInTypeNameString()));
- TIntermNode *replacement = createCompoundAssignmentFunctionCallNode(
- node->getLeft(), node->getRight(), "div");
- queueReplacement(replacement, OriginalNode::IS_DROPPED);
- break;
- }
- default:
- // The rest of the binary operations should not need precision emulation.
- break;
- }
- }
- return visitChildren;
-}
-
-bool EmulatePrecision::visitDeclaration(Visit visit, TIntermDeclaration *node)
-{
- // Variable or interface block declaration.
- if (visit == PreVisit)
- {
- mDeclaringVariables = true;
- }
- else if (visit == InVisit)
- {
- mDeclaringVariables = true;
- }
- else
- {
- mDeclaringVariables = false;
- }
- return true;
-}
-
-bool EmulatePrecision::visitInvariantDeclaration(Visit visit, TIntermInvariantDeclaration *node)
-{
- return false;
-}
-
-bool EmulatePrecision::visitFunctionPrototype(Visit visit, TIntermFunctionPrototype *node)
-{
- return false;
-}
-
-bool EmulatePrecision::visitAggregate(Visit visit, TIntermAggregate *node)
-{
- if (visit != PreVisit)
- return true;
- switch (node->getOp())
- {
- case EOpCallInternalRawFunction:
- case EOpCallFunctionInAST:
- // User-defined function return values are not rounded. The calculations that produced
- // the value inside the function definition should have been rounded.
- break;
- case EOpConstruct:
- if (node->getBasicType() == EbtStruct)
- {
- break;
- }
- default:
- TIntermNode *parent = getParentNode();
- if (canRoundFloat(node->getType()) && ParentUsesResult(parent, node) &&
- !ParentConstructorTakesCareOfRounding(parent, node))
- {
- TIntermNode *replacement = createRoundingFunctionCallNode(node);
- queueReplacement(replacement, OriginalNode::BECOMES_CHILD);
- }
- break;
- }
- return true;
-}
-
-bool EmulatePrecision::visitUnary(Visit visit, TIntermUnary *node)
-{
- switch (node->getOp())
- {
- case EOpNegative:
- case EOpLogicalNot:
- case EOpPostIncrement:
- case EOpPostDecrement:
- case EOpPreIncrement:
- case EOpPreDecrement:
- case EOpLogicalNotComponentWise:
- break;
- default:
- if (canRoundFloat(node->getType()) && visit == PreVisit)
- {
- TIntermNode *replacement = createRoundingFunctionCallNode(node);
- queueReplacement(replacement, OriginalNode::BECOMES_CHILD);
- }
- break;
- }
-
- return true;
-}
-
-void EmulatePrecision::writeEmulationHelpers(TInfoSinkBase &sink,
- const int shaderVersion,
- const ShShaderOutput outputLanguage)
-{
- std::unique_ptr<RoundingHelperWriter> roundingHelperWriter(
- RoundingHelperWriter::createHelperWriter(outputLanguage));
-
- roundingHelperWriter->writeCommonRoundingHelpers(sink, shaderVersion);
-
- EmulationSet::const_iterator it;
- for (it = mEmulateCompoundAdd.begin(); it != mEmulateCompoundAdd.end(); it++)
- roundingHelperWriter->writeCompoundAssignmentHelper(sink, it->lType, it->rType, "+", "add");
- for (it = mEmulateCompoundSub.begin(); it != mEmulateCompoundSub.end(); it++)
- roundingHelperWriter->writeCompoundAssignmentHelper(sink, it->lType, it->rType, "-", "sub");
- for (it = mEmulateCompoundDiv.begin(); it != mEmulateCompoundDiv.end(); it++)
- roundingHelperWriter->writeCompoundAssignmentHelper(sink, it->lType, it->rType, "/", "div");
- for (it = mEmulateCompoundMul.begin(); it != mEmulateCompoundMul.end(); it++)
- roundingHelperWriter->writeCompoundAssignmentHelper(sink, it->lType, it->rType, "*", "mul");
-}
-
-// static
-bool EmulatePrecision::SupportedInLanguage(const ShShaderOutput outputLanguage)
-{
- switch (outputLanguage)
- {
- case SH_HLSL_4_1_OUTPUT:
- case SH_ESSL_OUTPUT:
- return true;
- default:
- // Other languages not yet supported
- return (outputLanguage == SH_GLSL_COMPATIBILITY_OUTPUT ||
- sh::IsGLSL130OrNewer(outputLanguage));
- }
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/EmulatePrecision.h b/src/3rdparty/angle/src/compiler/translator/EmulatePrecision.h
deleted file mode 100644
index 8044465410..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/EmulatePrecision.h
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_TRANSLATOR_EMULATE_PRECISION_H_
-#define COMPILER_TRANSLATOR_EMULATE_PRECISION_H_
-
-#include "GLSLANG/ShaderLang.h"
-#include "common/angleutils.h"
-#include "compiler/translator/Compiler.h"
-#include "compiler/translator/InfoSink.h"
-#include "compiler/translator/IntermTraverse.h"
-
-// This class gathers all compound assignments from the AST and can then write
-// the functions required for their precision emulation. This way there is no
-// need to write a huge number of variations of the emulated compound assignment
-// to every translated shader with emulation enabled.
-
-namespace sh
-{
-
-class EmulatePrecision : public TLValueTrackingTraverser
-{
- public:
- EmulatePrecision(TSymbolTable *symbolTable, int shaderVersion);
-
- void visitSymbol(TIntermSymbol *node) override;
- bool visitBinary(Visit visit, TIntermBinary *node) override;
- bool visitUnary(Visit visit, TIntermUnary *node) override;
- bool visitAggregate(Visit visit, TIntermAggregate *node) override;
- bool visitInvariantDeclaration(Visit visit, TIntermInvariantDeclaration *node) override;
- bool visitDeclaration(Visit visit, TIntermDeclaration *node) override;
- bool visitFunctionPrototype(Visit visit, TIntermFunctionPrototype *node) override;
-
- void writeEmulationHelpers(TInfoSinkBase &sink,
- const int shaderVersion,
- const ShShaderOutput outputLanguage);
-
- static bool SupportedInLanguage(const ShShaderOutput outputLanguage);
-
- private:
- struct TypePair
- {
- TypePair(const char *l, const char *r) : lType(l), rType(r) {}
-
- const char *lType;
- const char *rType;
- };
-
- struct TypePairComparator
- {
- bool operator()(const TypePair &l, const TypePair &r) const
- {
- if (l.lType == r.lType)
- return l.rType < r.rType;
- return l.lType < r.lType;
- }
- };
-
- typedef std::set<TypePair, TypePairComparator> EmulationSet;
- EmulationSet mEmulateCompoundAdd;
- EmulationSet mEmulateCompoundSub;
- EmulationSet mEmulateCompoundMul;
- EmulationSet mEmulateCompoundDiv;
-
- bool mDeclaringVariables;
-};
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_EMULATE_PRECISION_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/ExpandIntegerPowExpressions.cpp b/src/3rdparty/angle/src/compiler/translator/ExpandIntegerPowExpressions.cpp
deleted file mode 100644
index f17dd73657..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ExpandIntegerPowExpressions.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-//
-// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// Implementation of the integer pow expressions HLSL bug workaround.
-// See header for more info.
-
-#include "compiler/translator/ExpandIntegerPowExpressions.h"
-
-#include <cmath>
-#include <cstdlib>
-
-#include "compiler/translator/IntermTraverse.h"
-
-namespace sh
-{
-
-namespace
-{
-
-class Traverser : public TIntermTraverser
-{
- public:
- static void Apply(TIntermNode *root, TSymbolTable *symbolTable);
-
- private:
- Traverser(TSymbolTable *symbolTable);
- bool visitAggregate(Visit visit, TIntermAggregate *node) override;
- void nextIteration();
-
- bool mFound = false;
-};
-
-// static
-void Traverser::Apply(TIntermNode *root, TSymbolTable *symbolTable)
-{
- Traverser traverser(symbolTable);
- do
- {
- traverser.nextIteration();
- root->traverse(&traverser);
- if (traverser.mFound)
- {
- traverser.updateTree();
- }
- } while (traverser.mFound);
-}
-
-Traverser::Traverser(TSymbolTable *symbolTable) : TIntermTraverser(true, false, false, symbolTable)
-{
-}
-
-void Traverser::nextIteration()
-{
- mFound = false;
- nextTemporaryId();
-}
-
-bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
-{
- if (mFound)
- {
- return false;
- }
-
- // Test 0: skip non-pow operators.
- if (node->getOp() != EOpPow)
- {
- return true;
- }
-
- const TIntermSequence *sequence = node->getSequence();
- ASSERT(sequence->size() == 2u);
- const TIntermConstantUnion *constantNode = sequence->at(1)->getAsConstantUnion();
-
- // Test 1: check for a single constant.
- if (!constantNode || constantNode->getNominalSize() != 1)
- {
- return true;
- }
-
- const TConstantUnion *constant = constantNode->getUnionArrayPointer();
-
- TConstantUnion asFloat;
- asFloat.cast(EbtFloat, *constant);
-
- float value = asFloat.getFConst();
-
- // Test 2: value is in the problematic range.
- if (value < -5.0f || value > 9.0f)
- {
- return true;
- }
-
- // Test 3: value is integer or pretty close to an integer.
- float absval = std::abs(value);
- float frac = absval - std::round(absval);
- if (frac > 0.0001f)
- {
- return true;
- }
-
- // Test 4: skip -1, 0, and 1
- int exponent = static_cast<int>(value);
- int n = std::abs(exponent);
- if (n < 2)
- {
- return true;
- }
-
- // Potential problem case detected, apply workaround.
- nextTemporaryId();
-
- TIntermTyped *lhs = sequence->at(0)->getAsTyped();
- ASSERT(lhs);
-
- TIntermDeclaration *init = createTempInitDeclaration(lhs);
- TIntermTyped *current = createTempSymbol(lhs->getType());
-
- insertStatementInParentBlock(init);
-
- // Create a chain of n-1 multiples.
- for (int i = 1; i < n; ++i)
- {
- TIntermBinary *mul = new TIntermBinary(EOpMul, current, createTempSymbol(lhs->getType()));
- mul->setLine(node->getLine());
- current = mul;
- }
-
- // For negative pow, compute the reciprocal of the positive pow.
- if (exponent < 0)
- {
- TConstantUnion *oneVal = new TConstantUnion();
- oneVal->setFConst(1.0f);
- TIntermConstantUnion *oneNode = new TIntermConstantUnion(oneVal, node->getType());
- TIntermBinary *div = new TIntermBinary(EOpDiv, oneNode, current);
- current = div;
- }
-
- queueReplacement(current, OriginalNode::IS_DROPPED);
- mFound = true;
- return false;
-}
-
-} // anonymous namespace
-
-void ExpandIntegerPowExpressions(TIntermNode *root, TSymbolTable *symbolTable)
-{
- Traverser::Apply(root, symbolTable);
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/ExpandIntegerPowExpressions.h b/src/3rdparty/angle/src/compiler/translator/ExpandIntegerPowExpressions.h
deleted file mode 100644
index 0074e5d663..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ExpandIntegerPowExpressions.h
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// This mutating tree traversal works around a bug in the HLSL compiler optimizer with "pow" that
-// manifests under the following conditions:
-//
-// - If pow() has a literal exponent value
-// - ... and this value is integer or within 10e-6 of an integer
-// - ... and it is in {-4, -3, -2, 2, 3, 4, 5, 6, 7, 8}
-//
-// The workaround is to replace the pow with a series of multiplies.
-// See http://anglebug.com/851
-
-#ifndef COMPILER_TRANSLATOR_EXPANDINTEGERPOWEXPRESSIONS_H_
-#define COMPILER_TRANSLATOR_EXPANDINTEGERPOWEXPRESSIONS_H_
-
-namespace sh
-{
-
-class TIntermNode;
-class TSymbolTable;
-
-void ExpandIntegerPowExpressions(TIntermNode *root, TSymbolTable *symbolTable);
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_EXPANDINTEGERPOWEXPRESSIONS_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/ExtensionBehavior.cpp b/src/3rdparty/angle/src/compiler/translator/ExtensionBehavior.cpp
deleted file mode 100644
index 3f910b9050..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ExtensionBehavior.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-//
-// Copyright (c) 2017 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// ExtensionBehavior.cpp: Extension name enumeration and data structures for storing extension
-// behavior.
-
-#include "compiler/translator/ExtensionBehavior.h"
-
-#include "common/debug.h"
-
-#include <string.h>
-
-#define LIST_EXTENSIONS(OP) \
- OP(ARB_texture_rectangle) \
- OP(ARM_shader_framebuffer_fetch) \
- OP(EXT_blend_func_extended) \
- OP(EXT_draw_buffers) \
- OP(EXT_frag_depth) \
- OP(EXT_geometry_shader) \
- OP(EXT_shader_framebuffer_fetch) \
- OP(EXT_shader_texture_lod) \
- OP(EXT_YUV_target) \
- OP(NV_EGL_stream_consumer_external) \
- OP(NV_shader_framebuffer_fetch) \
- OP(OES_EGL_image_external) \
- OP(OES_EGL_image_external_essl3) \
- OP(OES_geometry_shader) \
- OP(OES_standard_derivatives) \
- OP(OVR_multiview)
-
-namespace sh
-{
-
-#define RETURN_EXTENSION_NAME_CASE(ext) \
- case TExtension::ext: \
- return "GL_" #ext;
-
-const char *GetExtensionNameString(TExtension extension)
-{
- switch (extension)
- {
- LIST_EXTENSIONS(RETURN_EXTENSION_NAME_CASE)
- default:
- UNREACHABLE();
- return "";
- }
-}
-
-#define RETURN_EXTENSION_IF_NAME_MATCHES(ext) \
- if (strcmp(extWithoutGLPrefix, #ext) == 0) \
- { \
- return TExtension::ext; \
- }
-
-TExtension GetExtensionByName(const char *extension)
-{
- // If first characters of the extension don't equal "GL_", early out.
- if (strncmp(extension, "GL_", 3) != 0)
- {
- return TExtension::UNDEFINED;
- }
- const char *extWithoutGLPrefix = extension + 3;
-
- LIST_EXTENSIONS(RETURN_EXTENSION_IF_NAME_MATCHES)
-
- return TExtension::UNDEFINED;
-}
-
-const char *GetBehaviorString(TBehavior b)
-{
- switch (b)
- {
- case EBhRequire:
- return "require";
- case EBhEnable:
- return "enable";
- case EBhWarn:
- return "warn";
- case EBhDisable:
- return "disable";
- default:
- return nullptr;
- }
-}
-
-bool IsExtensionEnabled(const TExtensionBehavior &extBehavior, TExtension extension)
-{
- ASSERT(extension != TExtension::UNDEFINED);
- auto iter = extBehavior.find(extension);
- return iter != extBehavior.end() &&
- (iter->second == EBhEnable || iter->second == EBhRequire || iter->second == EBhWarn);
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/ExtensionBehavior.h b/src/3rdparty/angle/src/compiler/translator/ExtensionBehavior.h
deleted file mode 100644
index 09cc03f10f..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ExtensionBehavior.h
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// ExtensionBehavior.h: Extension name enumeration and data structures for storing extension
-// behavior.
-
-#ifndef COMPILER_TRANSLATOR_EXTENSIONBEHAVIOR_H_
-#define COMPILER_TRANSLATOR_EXTENSIONBEHAVIOR_H_
-
-#include <map>
-
-namespace sh
-{
-
-enum class TExtension
-{
- UNDEFINED, // Special value used to indicate no extension.
-
- ARB_texture_rectangle,
- ARM_shader_framebuffer_fetch,
- EXT_blend_func_extended,
- EXT_draw_buffers,
- EXT_frag_depth,
- EXT_geometry_shader,
- EXT_shader_framebuffer_fetch,
- EXT_shader_texture_lod,
- EXT_YUV_target,
- NV_EGL_stream_consumer_external,
- NV_shader_framebuffer_fetch,
- OES_EGL_image_external,
- OES_EGL_image_external_essl3,
- OES_geometry_shader,
- OES_standard_derivatives,
- OVR_multiview
-};
-
-enum TBehavior
-{
- EBhRequire,
- EBhEnable,
- EBhWarn,
- EBhDisable,
- EBhUndefined
-};
-
-const char *GetExtensionNameString(TExtension extension);
-TExtension GetExtensionByName(const char *extension);
-
-const char *GetBehaviorString(TBehavior b);
-
-// Mapping between extension id and behavior.
-typedef std::map<TExtension, TBehavior> TExtensionBehavior;
-
-bool IsExtensionEnabled(const TExtensionBehavior &extBehavior, TExtension extension);
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_EXTENSIONBEHAVIOR_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/ExtensionGLSL.cpp b/src/3rdparty/angle/src/compiler/translator/ExtensionGLSL.cpp
deleted file mode 100644
index 5b5dc580e9..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ExtensionGLSL.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-//
-// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// ExtensionGLSL.cpp: Implements the TExtensionGLSL class that tracks GLSL extension requirements
-// of shaders.
-
-#include "compiler/translator/ExtensionGLSL.h"
-
-#include "compiler/translator/VersionGLSL.h"
-
-namespace sh
-{
-
-TExtensionGLSL::TExtensionGLSL(ShShaderOutput output)
- : TIntermTraverser(true, false, false), mTargetVersion(ShaderOutputTypeToGLSLVersion(output))
-{
-}
-
-const std::set<std::string> &TExtensionGLSL::getEnabledExtensions() const
-{
- return mEnabledExtensions;
-}
-
-const std::set<std::string> &TExtensionGLSL::getRequiredExtensions() const
-{
- return mRequiredExtensions;
-}
-
-bool TExtensionGLSL::visitUnary(Visit, TIntermUnary *node)
-{
- checkOperator(node);
-
- return true;
-}
-
-bool TExtensionGLSL::visitAggregate(Visit, TIntermAggregate *node)
-{
- checkOperator(node);
-
- return true;
-}
-
-void TExtensionGLSL::checkOperator(TIntermOperator *node)
-{
- if (mTargetVersion < GLSL_VERSION_130)
- {
- return;
- }
-
- switch (node->getOp())
- {
- case EOpAbs:
- break;
-
- case EOpSign:
- break;
-
- case EOpMix:
- break;
-
- case EOpFloatBitsToInt:
- case EOpFloatBitsToUint:
- case EOpIntBitsToFloat:
- case EOpUintBitsToFloat:
- if (mTargetVersion < GLSL_VERSION_330)
- {
- // Bit conversion functions cannot be emulated.
- mRequiredExtensions.insert("GL_ARB_shader_bit_encoding");
- }
- break;
-
- case EOpPackSnorm2x16:
- case EOpPackHalf2x16:
- case EOpUnpackSnorm2x16:
- case EOpUnpackHalf2x16:
- if (mTargetVersion < GLSL_VERSION_420)
- {
- mEnabledExtensions.insert("GL_ARB_shading_language_packing");
-
- if (mTargetVersion < GLSL_VERSION_330)
- {
- // floatBitsToUint and uintBitsToFloat are needed to emulate
- // packHalf2x16 and unpackHalf2x16 respectively and cannot be
- // emulated themselves.
- mRequiredExtensions.insert("GL_ARB_shader_bit_encoding");
- }
- }
- break;
-
- case EOpPackUnorm2x16:
- case EOpUnpackUnorm2x16:
- if (mTargetVersion < GLSL_VERSION_410)
- {
- mEnabledExtensions.insert("GL_ARB_shading_language_packing");
- }
- break;
-
- default:
- break;
- }
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/ExtensionGLSL.h b/src/3rdparty/angle/src/compiler/translator/ExtensionGLSL.h
deleted file mode 100644
index a1b9cb2225..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ExtensionGLSL.h
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// ExtensionGLSL.h: Defines the TExtensionGLSL class that tracks GLSL extension requirements of
-// shaders.
-
-#ifndef COMPILER_TRANSLATOR_EXTENSIONGLSL_H_
-#define COMPILER_TRANSLATOR_EXTENSIONGLSL_H_
-
-#include <set>
-#include <string>
-
-#include "compiler/translator/IntermTraverse.h"
-
-namespace sh
-{
-
-// Traverses the intermediate tree to determine which GLSL extensions are required
-// to support the shader.
-class TExtensionGLSL : public TIntermTraverser
-{
- public:
- TExtensionGLSL(ShShaderOutput output);
-
- const std::set<std::string> &getEnabledExtensions() const;
- const std::set<std::string> &getRequiredExtensions() const;
-
- bool visitUnary(Visit visit, TIntermUnary *node) override;
- bool visitAggregate(Visit visit, TIntermAggregate *node) override;
-
- private:
- void checkOperator(TIntermOperator *node);
-
- int mTargetVersion;
-
- std::set<std::string> mEnabledExtensions;
- std::set<std::string> mRequiredExtensions;
-};
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_EXTENSIONGLSL_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/FindMain.cpp b/src/3rdparty/angle/src/compiler/translator/FindMain.cpp
deleted file mode 100644
index 7417fbac8a..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/FindMain.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// Copyright (c) 2017 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// FindMain.cpp: Find the main() function definition in a given AST.
-
-#include "compiler/translator/FindMain.h"
-
-#include "compiler/translator/IntermNode.h"
-
-namespace sh
-{
-
-TIntermFunctionDefinition *FindMain(TIntermBlock *root)
-{
- for (TIntermNode *node : *root->getSequence())
- {
- TIntermFunctionDefinition *nodeFunction = node->getAsFunctionDefinition();
- if (nodeFunction != nullptr && nodeFunction->getFunctionSymbolInfo()->isMain())
- {
- return nodeFunction;
- }
- }
- return nullptr;
-}
-
-TIntermBlock *FindMainBody(TIntermBlock *root)
-{
- TIntermFunctionDefinition *main = FindMain(root);
- ASSERT(main != nullptr);
- TIntermBlock *mainBody = main->getBody();
- ASSERT(mainBody != nullptr);
- return mainBody;
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/FindMain.h b/src/3rdparty/angle/src/compiler/translator/FindMain.h
deleted file mode 100644
index bf2c45d871..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/FindMain.h
+++ /dev/null
@@ -1,23 +0,0 @@
-//
-// Copyright (c) 2017 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// FindMain.h: Adds functions to get the main function definition and its body.
-
-#ifndef COMPILER_TRANSLATOR_FINDMAIN_H_
-#define COMPILER_TRANSLATOR_FINDMAIN_H_
-
-namespace sh
-{
-
-class TIntermBlock;
-class TIntermFunctionDefinition;
-
-TIntermFunctionDefinition *FindMain(TIntermBlock *root);
-TIntermBlock *FindMainBody(TIntermBlock *root);
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_FINDMAIN_H_ \ No newline at end of file
diff --git a/src/3rdparty/angle/src/compiler/translator/FindSymbolNode.cpp b/src/3rdparty/angle/src/compiler/translator/FindSymbolNode.cpp
deleted file mode 100644
index a2a10f128d..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/FindSymbolNode.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// FindSymbol.cpp:
-// Utility for finding a symbol node inside an AST tree.
-
-#include "compiler/translator/FindSymbolNode.h"
-
-#include "compiler/translator/IntermTraverse.h"
-
-namespace sh
-{
-
-namespace
-{
-
-class SymbolFinder : public TIntermTraverser
-{
- public:
- SymbolFinder(const TString &symbolName, TBasicType basicType)
- : TIntermTraverser(true, false, false),
- mSymbolName(symbolName),
- mNodeFound(nullptr),
- mBasicType(basicType)
- {
- }
-
- void visitSymbol(TIntermSymbol *node)
- {
- if (node->getBasicType() == mBasicType && node->getSymbol() == mSymbolName)
- {
- mNodeFound = node;
- }
- }
-
- bool isFound() const { return mNodeFound != nullptr; }
- const TIntermSymbol *getNode() const { return mNodeFound; }
-
- private:
- TString mSymbolName;
- TIntermSymbol *mNodeFound;
- TBasicType mBasicType;
-};
-
-} // anonymous namespace
-
-const TIntermSymbol *FindSymbolNode(TIntermNode *root,
- const TString &symbolName,
- TBasicType basicType)
-{
- SymbolFinder finder(symbolName, basicType);
- root->traverse(&finder);
- return finder.getNode();
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/FindSymbolNode.h b/src/3rdparty/angle/src/compiler/translator/FindSymbolNode.h
deleted file mode 100644
index 08dfb9a222..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/FindSymbolNode.h
+++ /dev/null
@@ -1,27 +0,0 @@
-//
-// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// FindSymbolNode.h:
-// Utility for finding a symbol node inside an AST tree.
-
-#ifndef COMPILER_TRANSLATOR_FIND_SYMBOL_H_
-#define COMPILER_TRANSLATOR_FIND_SYMBOL_H_
-
-#include "compiler/translator/BaseTypes.h"
-#include "compiler/translator/Common.h"
-
-namespace sh
-{
-
-class TIntermNode;
-class TIntermSymbol;
-
-const TIntermSymbol *FindSymbolNode(TIntermNode *root,
- const TString &symbolName,
- TBasicType basicType);
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_FIND_SYMBOL_H_ \ No newline at end of file
diff --git a/src/3rdparty/angle/src/compiler/translator/FlagStd140Structs.cpp b/src/3rdparty/angle/src/compiler/translator/FlagStd140Structs.cpp
deleted file mode 100644
index fba837f55c..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/FlagStd140Structs.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// FlagStd140Structs.cpp: Find structs in std140 blocks, where the padding added in the translator
-// conflicts with the "natural" unpadded type.
-
-#include "compiler/translator/FlagStd140Structs.h"
-
-#include "compiler/translator/IntermTraverse.h"
-
-namespace sh
-{
-
-namespace
-{
-
-class FlagStd140StructsTraverser : public TIntermTraverser
-{
- public:
- FlagStd140StructsTraverser() : TIntermTraverser(true, false, false) {}
-
- const std::vector<MappedStruct> getMappedStructs() const { return mMappedStructs; }
-
- protected:
- bool visitDeclaration(Visit visit, TIntermDeclaration *node) override;
-
- private:
- void mapBlockStructMembers(TIntermSymbol *blockDeclarator, TInterfaceBlock *block);
-
- std::vector<MappedStruct> mMappedStructs;
-};
-
-void FlagStd140StructsTraverser::mapBlockStructMembers(TIntermSymbol *blockDeclarator,
- TInterfaceBlock *block)
-{
- for (auto *field : block->fields())
- {
- if (field->type()->getBasicType() == EbtStruct)
- {
- MappedStruct mappedStruct;
- mappedStruct.blockDeclarator = blockDeclarator;
- mappedStruct.field = field;
- mMappedStructs.push_back(mappedStruct);
- }
- }
-}
-
-bool FlagStd140StructsTraverser::visitDeclaration(Visit visit, TIntermDeclaration *node)
-{
- TIntermTyped *declarator = node->getSequence()->back()->getAsTyped();
- if (declarator->getBasicType() == EbtInterfaceBlock)
- {
- TInterfaceBlock *block = declarator->getType().getInterfaceBlock();
- if (block->blockStorage() == EbsStd140)
- {
- mapBlockStructMembers(declarator->getAsSymbolNode(), block);
- }
- }
- return false;
-}
-
-} // anonymous namespace
-
-std::vector<MappedStruct> FlagStd140Structs(TIntermNode *node)
-{
- FlagStd140StructsTraverser flaggingTraversal;
-
- node->traverse(&flaggingTraversal);
-
- return flaggingTraversal.getMappedStructs();
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/FlagStd140Structs.h b/src/3rdparty/angle/src/compiler/translator/FlagStd140Structs.h
deleted file mode 100644
index f548d8b6ed..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/FlagStd140Structs.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//
-// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// FlagStd140Structs.h: Find structs in std140 blocks, where the padding added in the translator
-// conflicts with the "natural" unpadded type.
-
-#ifndef COMPILER_TRANSLATOR_FLAGSTD140STRUCTS_H_
-#define COMPILER_TRANSLATOR_FLAGSTD140STRUCTS_H_
-
-#include <vector>
-
-namespace sh
-{
-
-class TField;
-class TIntermNode;
-class TIntermSymbol;
-
-struct MappedStruct
-{
- TIntermSymbol *blockDeclarator;
- TField *field;
-};
-
-std::vector<MappedStruct> FlagStd140Structs(TIntermNode *node);
-}
-
-#endif // COMPILER_TRANSLATOR_FLAGSTD140STRUCTS_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/HashNames.cpp b/src/3rdparty/angle/src/compiler/translator/HashNames.cpp
deleted file mode 100644
index 6bc90faf94..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/HashNames.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-//
-// Copyright (c) 2017 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/translator/HashNames.h"
-
-#include "compiler/translator/IntermNode.h"
-
-namespace sh
-{
-
-namespace
-{
-
-// GLSL ES 3.00.6 section 3.9: the maximum length of an identifier is 1024 characters.
-static const unsigned int kESSLMaxIdentifierLength = 1024u;
-
-static const char *kHashedNamePrefix = "webgl_";
-
-// Can't prefix with just _ because then we might introduce a double underscore, which is not safe
-// in GLSL (ESSL 3.00.6 section 3.8: All identifiers containing a double underscore are reserved for
-// use by the underlying implementation). u is short for user-defined.
-static const char *kUnhashedNamePrefix = "_u";
-static const unsigned int kUnhashedNamePrefixLength = 2u;
-
-TString HashName(const TString &name, ShHashFunction64 hashFunction)
-{
- ASSERT(!name.empty());
- ASSERT(hashFunction);
- khronos_uint64_t number = (*hashFunction)(name.c_str(), name.length());
- TStringStream stream;
- stream << kHashedNamePrefix << std::hex << number;
- TString hashedName = stream.str();
- return hashedName;
-}
-
-} // anonymous namespace
-
-TString HashName(const TName &name, ShHashFunction64 hashFunction, NameMap *nameMap)
-{
- if (name.getString().empty() || name.isInternal())
- {
- return name.getString();
- }
- if (hashFunction == nullptr)
- {
- if (name.getString().length() + kUnhashedNamePrefixLength > kESSLMaxIdentifierLength)
- {
- // If the identifier length is already close to the limit, we can't prefix it. This is
- // not a problem since there are no builtins or ANGLE's internal variables that would
- // have as long names and could conflict.
- return name.getString();
- }
- return kUnhashedNamePrefix + name.getString();
- }
- if (nameMap)
- {
- NameMap::const_iterator it = nameMap->find(name.getString().c_str());
- if (it != nameMap->end())
- return it->second.c_str();
- }
- TString hashedName = HashName(name.getString(), hashFunction);
- if (nameMap)
- {
- (*nameMap)[name.getString().c_str()] = hashedName.c_str();
- }
- return hashedName;
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/HashNames.h b/src/3rdparty/angle/src/compiler/translator/HashNames.h
deleted file mode 100644
index 28e861b309..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/HashNames.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//
-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_TRANSLATOR_HASHNAMES_H_
-#define COMPILER_TRANSLATOR_HASHNAMES_H_
-
-#include <map>
-
-#include "GLSLANG/ShaderLang.h"
-#include "compiler/translator/Common.h"
-
-namespace sh
-{
-
-typedef std::map<TPersistString, TPersistString> NameMap;
-
-class TName;
-
-// Hash user-defined name for GLSL output, with special handling for internal names.
-// The nameMap parameter is optional and is used to cache hashed names if set.
-TString HashName(const TName &name, ShHashFunction64 hashFunction, NameMap *nameMap);
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_HASHNAMES_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/ImageFunctionHLSL.cpp b/src/3rdparty/angle/src/compiler/translator/ImageFunctionHLSL.cpp
deleted file mode 100644
index 40b5e1f1e2..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ImageFunctionHLSL.cpp
+++ /dev/null
@@ -1,304 +0,0 @@
-//
-// Copyright (c) 2017 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// ImageFunctionHLSL: Class for writing implementations of ESSL image functions into HLSL output.
-//
-
-#include "compiler/translator/ImageFunctionHLSL.h"
-#include "compiler/translator/UtilsHLSL.h"
-
-namespace sh
-{
-
-// static
-void ImageFunctionHLSL::OutputImageFunctionArgumentList(
- TInfoSinkBase &out,
- const ImageFunctionHLSL::ImageFunction &imageFunction)
-{
- if (imageFunction.readonly)
- {
- out << TextureString(imageFunction.image, imageFunction.imageInternalFormat) << " tex";
- }
- else
- {
- out << RWTextureString(imageFunction.image, imageFunction.imageInternalFormat) << " tex";
- }
-
- if (imageFunction.method == ImageFunctionHLSL::ImageFunction::Method::LOAD ||
- imageFunction.method == ImageFunctionHLSL::ImageFunction::Method::STORE)
- {
- switch (imageFunction.image)
- {
- case EbtImage2D:
- case EbtIImage2D:
- case EbtUImage2D:
- out << ", int2 p";
- break;
- case EbtImage3D:
- case EbtIImage3D:
- case EbtUImage3D:
- case EbtImageCube:
- case EbtIImageCube:
- case EbtUImageCube:
- case EbtImage2DArray:
- case EbtIImage2DArray:
- case EbtUImage2DArray:
- out << ", int3 p";
- break;
- default:
- UNREACHABLE();
- }
-
- if (imageFunction.method == ImageFunctionHLSL::ImageFunction::Method::STORE)
- {
- switch (imageFunction.image)
- {
- case EbtImage2D:
- case EbtImage3D:
- case EbtImageCube:
- case EbtImage2DArray:
- out << ", float4 data";
- break;
- case EbtIImage2D:
- case EbtIImage3D:
- case EbtIImageCube:
- case EbtIImage2DArray:
- out << ", int4 data";
- break;
- case EbtUImage2D:
- case EbtUImage3D:
- case EbtUImageCube:
- case EbtUImage2DArray:
- out << ", uint4 data";
- break;
- default:
- UNREACHABLE();
- }
- }
- }
-}
-
-// static
-void ImageFunctionHLSL::OutputImageSizeFunctionBody(
- TInfoSinkBase &out,
- const ImageFunctionHLSL::ImageFunction &imageFunction,
- const TString &imageReference)
-{
- if (IsImage3D(imageFunction.image) || IsImage2DArray(imageFunction.image) ||
- IsImageCube(imageFunction.image))
- {
- // "depth" stores either the number of layers in an array texture or 3D depth
- out << " uint width; uint height; uint depth;\n"
- << " " << imageReference << ".GetDimensions(width, height, depth);\n";
- }
- else if (IsImage2D(imageFunction.image))
- {
- out << " uint width; uint height;\n"
- << " " << imageReference << ".GetDimensions(width, height);\n";
- }
- else
- UNREACHABLE();
-
- if (strcmp(imageFunction.getReturnType(), "int3") == 0)
- {
- out << " return int3(width, height, depth);\n";
- }
- else
- {
- out << " return int2(width, height);\n";
- }
-}
-
-// static
-void ImageFunctionHLSL::OutputImageLoadFunctionBody(
- TInfoSinkBase &out,
- const ImageFunctionHLSL::ImageFunction &imageFunction,
- const TString &imageReference)
-{
- if (IsImage3D(imageFunction.image) || IsImage2DArray(imageFunction.image) ||
- IsImageCube(imageFunction.image))
- {
- out << " return " << imageReference << "[uint3(p.x, p.y, p.z)];\n";
- }
- else if (IsImage2D(imageFunction.image))
- {
- out << " return " << imageReference << "[uint2(p.x, p.y)];\n";
- }
- else
- UNREACHABLE();
-}
-
-// static
-void ImageFunctionHLSL::OutputImageStoreFunctionBody(
- TInfoSinkBase &out,
- const ImageFunctionHLSL::ImageFunction &imageFunction,
- const TString &imageReference)
-{
- if (IsImage3D(imageFunction.image) || IsImage2DArray(imageFunction.image) ||
- IsImage2D(imageFunction.image) || IsImageCube(imageFunction.image))
- {
- out << " " << imageReference << "[p] = data;\n";
- }
- else
- UNREACHABLE();
-}
-
-TString ImageFunctionHLSL::ImageFunction::name() const
-{
- TString name = "gl_image";
- if (readonly)
- {
- name += TextureTypeSuffix(image, imageInternalFormat);
- }
- else
- {
- name += RWTextureTypeSuffix(image, imageInternalFormat);
- }
-
- switch (method)
- {
- case Method::SIZE:
- name += "Size";
- break;
- case Method::LOAD:
- name += "Load";
- break;
- case Method::STORE:
- name += "Store";
- break;
- default:
- UNREACHABLE();
- }
-
- return name;
-}
-
-const char *ImageFunctionHLSL::ImageFunction::getReturnType() const
-{
- if (method == ImageFunction::Method::SIZE)
- {
- switch (image)
- {
- case EbtImage2D:
- case EbtIImage2D:
- case EbtUImage2D:
- case EbtImageCube:
- case EbtIImageCube:
- case EbtUImageCube:
- return "int2";
- case EbtImage3D:
- case EbtIImage3D:
- case EbtUImage3D:
- case EbtImage2DArray:
- case EbtIImage2DArray:
- case EbtUImage2DArray:
- return "int3";
- default:
- UNREACHABLE();
- }
- }
- else if (method == ImageFunction::Method::LOAD)
- {
- switch (image)
- {
- case EbtImage2D:
- case EbtImage3D:
- case EbtImageCube:
- case EbtImage2DArray:
- return "float4";
- case EbtIImage2D:
- case EbtIImage3D:
- case EbtIImageCube:
- case EbtIImage2DArray:
- return "int4";
- case EbtUImage2D:
- case EbtUImage3D:
- case EbtUImageCube:
- case EbtUImage2DArray:
- return "uint4";
- default:
- UNREACHABLE();
- }
- }
- else if (method == ImageFunction::Method::STORE)
- {
- return "void";
- }
- else
- {
- UNREACHABLE();
- }
- return "";
-}
-
-bool ImageFunctionHLSL::ImageFunction::operator<(const ImageFunction &rhs) const
-{
- return std::tie(image, imageInternalFormat, readonly, method) <
- std::tie(rhs.image, rhs.imageInternalFormat, rhs.readonly, rhs.method);
-}
-
-TString ImageFunctionHLSL::useImageFunction(const TString &name,
- const TBasicType &type,
- TLayoutImageInternalFormat imageInternalFormat,
- bool readonly)
-{
- ASSERT(IsImage(type));
- ImageFunction imageFunction;
- imageFunction.image = type;
- imageFunction.imageInternalFormat = imageInternalFormat;
- imageFunction.readonly = readonly;
-
- if (name == "imageSize")
- {
- imageFunction.method = ImageFunction::Method::SIZE;
- }
- else if (name == "imageLoad")
- {
- imageFunction.method = ImageFunction::Method::LOAD;
- }
- else if (name == "imageStore")
- {
- imageFunction.method = ImageFunction::Method::STORE;
- }
- else
- UNREACHABLE();
-
- mUsesImage.insert(imageFunction);
- return imageFunction.name();
-}
-
-void ImageFunctionHLSL::imageFunctionHeader(TInfoSinkBase &out)
-{
- for (const ImageFunction &imageFunction : mUsesImage)
- {
- // Function header
- out << imageFunction.getReturnType() << " " << imageFunction.name() << "(";
-
- OutputImageFunctionArgumentList(out, imageFunction);
-
- out << ")\n"
- "{\n";
-
- TString imageReference("tex");
-
- if (imageFunction.method == ImageFunction::Method::SIZE)
- {
- OutputImageSizeFunctionBody(out, imageFunction, imageReference);
- }
- else if (imageFunction.method == ImageFunction::Method::LOAD)
- {
- OutputImageLoadFunctionBody(out, imageFunction, imageReference);
- }
- else
- {
- OutputImageStoreFunctionBody(out, imageFunction, imageReference);
- }
-
- out << "}\n"
- "\n";
- }
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/ImageFunctionHLSL.h b/src/3rdparty/angle/src/compiler/translator/ImageFunctionHLSL.h
deleted file mode 100644
index 9db17a6bbf..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/ImageFunctionHLSL.h
+++ /dev/null
@@ -1,76 +0,0 @@
-//
-// Copyright (c) 2017 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// ImageFunctionHLSL: Class for writing implementations of ESSL image functions into HLSL output.
-//
-
-#ifndef COMPILER_TRANSLATOR_IMAGEFUNCTIONHLSL_H_
-#define COMPILER_TRANSLATOR_IMAGEFUNCTIONHLSL_H_
-
-#include <set>
-
-#include "GLSLANG/ShaderLang.h"
-#include "compiler/translator/BaseTypes.h"
-#include "compiler/translator/Common.h"
-#include "compiler/translator/InfoSink.h"
-#include "compiler/translator/Types.h"
-
-namespace sh
-{
-
-class ImageFunctionHLSL final : angle::NonCopyable
-{
- public:
- // Returns the name of the image function implementation to caller.
- // The name that's passed in is the name of the GLSL image function that it should implement.
- TString useImageFunction(const TString &name,
- const TBasicType &type,
- TLayoutImageInternalFormat imageInternalFormat,
- bool readonly);
-
- void imageFunctionHeader(TInfoSinkBase &out);
-
- private:
- struct ImageFunction
- {
- // See ESSL 3.10.4 section 8.12 for reference about what the different methods below do.
- enum class Method
- {
- SIZE,
- LOAD,
- STORE
- };
-
- TString name() const;
-
- bool operator<(const ImageFunction &rhs) const;
-
- const char *getReturnType() const;
-
- TBasicType image;
- TLayoutImageInternalFormat imageInternalFormat;
- bool readonly;
- Method method;
- };
-
- static void OutputImageFunctionArgumentList(
- TInfoSinkBase &out,
- const ImageFunctionHLSL::ImageFunction &imageFunction);
- static void OutputImageSizeFunctionBody(TInfoSinkBase &out,
- const ImageFunctionHLSL::ImageFunction &imageFunction,
- const TString &imageReference);
- static void OutputImageLoadFunctionBody(TInfoSinkBase &out,
- const ImageFunctionHLSL::ImageFunction &imageFunction,
- const TString &imageReference);
- static void OutputImageStoreFunctionBody(TInfoSinkBase &out,
- const ImageFunctionHLSL::ImageFunction &imageFunction,
- const TString &imageReference);
- using ImageFunctionSet = std::set<ImageFunction>;
- ImageFunctionSet mUsesImage;
-};
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_IMAGEFUNCTIONHLSL_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/InfoSink.cpp b/src/3rdparty/angle/src/compiler/translator/InfoSink.cpp
deleted file mode 100644
index db26aa67e8..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/InfoSink.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/translator/InfoSink.h"
-
-namespace sh
-{
-
-void TInfoSinkBase::prefix(Severity severity)
-{
- switch (severity)
- {
- case SH_WARNING:
- sink.append("WARNING: ");
- break;
- case SH_ERROR:
- sink.append("ERROR: ");
- break;
- default:
- sink.append("UNKOWN ERROR: ");
- break;
- }
-}
-
-void TInfoSinkBase::location(int file, int line)
-{
- TPersistStringStream stream;
- if (line)
- stream << file << ":" << line;
- else
- stream << file << ":? ";
- stream << ": ";
-
- sink.append(stream.str());
-}
-
-} // namespace sh
diff --git a/src/3rdparty/angle/src/compiler/translator/InfoSink.h b/src/3rdparty/angle/src/compiler/translator/InfoSink.h
deleted file mode 100644
index 2705f48d59..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/InfoSink.h
+++ /dev/null
@@ -1,120 +0,0 @@
-//
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_TRANSLATOR_INFOSINK_H_
-#define COMPILER_TRANSLATOR_INFOSINK_H_
-
-#include <math.h>
-#include <stdlib.h>
-#include "compiler/translator/Common.h"
-#include "compiler/translator/Severity.h"
-
-namespace sh
-{
-
-// Returns the fractional part of the given floating-point number.
-inline float fractionalPart(float f)
-{
- float intPart = 0.0f;
- return modff(f, &intPart);
-}
-
-//
-// Encapsulate info logs for all objects that have them.
-//
-// The methods are a general set of tools for getting a variety of
-// messages and types inserted into the log.
-//
-class TInfoSinkBase
-{
- public:
- TInfoSinkBase() {}
-
- template <typename T>
- TInfoSinkBase &operator<<(const T &t)
- {
- TPersistStringStream stream;
- stream << t;
- sink.append(stream.str());
- return *this;
- }
- // Override << operator for specific types. It is faster to append strings
- // and characters directly to the sink.
- TInfoSinkBase &operator<<(char c)
- {
- sink.append(1, c);
- return *this;
- }
- TInfoSinkBase &operator<<(const char *str)
- {
- sink.append(str);
- return *this;
- }
- TInfoSinkBase &operator<<(const TPersistString &str)
- {
- sink.append(str);
- return *this;
- }
- TInfoSinkBase &operator<<(const TString &str)
- {
- sink.append(str.c_str());
- return *this;
- }
- // Make sure floats are written with correct precision.
- TInfoSinkBase &operator<<(float f)
- {
- // Make sure that at least one decimal point is written. If a number
- // does not have a fractional part, the default precision format does
- // not write the decimal portion which gets interpreted as integer by
- // the compiler.
- TPersistStringStream stream;
- if (fractionalPart(f) == 0.0f)
- {
- stream.precision(1);
- stream << std::showpoint << std::fixed << f;
- }
- else
- {
- stream.unsetf(std::ios::fixed);
- stream.unsetf(std::ios::scientific);
- stream.precision(8);
- stream << f;
- }
- sink.append(stream.str());
- return *this;
- }
- // Write boolean values as their names instead of integral value.
- TInfoSinkBase &operator<<(bool b)
- {
- const char *str = b ? "true" : "false";
- sink.append(str);
- return *this;
- }
-
- void erase() { sink.clear(); }
- int size() { return static_cast<int>(sink.size()); }
-
- const TPersistString &str() const { return sink; }
- const char *c_str() const { return sink.c_str(); }
-
- void prefix(Severity severity);
- void location(int file, int line);
-
- private:
- TPersistString sink;
-};
-
-class TInfoSink
-{
- public:
- TInfoSinkBase info;
- TInfoSinkBase debug;
- TInfoSinkBase obj;
-};
-
-} // namespace sh
-
-#endif // COMPILER_TRANSLATOR_INFOSINK_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/Initialize.cpp b/src/3rdparty/angle/src/compiler/translator/Initialize.cpp
deleted file mode 100644
index 6f8baee96b..0000000000
--- a/src/3rdparty/angle/src/compiler/translator/Initialize.cpp
+++ /dev/null
@@ -1,1135 +0,0 @@
-//
-// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-//
-// Create symbols that declare built-in definitions, add built-ins that
-// cannot be expressed in the files, and establish mappings between
-// built-in functions and operators.
-//
-
-#include "compiler/translator/Initialize.h"
-#include "compiler/translator/Cache.h"
-
-#include "compiler/translator/IntermNode.h"
-#include "angle_gl.h"
-
-namespace sh
-{
-
-void InsertBuiltInFunctions(sh::GLenum type,
- ShShaderSpec spec,
- const ShBuiltInResources &resources,
- TSymbolTable &symbolTable)
-{
- const TType *voidType = TCache::getType(EbtVoid);
- const TType *float1 = TCache::getType(EbtFloat);
- const TType *float2 = TCache::getType(EbtFloat, 2);
- const TType *float3 = TCache::getType(EbtFloat, 3);
- const TType *float4 = TCache::getType(EbtFloat, 4);
- const TType *int1 = TCache::getType(EbtInt);
- const TType *int2 = TCache::getType(EbtInt, 2);
- const TType *int3 = TCache::getType(EbtInt, 3);
- const TType *uint1 = TCache::getType(EbtUInt);
- const TType *bool1 = TCache::getType(EbtBool);
- const TType *genType = TCache::getType(EbtGenType);
- const TType *genIType = TCache::getType(EbtGenIType);
- const TType *genUType = TCache::getType(EbtGenUType);
- const TType *genBType = TCache::getType(EbtGenBType);
-
- //
- // Angle and Trigonometric Functions.
- //
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpRadians, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpDegrees, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpSin, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpCos, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpTan, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpAsin, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpAcos, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpAtan, genType, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpAtan, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpSinh, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpCosh, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpTanh, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpAsinh, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpAcosh, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpAtanh, genType, genType);
-
- //
- // Exponential Functions.
- //
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpPow, genType, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpExp, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpLog, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpExp2, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpLog2, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpSqrt, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpInverseSqrt, genType, genType);
-
- //
- // Common Functions.
- //
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpAbs, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpAbs, genIType, genIType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpSign, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpSign, genIType, genIType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpFloor, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpTrunc, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpRound, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpRoundEven, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpCeil, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpFract, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpMod, genType, genType, float1);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpMod, genType, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpMin, genType, genType, float1);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpMin, genType, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpMin, genIType, genIType, genIType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpMin, genIType, genIType, int1);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpMin, genUType, genUType, genUType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpMin, genUType, genUType, uint1);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpMax, genType, genType, float1);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpMax, genType, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpMax, genIType, genIType, genIType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpMax, genIType, genIType, int1);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpMax, genUType, genUType, genUType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpMax, genUType, genUType, uint1);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpClamp, genType, genType, float1, float1);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpClamp, genType, genType, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpClamp, genIType, genIType, int1, int1);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpClamp, genIType, genIType, genIType, genIType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpClamp, genUType, genUType, uint1, uint1);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpClamp, genUType, genUType, genUType, genUType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpMix, genType, genType, genType, float1);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpMix, genType, genType, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpMix, genType, genType, genType, genBType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpStep, genType, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpStep, genType, float1, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpSmoothStep, genType, genType, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpSmoothStep, genType, float1, float1, genType);
-
- const TType *outGenType = TCache::getType(EbtGenType, EvqOut);
- const TType *outGenIType = TCache::getType(EbtGenIType, EvqOut);
-
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpModf, genType, genType, outGenType);
-
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpIsNan, genBType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpIsInf, genBType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpFloatBitsToInt, genIType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpFloatBitsToUint, genUType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpIntBitsToFloat, genType, genIType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpUintBitsToFloat, genType, genUType);
-
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpFrexp, genType, genType, outGenIType);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpLdexp, genType, genType, genIType);
-
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpPackSnorm2x16, uint1, float2);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpPackUnorm2x16, uint1, float2);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpPackHalf2x16, uint1, float2);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpUnpackSnorm2x16, float2, uint1);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpUnpackUnorm2x16, float2, uint1);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpUnpackHalf2x16, float2, uint1);
-
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpPackUnorm4x8, uint1, float4);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpPackSnorm4x8, uint1, float4);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpUnpackUnorm4x8, float4, uint1);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpUnpackSnorm4x8, float4, uint1);
-
- //
- // Geometric Functions.
- //
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpLength, float1, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpDistance, float1, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpDot, float1, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpCross, float3, float3, float3);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpNormalize, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpFaceforward, genType, genType, genType,
- genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpReflect, genType, genType, genType);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpRefract, genType, genType, genType, float1);
-
- const TType *mat2 = TCache::getType(EbtFloat, 2, 2);
- const TType *mat3 = TCache::getType(EbtFloat, 3, 3);
- const TType *mat4 = TCache::getType(EbtFloat, 4, 4);
- const TType *mat2x3 = TCache::getType(EbtFloat, 2, 3);
- const TType *mat3x2 = TCache::getType(EbtFloat, 3, 2);
- const TType *mat2x4 = TCache::getType(EbtFloat, 2, 4);
- const TType *mat4x2 = TCache::getType(EbtFloat, 4, 2);
- const TType *mat3x4 = TCache::getType(EbtFloat, 3, 4);
- const TType *mat4x3 = TCache::getType(EbtFloat, 4, 3);
-
- //
- // Matrix Functions.
- //
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpMulMatrixComponentWise, mat2, mat2, mat2);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpMulMatrixComponentWise, mat3, mat3, mat3);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpMulMatrixComponentWise, mat4, mat4, mat4);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpMulMatrixComponentWise, mat2x3, mat2x3, mat2x3);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpMulMatrixComponentWise, mat3x2, mat3x2, mat3x2);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpMulMatrixComponentWise, mat2x4, mat2x4, mat2x4);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpMulMatrixComponentWise, mat4x2, mat4x2, mat4x2);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpMulMatrixComponentWise, mat3x4, mat3x4, mat3x4);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpMulMatrixComponentWise, mat4x3, mat4x3, mat4x3);
-
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpOuterProduct, mat2, float2, float2);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpOuterProduct, mat3, float3, float3);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpOuterProduct, mat4, float4, float4);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpOuterProduct, mat2x3, float3, float2);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpOuterProduct, mat3x2, float2, float3);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpOuterProduct, mat2x4, float4, float2);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpOuterProduct, mat4x2, float2, float4);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpOuterProduct, mat3x4, float4, float3);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpOuterProduct, mat4x3, float3, float4);
-
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpTranspose, mat2, mat2);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpTranspose, mat3, mat3);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpTranspose, mat4, mat4);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpTranspose, mat2x3, mat3x2);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpTranspose, mat3x2, mat2x3);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpTranspose, mat2x4, mat4x2);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpTranspose, mat4x2, mat2x4);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpTranspose, mat3x4, mat4x3);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpTranspose, mat4x3, mat3x4);
-
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpDeterminant, float1, mat2);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpDeterminant, float1, mat3);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpDeterminant, float1, mat4);
-
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpInverse, mat2, mat2);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpInverse, mat3, mat3);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpInverse, mat4, mat4);
-
- const TType *vec = TCache::getType(EbtVec);
- const TType *ivec = TCache::getType(EbtIVec);
- const TType *uvec = TCache::getType(EbtUVec);
- const TType *bvec = TCache::getType(EbtBVec);
-
- //
- // Vector relational functions.
- //
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpLessThanComponentWise, bvec, vec, vec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpLessThanComponentWise, bvec, ivec, ivec);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpLessThanComponentWise, bvec, uvec, uvec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpLessThanEqualComponentWise, bvec, vec, vec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpLessThanEqualComponentWise, bvec, ivec, ivec);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpLessThanEqualComponentWise, bvec, uvec, uvec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpGreaterThanComponentWise, bvec, vec, vec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpGreaterThanComponentWise, bvec, ivec, ivec);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpGreaterThanComponentWise, bvec, uvec, uvec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpGreaterThanEqualComponentWise, bvec, vec, vec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpGreaterThanEqualComponentWise, bvec, ivec,
- ivec);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpGreaterThanEqualComponentWise, bvec, uvec, uvec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpEqualComponentWise, bvec, vec, vec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpEqualComponentWise, bvec, ivec, ivec);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpEqualComponentWise, bvec, uvec, uvec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpEqualComponentWise, bvec, bvec, bvec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpNotEqualComponentWise, bvec, vec, vec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpNotEqualComponentWise, bvec, ivec, ivec);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpNotEqualComponentWise, bvec, uvec, uvec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpNotEqualComponentWise, bvec, bvec, bvec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpAny, bool1, bvec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpAll, bool1, bvec);
- symbolTable.insertBuiltInOp(COMMON_BUILTINS, EOpLogicalNotComponentWise, bvec, bvec);
-
- //
- // Integer functions
- //
- const TType *outGenUType = TCache::getType(EbtGenUType, EvqOut);
-
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpBitfieldExtract, genIType, genIType, int1,
- int1);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpBitfieldExtract, genUType, genUType, int1,
- int1);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpBitfieldInsert, genIType, genIType, genIType,
- int1, int1);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpBitfieldInsert, genUType, genUType, genUType,
- int1, int1);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpBitfieldReverse, genIType, genIType);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpBitfieldReverse, genUType, genUType);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpBitCount, genIType, genIType);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpBitCount, genIType, genUType);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpFindLSB, genIType, genIType);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpFindLSB, genIType, genUType);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpFindMSB, genIType, genIType);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpFindMSB, genIType, genUType);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpUaddCarry, genUType, genUType, genUType,
- outGenUType);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpUsubBorrow, genUType, genUType, genUType,
- outGenUType);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpUmulExtended, voidType, genUType, genUType,
- outGenUType, outGenUType);
- symbolTable.insertBuiltInOp(ESSL3_1_BUILTINS, EOpImulExtended, voidType, genIType, genIType,
- outGenIType, outGenIType);
-
- const TType *sampler2D = TCache::getType(EbtSampler2D);
- const TType *samplerCube = TCache::getType(EbtSamplerCube);
-
- //
- // Texture Functions for GLSL ES 1.0
- //
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3);
-
- if (resources.OES_EGL_image_external || resources.NV_EGL_stream_consumer_external)
- {
- const TType *samplerExternalOES = TCache::getType(EbtSamplerExternalOES);
-
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", samplerExternalOES, float2);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES,
- float3);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES,
- float4);
- }
-
- if (resources.ARB_texture_rectangle)
- {
- const TType *sampler2DRect = TCache::getType(EbtSampler2DRect);
-
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRect", sampler2DRect, float2);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect,
- float3);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect,
- float4);
- }
-
- if (resources.EXT_shader_texture_lod)
- {
- /* The *Grad* variants are new to both vertex and fragment shaders; the fragment
- * shader specific pieces are added separately below.
- */
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, TExtension::EXT_shader_texture_lod, float4,
- "texture2DGradEXT", sampler2D, float2, float2, float2);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, TExtension::EXT_shader_texture_lod, float4,
- "texture2DProjGradEXT", sampler2D, float3, float2, float2);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, TExtension::EXT_shader_texture_lod, float4,
- "texture2DProjGradEXT", sampler2D, float4, float2, float2);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, TExtension::EXT_shader_texture_lod, float4,
- "textureCubeGradEXT", samplerCube, float3, float3, float3);
- }
-
- if (type == GL_FRAGMENT_SHADER)
- {
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2, float1);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3,
- float1);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4,
- float1);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3,
- float1);
-
- if (resources.OES_standard_derivatives)
- {
- symbolTable.insertBuiltInOp(ESSL1_BUILTINS, EOpDFdx,
- TExtension::OES_standard_derivatives, genType, genType);
- symbolTable.insertBuiltInOp(ESSL1_BUILTINS, EOpDFdy,
- TExtension::OES_standard_derivatives, genType, genType);
- symbolTable.insertBuiltInOp(ESSL1_BUILTINS, EOpFwidth,
- TExtension::OES_standard_derivatives, genType, genType);
- }
-
- if (resources.EXT_shader_texture_lod)
- {
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, TExtension::EXT_shader_texture_lod, float4,
- "texture2DLodEXT", sampler2D, float2, float1);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, TExtension::EXT_shader_texture_lod, float4,
- "texture2DProjLodEXT", sampler2D, float3, float1);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, TExtension::EXT_shader_texture_lod, float4,
- "texture2DProjLodEXT", sampler2D, float4, float1);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, TExtension::EXT_shader_texture_lod, float4,
- "textureCubeLodEXT", samplerCube, float3, float1);
- }
- }
-
- if (type == GL_VERTEX_SHADER)
- {
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLod", sampler2D, float2,
- float1);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float3,
- float1);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float4,
- float1);
- symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLod", samplerCube, float3,
- float1);
- }
-
- const TType *gvec4 = TCache::getType(EbtGVec4);
-
- const TType *gsampler2D = TCache::getType(EbtGSampler2D);
- const TType *gsamplerCube = TCache::getType(EbtGSamplerCube);
- const TType *gsampler3D = TCache::getType(EbtGSampler3D);
- const TType *gsampler2DArray = TCache::getType(EbtGSampler2DArray);
- const TType *gsampler2DMS = TCache::getType(EbtGSampler2DMS);
-
- //
- // Texture Functions for GLSL ES 3.0
- //
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2D, float2, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler3D, float3, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsamplerCube, float3, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2DArray, float3, float1);
-
- if (resources.OES_EGL_image_external_essl3)
- {
- const TType *samplerExternalOES = TCache::getType(EbtSamplerExternalOES);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texture", samplerExternalOES, float2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", samplerExternalOES,
- float3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", samplerExternalOES,
- float4);
- }
-
- if (resources.EXT_YUV_target)
- {
- const TType *samplerExternal2DY2YEXT = TCache::getType(EbtSamplerExternal2DY2YEXT);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, TExtension::EXT_YUV_target, float4, "texture",
- samplerExternal2DY2YEXT, float2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, TExtension::EXT_YUV_target, float4, "textureProj",
- samplerExternal2DY2YEXT, float3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, TExtension::EXT_YUV_target, float4, "textureProj",
- samplerExternal2DY2YEXT, float4);
-
- const TType *yuvCscStandardEXT = TCache::getType(EbtYuvCscStandardEXT);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, TExtension::EXT_YUV_target, float3, "rgb_2_yuv",
- float3, yuvCscStandardEXT);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, TExtension::EXT_YUV_target, float3, "yuv_2_rgb",
- float3, yuvCscStandardEXT);
- }
-
- if (type == GL_FRAGMENT_SHADER)
- {
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3,
- float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4, float1);
-
- if (resources.OES_EGL_image_external_essl3)
- {
- const TType *samplerExternalOES = TCache::getType(EbtSamplerExternalOES);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texture", samplerExternalOES, float2,
- float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", samplerExternalOES,
- float3, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", samplerExternalOES,
- float4, float1);
- }
-
- if (resources.EXT_YUV_target)
- {
- const TType *samplerExternal2DY2YEXT = TCache::getType(EbtSamplerExternal2DY2YEXT);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, TExtension::EXT_YUV_target, float4, "texture",
- samplerExternal2DY2YEXT, float2, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, TExtension::EXT_YUV_target, float4,
- "textureProj", samplerExternal2DY2YEXT, float3, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, TExtension::EXT_YUV_target, float4,
- "textureProj", samplerExternal2DY2YEXT, float4, float1);
- }
- }
-
- const TType *sampler2DShadow = TCache::getType(EbtSampler2DShadow);
- const TType *samplerCubeShadow = TCache::getType(EbtSamplerCubeShadow);
- const TType *sampler2DArrayShadow = TCache::getType(EbtSampler2DArrayShadow);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DArrayShadow, float4);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLod", sampler2DShadow, float3,
- float1);
-
- if (type == GL_FRAGMENT_SHADER)
- {
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3,
- float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4,
- float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4,
- float1);
- }
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsampler2D, int1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler3D, int1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsamplerCube, int1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler2DArray, int1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", sampler2DShadow, int1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", samplerCubeShadow, int1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", sampler2DArrayShadow, int1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsampler2DMS);
-
- if (resources.OES_EGL_image_external_essl3)
- {
- const TType *samplerExternalOES = TCache::getType(EbtSamplerExternalOES);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", samplerExternalOES, int1);
- }
-
- if (resources.EXT_YUV_target)
- {
- const TType *samplerExternal2DY2YEXT = TCache::getType(EbtSamplerExternal2DY2YEXT);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, TExtension::EXT_YUV_target, int2, "textureSize",
- samplerExternal2DY2YEXT, int1);
- }
-
- if (type == GL_FRAGMENT_SHADER)
- {
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpDFdx, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpDFdy, genType, genType);
- symbolTable.insertBuiltInOp(ESSL3_BUILTINS, EOpFwidth, genType, genType);
- }
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3,
- int2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3,
- int2);
-
- 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);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3,
- int2, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3,
- int2, float1);
- }
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4,
- int2);
-
- 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);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4,
- int3, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow,
- float4, int2, float1);
- }
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2D, float2, float1,
- int2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler3D, float3, float1,
- int3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLodOffset", sampler2DShadow, float3,
- float1, int2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2DArray, float3,
- float1, int2);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float3, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float4, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler3D, float4, float1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLod", sampler2DShadow, float4,
- float1);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float3,
- float1, int2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float4,
- float1, int2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler3D, float4,
- float1, int3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLodOffset", sampler2DShadow,
- float4, float1, int2);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2D, int2, int1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler3D, int3, int1);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2DArray, int3, int1);
-
- if (resources.OES_EGL_image_external_essl3)
- {
- const TType *samplerExternalOES = TCache::getType(EbtSamplerExternalOES);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texelFetch", samplerExternalOES, int2,
- int1);
- }
-
- if (resources.EXT_YUV_target)
- {
- const TType *samplerExternal2DY2YEXT = TCache::getType(EbtSamplerExternal2DY2YEXT);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, TExtension::EXT_YUV_target, float4, "texelFetch",
- samplerExternal2DY2YEXT, int2, int1);
- }
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2D, int2, int1,
- int2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler3D, int3, int1,
- int3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2DArray, int3,
- int1, int2);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2D, float2, float2,
- float2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler3D, float3, float3,
- float3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsamplerCube, float3, float3,
- float3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DShadow, float3,
- float2, float2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", samplerCubeShadow, float4,
- float3, float3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2DArray, float3, float2,
- float2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DArrayShadow, float4,
- float2, float2);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2D, float2,
- float2, float2, int2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler3D, float3,
- float3, float3, int3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DShadow, float3,
- float2, float2, int2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2DArray, float3,
- float2, float2, int2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DArrayShadow,
- float4, float2, float2, int2);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float3, float2,
- float2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float4, float2,
- float2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler3D, float4, float3,
- float3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGrad", sampler2DShadow, float4,
- float2, float2);
-
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float3,
- float2, float2, int2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float4,
- float2, float2, int2);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler3D, float4,
- float3, float3, int3);
- symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGradOffset", sampler2DShadow,
- float4, float2, float2, int2);
-
- const TType *atomicCounter = TCache::getType(EbtAtomicCounter);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, uint1, "atomicCounter", atomicCounter);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, uint1, "atomicCounterIncrement", atomicCounter);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, uint1, "atomicCounterDecrement", atomicCounter);
-
- // Insert all atomic memory functions
- const TType *int1InOut = TCache::getType(EbtInt, EvqInOut);
- const TType *uint1InOut = TCache::getType(EbtUInt, EvqInOut);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, uint1, "atomicAdd", uint1InOut, uint1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int1, "atomicAdd", int1InOut, int1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, uint1, "atomicMin", uint1InOut, uint1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int1, "atomicMin", int1InOut, int1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, uint1, "atomicMax", uint1InOut, uint1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int1, "atomicMax", int1InOut, int1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, uint1, "atomicAnd", uint1InOut, uint1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int1, "atomicAnd", int1InOut, int1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, uint1, "atomicOr", uint1InOut, uint1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int1, "atomicOr", int1InOut, int1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, uint1, "atomicXor", uint1InOut, uint1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int1, "atomicXor", int1InOut, int1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, uint1, "atomicExchange", uint1InOut, uint1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int1, "atomicExchange", int1InOut, int1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, uint1, "atomicCompSwap", uint1InOut, uint1, uint1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int1, "atomicCompSwap", int1InOut, int1, int1);
-
- const TType *gimage2D = TCache::getType(EbtGImage2D);
- const TType *gimage3D = TCache::getType(EbtGImage3D);
- const TType *gimage2DArray = TCache::getType(EbtGImage2DArray);
- const TType *gimageCube = TCache::getType(EbtGImageCube);
-
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, voidType, "imageStore", gimage2D, int2, gvec4);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, voidType, "imageStore", gimage3D, int3, gvec4);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, voidType, "imageStore", gimage2DArray, int3, gvec4);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, voidType, "imageStore", gimageCube, int3, gvec4);
-
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "imageLoad", gimage2D, int2);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "imageLoad", gimage3D, int3);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "imageLoad", gimage2DArray, int3);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "imageLoad", gimageCube, int3);
-
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int2, "imageSize", gimage2D);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int3, "imageSize", gimage3D);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int3, "imageSize", gimage2DArray);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int2, "imageSize", gimageCube);
-
- symbolTable.insertBuiltInFunctionNoParameters(ESSL3_1_BUILTINS, EOpMemoryBarrier, voidType,
- "memoryBarrier");
- symbolTable.insertBuiltInFunctionNoParameters(ESSL3_1_BUILTINS, EOpMemoryBarrierAtomicCounter,
- voidType, "memoryBarrierAtomicCounter");
- symbolTable.insertBuiltInFunctionNoParameters(ESSL3_1_BUILTINS, EOpMemoryBarrierBuffer,
- voidType, "memoryBarrierBuffer");
- symbolTable.insertBuiltInFunctionNoParameters(ESSL3_1_BUILTINS, EOpMemoryBarrierImage, voidType,
- "memoryBarrierImage");
-
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "texelFetch", gsampler2DMS, int2, int1);
-
- // Insert all variations of textureGather.
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "textureGather", gsampler2D, float2);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "textureGather", gsampler2D, float2, int1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "textureGather", gsampler2DArray, float3);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "textureGather", gsampler2DArray, float3,
- int1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "textureGather", gsamplerCube, float3);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "textureGather", gsamplerCube, float3, int1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, float4, "textureGather", sampler2DShadow, float2);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, float4, "textureGather", sampler2DShadow, float2,
- float1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, float4, "textureGather", sampler2DArrayShadow,
- float3);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, float4, "textureGather", sampler2DArrayShadow,
- float3, float1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, float4, "textureGather", samplerCubeShadow, float3);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, float4, "textureGather", samplerCubeShadow, float3,
- float1);
-
- // Insert all variations of textureGatherOffset.
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "textureGatherOffset", gsampler2D, float2,
- int2);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "textureGatherOffset", gsampler2D, float2,
- int2, int1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "textureGatherOffset", gsampler2DArray,
- float3, int2);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "textureGatherOffset", gsampler2DArray,
- float3, int2, int1);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, float4, "textureGatherOffset", sampler2DShadow,
- float2, float1, int2);
- symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, float4, "textureGatherOffset", sampler2DArrayShadow,
- float3, float1, int2);
-
- if (type == GL_COMPUTE_SHADER)
- {
- symbolTable.insertBuiltInFunctionNoParameters(ESSL3_1_BUILTINS, EOpBarrier, voidType,
- "barrier");
- symbolTable.insertBuiltInFunctionNoParameters(ESSL3_1_BUILTINS, EOpMemoryBarrierShared,
- voidType, "memoryBarrierShared");
- symbolTable.insertBuiltInFunctionNoParameters(ESSL3_1_BUILTINS, EOpGroupMemoryBarrier,
- voidType, "groupMemoryBarrier");
- }
-
- if (type == GL_GEOMETRY_SHADER_OES)
- {
- TExtension extension = TExtension::OES_geometry_shader;
- symbolTable.insertBuiltInFunctionNoParametersExt(ESSL3_1_BUILTINS, extension, EOpEmitVertex,
- voidType, "EmitVertex");
- symbolTable.insertBuiltInFunctionNoParametersExt(ESSL3_1_BUILTINS, extension,
- EOpEndPrimitive, voidType, "EndPrimitive");
- }
-
- //
- // Depth range in window coordinates
- //
- TFieldList *fields = NewPoolTFieldList();
- TSourceLoc zeroSourceLoc = {0, 0, 0, 0};
- auto highpFloat1 = new TType(EbtFloat, EbpHigh, EvqGlobal, 1);
- TField *near = new TField(highpFloat1, NewPoolTString("near"), zeroSourceLoc);
- TField *far = new TField(highpFloat1, NewPoolTString("far"), zeroSourceLoc);
- TField *diff = new TField(highpFloat1, NewPoolTString("diff"), zeroSourceLoc);
- fields->push_back(near);
- fields->push_back(far);
- fields->push_back(diff);
- TStructure *depthRangeStruct =
- new TStructure(&symbolTable, NewPoolTString("gl_DepthRangeParameters"), fields);
- symbolTable.insertStructType(COMMON_BUILTINS, depthRangeStruct);
- TType depthRangeType(depthRangeStruct);
- depthRangeType.setQualifier(EvqUniform);
- symbolTable.insertVariable(COMMON_BUILTINS, "gl_DepthRange", depthRangeType);
-
- //
- // Implementation dependent built-in constants.
- //
- symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexAttribs", resources.MaxVertexAttribs,
- EbpMedium);
- symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexUniformVectors",
- resources.MaxVertexUniformVectors, EbpMedium);
- symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexTextureImageUnits",
- resources.MaxVertexTextureImageUnits, EbpMedium);
- symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxCombinedTextureImageUnits",
- resources.MaxCombinedTextureImageUnits, EbpMedium);
- symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxTextureImageUnits",
- resources.MaxTextureImageUnits, EbpMedium);
- symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxFragmentUniformVectors",
- resources.MaxFragmentUniformVectors, EbpMedium);
-
- symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxVaryingVectors", resources.MaxVaryingVectors,
- EbpMedium);
-
- symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxDrawBuffers", resources.MaxDrawBuffers,
- EbpMedium);
- if (resources.EXT_blend_func_extended)
- {
- symbolTable.insertConstIntExt(COMMON_BUILTINS, TExtension::EXT_blend_func_extended,
- "gl_MaxDualSourceDrawBuffersEXT",
- resources.MaxDualSourceDrawBuffers, EbpMedium);
- }
-
- symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxVertexOutputVectors",
- resources.MaxVertexOutputVectors, EbpMedium);
- symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxFragmentInputVectors",
- resources.MaxFragmentInputVectors, EbpMedium);
- symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MinProgramTexelOffset",
- resources.MinProgramTexelOffset, EbpMedium);
- symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxProgramTexelOffset",
- resources.MaxProgramTexelOffset, EbpMedium);
-
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxImageUnits", resources.MaxImageUnits,
- EbpMedium);
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxVertexImageUniforms",
- resources.MaxVertexImageUniforms, EbpMedium);
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxFragmentImageUniforms",
- resources.MaxFragmentImageUniforms, EbpMedium);
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxComputeImageUniforms",
- resources.MaxComputeImageUniforms, EbpMedium);
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxCombinedImageUniforms",
- resources.MaxCombinedImageUniforms, EbpMedium);
-
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxCombinedShaderOutputResources",
- resources.MaxCombinedShaderOutputResources, EbpMedium);
-
- symbolTable.insertConstIvec3(ESSL3_1_BUILTINS, "gl_MaxComputeWorkGroupCount",
- resources.MaxComputeWorkGroupCount, EbpHigh);
- symbolTable.insertConstIvec3(ESSL3_1_BUILTINS, "gl_MaxComputeWorkGroupSize",
- resources.MaxComputeWorkGroupSize, EbpHigh);
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxComputeUniformComponents",
- resources.MaxComputeUniformComponents, EbpMedium);
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxComputeTextureImageUnits",
- resources.MaxComputeTextureImageUnits, EbpMedium);
-
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxComputeAtomicCounters",
- resources.MaxComputeAtomicCounters, EbpMedium);
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxComputeAtomicCounterBuffers",
- resources.MaxComputeAtomicCounterBuffers, EbpMedium);
-
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxVertexAtomicCounters",
- resources.MaxVertexAtomicCounters, EbpMedium);
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxFragmentAtomicCounters",
- resources.MaxFragmentAtomicCounters, EbpMedium);
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxCombinedAtomicCounters",
- resources.MaxCombinedAtomicCounters, EbpMedium);
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxAtomicCounterBindings",
- resources.MaxAtomicCounterBindings, EbpMedium);
-
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxVertexAtomicCounterBuffers",
- resources.MaxVertexAtomicCounterBuffers, EbpMedium);
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxFragmentAtomicCounterBuffers",
- resources.MaxFragmentAtomicCounterBuffers, EbpMedium);
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxCombinedAtomicCounterBuffers",
- resources.MaxCombinedAtomicCounterBuffers, EbpMedium);
- symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxAtomicCounterBufferSize",
- resources.MaxAtomicCounterBufferSize, EbpMedium);
-
- if (resources.OES_geometry_shader)
- {
- TExtension ext = TExtension::OES_geometry_shader;
- symbolTable.insertConstIntExt(ESSL3_1_BUILTINS, ext, "gl_MaxGeometryInputComponents",
- resources.MaxGeometryInputComponents, EbpMedium);
- symbolTable.insertConstIntExt(ESSL3_1_BUILTINS, ext, "gl_MaxGeometryOutputComponents",
- resources.MaxGeometryOutputComponents, EbpMedium);
- symbolTable.insertConstIntExt(ESSL3_1_BUILTINS, ext, "gl_MaxGeometryImageUniforms",
- resources.MaxGeometryImageUniforms, EbpMedium);
- symbolTable.insertConstIntExt(ESSL3_1_BUILTINS, ext, "gl_MaxGeometryTextureImageUnits",
- resources.MaxGeometryTextureImageUnits, EbpMedium);
- symbolTable.insertConstIntExt(ESSL3_1_BUILTINS, ext, "gl_MaxGeometryOutputVertices",
- resources.MaxGeometryOutputVertices, EbpMedium);
- symbolTable.insertConstIntExt(ESSL3_1_BUILTINS, ext, "gl_MaxGeometryTotalOutputComponents",
- resources.MaxGeometryTotalOutputComponents, EbpMedium);
- symbolTable.insertConstIntExt(ESSL3_1_BUILTINS, ext, "gl_MaxGeometryUniformComponents",
- resources.MaxGeometryUniformComponents, EbpMedium);
- symbolTable.insertConstIntExt(ESSL3_1_BUILTINS, ext, "gl_MaxGeometryAtomicCounters",
- resources.MaxGeometryAtomicCounters, EbpMedium);
- symbolTable.insertConstIntExt(ESSL3_1_BUILTINS, ext, "gl_MaxGeometryAtomicCounterBuffers",
- resources.MaxGeometryAtomicCounterBuffers, EbpMedium);
- }
-}
-
-void IdentifyBuiltIns(sh::GLenum type,
- ShShaderSpec spec,
- const ShBuiltInResources &resources,
- TSymbolTable &symbolTable)
-{
- //
- // Insert some special built-in variables that are not in
- // the built-in header files.
- //
-
- if (resources.OVR_multiview && type != GL_COMPUTE_SHADER)
- {
- symbolTable.insertVariableExt(ESSL3_BUILTINS, TExtension::OVR_multiview, "gl_ViewID_OVR",
- TType(EbtUInt, EbpHigh, EvqViewIDOVR, 1));
-
- // ESSL 1.00 doesn't have unsigned integers, so gl_ViewID_OVR is a signed integer in ESSL
- // 1.00. This is specified in the WEBGL_multiview spec.
- symbolTable.insertVariableExt(ESSL1_BUILTINS, TExtension::OVR_multiview, "gl_ViewID_OVR",
- TType(EbtInt, EbpHigh, EvqViewIDOVR, 1));
- }
-
- switch (type)
- {
- case GL_FRAGMENT_SHADER:
- {
- symbolTable.insertVariable(COMMON_BUILTINS, "gl_FragCoord",
- TType(EbtFloat, EbpMedium, EvqFragCoord, 4));
- symbolTable.insertVariable(COMMON_BUILTINS, "gl_FrontFacing",
- TType(EbtBool, EbpUndefined, EvqFrontFacing, 1));
- symbolTable.insertVariable(COMMON_BUILTINS, "gl_PointCoord",
- TType(EbtFloat, EbpMedium, EvqPointCoord, 2));
-
- symbolTable.insertVariable(ESSL1_BUILTINS, "gl_FragColor",
- TType(EbtFloat, EbpMedium, EvqFragColor, 4));
- TType fragData(EbtFloat, EbpMedium, EvqFragData, 4);
- if (spec != SH_WEBGL2_SPEC && spec != SH_WEBGL3_SPEC)
- {
- fragData.makeArray(resources.MaxDrawBuffers);
- }
- else
- {
- fragData.makeArray(1u);
- }
- symbolTable.insertVariable(ESSL1_BUILTINS, "gl_FragData", fragData);
-
- if (resources.EXT_blend_func_extended)
- {
- symbolTable.insertVariableExt(
- ESSL1_BUILTINS, TExtension::EXT_blend_func_extended, "gl_SecondaryFragColorEXT",
- TType(EbtFloat, EbpMedium, EvqSecondaryFragColorEXT, 4));
- TType secondaryFragData(EbtFloat, EbpMedium, EvqSecondaryFragDataEXT, 4, 1);
- secondaryFragData.makeArray(resources.MaxDualSourceDrawBuffers);
- symbolTable.insertVariableExt(ESSL1_BUILTINS, TExtension::EXT_blend_func_extended,
- "gl_SecondaryFragDataEXT", secondaryFragData);
- }
-
- if (resources.EXT_frag_depth)
- {
- symbolTable.insertVariableExt(
- ESSL1_BUILTINS, TExtension::EXT_frag_depth, "gl_FragDepthEXT",
- TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium,
- EvqFragDepthEXT, 1));
- }
-
- symbolTable.insertVariable(ESSL3_BUILTINS, "gl_FragDepth",
- TType(EbtFloat, EbpHigh, EvqFragDepth, 1));
-
- if (resources.EXT_shader_framebuffer_fetch || resources.NV_shader_framebuffer_fetch)
- {
- TType lastFragData(EbtFloat, EbpMedium, EvqLastFragData, 4, 1);
- lastFragData.makeArray(resources.MaxDrawBuffers);
-
- if (resources.EXT_shader_framebuffer_fetch)
- {
- symbolTable.insertVariableExt(ESSL1_BUILTINS,
- TExtension::EXT_shader_framebuffer_fetch,
- "gl_LastFragData", lastFragData);
- }
- else if (resources.NV_shader_framebuffer_fetch)
- {
- symbolTable.insertVariableExt(
- ESSL1_BUILTINS, TExtension::NV_shader_framebuffer_fetch, "gl_LastFragColor",
- TType(EbtFloat, EbpMedium, EvqLastFragColor, 4));
- symbolTable.insertVariableExt(ESSL1_BUILTINS,
- TExtension::NV_shader_framebuffer_fetch,
- "gl_LastFragData", lastFragData);
- }
- }
- else if (resources.ARM_shader_framebuffer_fetch)
- {
- symbolTable.insertVariableExt(
- ESSL1_BUILTINS, TExtension::ARM_shader_framebuffer_fetch, "gl_LastFragColorARM",
- TType(EbtFloat, EbpMedium, EvqLastFragColor, 4));
- }
-
- if (resources.OES_geometry_shader)
- {
- TExtension extension = TExtension::OES_geometry_shader;
- symbolTable.insertVariableExt(ESSL3_1_BUILTINS, extension, "gl_PrimitiveID",
- TType(EbtInt, EbpHigh, EvqPrimitiveID, 1));
- symbolTable.insertVariableExt(ESSL3_1_BUILTINS, extension, "gl_Layer",
- TType(EbtInt, EbpHigh, EvqLayer, 1));
- }
-
- break;
- }
- case GL_VERTEX_SHADER:
- {
- symbolTable.insertVariable(COMMON_BUILTINS, "gl_Position",
- TType(EbtFloat, EbpHigh, EvqPosition, 4));
- symbolTable.insertVariable(COMMON_BUILTINS, "gl_PointSize",
- TType(EbtFloat, EbpMedium, EvqPointSize, 1));
- symbolTable.insertVariable(ESSL3_BUILTINS, "gl_InstanceID",
- TType(EbtInt, EbpHigh, EvqInstanceID, 1));
- symbolTable.insertVariable(ESSL3_BUILTINS, "gl_VertexID",
- TType(EbtInt, EbpHigh, EvqVertexID, 1));
-
- // For internal use by ANGLE - not exposed to the parser.
- symbolTable.insertVariable(GLSL_BUILTINS, "gl_ViewportIndex",
- TType(EbtInt, EbpHigh, EvqViewportIndex));
- // gl_Layer exists in other shader stages in ESSL, but not in vertex shader so far.
- symbolTable.insertVariable(GLSL_BUILTINS, "gl_Layer", TType(EbtInt, EbpHigh, EvqLayer));
- break;
- }
- case GL_COMPUTE_SHADER:
- {
- symbolTable.insertVariable(ESSL3_1_BUILTINS, "gl_NumWorkGroups",
- TType(EbtUInt, EbpUndefined, EvqNumWorkGroups, 3));
- symbolTable.insertVariable(ESSL3_1_BUILTINS, "gl_WorkGroupSize",
- TType(EbtUInt, EbpUndefined, EvqWorkGroupSize, 3));
- symbolTable.insertVariable(ESSL3_1_BUILTINS, "gl_WorkGroupID",
- TType(EbtUInt, EbpUndefined, EvqWorkGroupID, 3));
- symbolTable.insertVariable(ESSL3_1_BUILTINS, "gl_LocalInv