blob: 0837868f0921e800764279a982b235845378e558 [file] [log] [blame]
alokp@chromium.org07620a52010-09-23 17:53:56 +00001//
Jamie Madill88f6e942014-02-19 10:27:53 -05002// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
alokp@chromium.org07620a52010-09-23 17:53:56 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
Corentin Wallez8b28a8b2016-09-15 19:47:56 -04007#include "compiler/translator/Compiler.h"
8
9#include <sstream>
10
11#include "angle_gl.h"
12#include "common/utilities.h"
Qiankun Miao09cfac62016-09-06 17:25:16 +080013#include "compiler/translator/AddAndTrueToLoopCondition.h"
Dmitry Skiba01971112015-07-10 14:54:00 -040014#include "compiler/translator/Cache.h"
Corentin Wallez71d147f2015-02-11 11:15:24 -080015#include "compiler/translator/CallDAG.h"
Olli Etuahoab918822017-07-14 17:03:42 +030016#include "compiler/translator/ClampPointSize.h"
Olli Etuaho78ed6cd2017-08-09 16:19:00 +030017#include "compiler/translator/CollectVariables.h"
Martin Radev69056a12017-05-18 11:14:50 +030018#include "compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.h"
Olli Etuaho3d932d82016-04-12 11:10:30 +030019#include "compiler/translator/DeferGlobalInitializers.h"
Zhenyao Mo4e94fea2016-08-09 14:31:37 -070020#include "compiler/translator/EmulateGLFragColorBroadcast.h"
Jamie Madilld5696192016-10-06 11:09:24 -040021#include "compiler/translator/EmulatePrecision.h"
Geoff Lang17732822013-08-29 13:46:49 -040022#include "compiler/translator/Initialize.h"
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080023#include "compiler/translator/InitializeVariables.h"
Olli Etuaho9733cee2017-05-11 19:14:35 +030024#include "compiler/translator/IntermNodePatternMatcher.h"
Olli Etuahocccf2b02017-07-05 14:50:54 +030025#include "compiler/translator/IsASTDepthBelowLimit.h"
26#include "compiler/translator/OutputTree.h"
Jamie Madill6b9cb252013-10-17 10:45:47 -040027#include "compiler/translator/ParseContext.h"
Olli Etuaho87c35882017-10-19 15:19:38 +030028#include "compiler/translator/PruneNoOps.h"
Zhenyao Moe740add2014-07-18 17:01:01 -070029#include "compiler/translator/RegenerateStructNames.h"
Olli Etuahobb5a7e22017-08-30 13:03:12 +030030#include "compiler/translator/RemoveArrayLengthMethod.h"
Olli Etuahoc1f14fb2017-10-28 19:17:23 +030031#include "compiler/translator/RemoveEmptySwitchStatements.h"
Qiankun Miao705a9192016-08-29 10:05:27 +080032#include "compiler/translator/RemoveInvariantDeclaration.h"
Olli Etuaho923ecef2017-10-11 12:01:38 +030033#include "compiler/translator/RemoveNoOpCasesFromEndOfSwitchStatements.h"
Olli Etuaho5c407bb2015-06-01 12:20:39 +030034#include "compiler/translator/RemovePow.h"
Corentin Wallezd4b50542015-09-28 12:19:26 -070035#include "compiler/translator/RewriteDoWhile.h"
Zhenyao Mocd68fe72014-07-11 10:45:44 -070036#include "compiler/translator/ScalarizeVecAndMatConstructorArgs.h"
Olli Etuaho9733cee2017-05-11 19:14:35 +030037#include "compiler/translator/SeparateDeclarations.h"
38#include "compiler/translator/SimplifyLoopConditions.h"
Olli Etuahobb5a7e22017-08-30 13:03:12 +030039#include "compiler/translator/SplitSequenceOperator.h"
Zhenyao Mo7cab38b2013-10-15 12:59:30 -070040#include "compiler/translator/UnfoldShortCircuitAST.h"
Qin Jiajia7835b522016-10-08 11:20:17 +080041#include "compiler/translator/UseInterfaceBlockFields.h"
Geoff Lang17732822013-08-29 13:46:49 -040042#include "compiler/translator/ValidateLimitations.h"
Olli Etuaho19d1dc92016-03-08 17:18:46 +020043#include "compiler/translator/ValidateMaxParameters.h"
Geoff Lang17732822013-08-29 13:46:49 -040044#include "compiler/translator/ValidateOutputs.h"
Jiawei Shao4cc89e22017-08-31 14:25:54 +080045#include "compiler/translator/ValidateVaryingLocations.h"
Geoff Lang17732822013-08-29 13:46:49 -040046#include "compiler/translator/VariablePacker.h"
shannon.woods@transgaming.comda1ed362013-01-25 21:54:57 +000047#include "third_party/compiler/ArrayBoundsClamper.h"
Corentin Wallez28b65282016-06-16 07:24:50 -070048
Jamie Madillacb4b812016-11-07 13:50:29 -050049namespace sh
50{
51
Corentin Wallez28b65282016-06-16 07:24:50 -070052namespace
53{
54
55#if defined(ANGLE_ENABLE_FUZZER_CORPUS_OUTPUT)
56void DumpFuzzerCase(char const *const *shaderStrings,
57 size_t numStrings,
58 uint32_t type,
59 uint32_t spec,
60 uint32_t output,
61 uint64_t options)
62{
63 static int fileIndex = 0;
64
65 std::ostringstream o;
66 o << "corpus/" << fileIndex++ << ".sample";
67 std::string s = o.str();
68
69 // Must match the input format of the fuzzer
70 FILE *f = fopen(s.c_str(), "w");
71 fwrite(&type, sizeof(type), 1, f);
72 fwrite(&spec, sizeof(spec), 1, f);
73 fwrite(&output, sizeof(output), 1, f);
74 fwrite(&options, sizeof(options), 1, f);
75
76 char zero[128 - 20] = {0};
77 fwrite(&zero, 128 - 20, 1, f);
78
79 for (size_t i = 0; i < numStrings; i++)
80 {
81 fwrite(shaderStrings[i], sizeof(char), strlen(shaderStrings[i]), f);
82 }
83 fwrite(&zero, 1, 1, f);
84
85 fclose(f);
86}
87#endif // defined(ANGLE_ENABLE_FUZZER_CORPUS_OUTPUT)
88} // anonymous namespace
89
Jamie Madill5508f392014-02-20 13:31:36 -050090bool IsWebGLBasedSpec(ShShaderSpec spec)
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +000091{
Qiankun Miaoc2c5fc42016-08-31 15:24:22 +080092 return (spec == SH_WEBGL_SPEC || spec == SH_WEBGL2_SPEC || spec == SH_WEBGL3_SPEC);
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +000093}
94
Qingqing Dengad0d0792015-04-08 14:25:06 -070095bool IsGLSL130OrNewer(ShShaderOutput output)
96{
Jamie Madillacb4b812016-11-07 13:50:29 -050097 return (output == SH_GLSL_130_OUTPUT || output == SH_GLSL_140_OUTPUT ||
98 output == SH_GLSL_150_CORE_OUTPUT || output == SH_GLSL_330_CORE_OUTPUT ||
99 output == SH_GLSL_400_CORE_OUTPUT || output == SH_GLSL_410_CORE_OUTPUT ||
100 output == SH_GLSL_420_CORE_OUTPUT || output == SH_GLSL_430_CORE_OUTPUT ||
101 output == SH_GLSL_440_CORE_OUTPUT || output == SH_GLSL_450_CORE_OUTPUT);
Qingqing Dengad0d0792015-04-08 14:25:06 -0700102}
103
Qiankun Miao705a9192016-08-29 10:05:27 +0800104bool IsGLSL420OrNewer(ShShaderOutput output)
105{
Jamie Madillacb4b812016-11-07 13:50:29 -0500106 return (output == SH_GLSL_420_CORE_OUTPUT || output == SH_GLSL_430_CORE_OUTPUT ||
107 output == SH_GLSL_440_CORE_OUTPUT || output == SH_GLSL_450_CORE_OUTPUT);
Qiankun Miao705a9192016-08-29 10:05:27 +0800108}
109
Zhenyao Mob7bf7422016-11-08 14:44:05 -0800110bool IsGLSL410OrOlder(ShShaderOutput output)
111{
112 return (output == SH_GLSL_130_OUTPUT || output == SH_GLSL_140_OUTPUT ||
113 output == SH_GLSL_150_CORE_OUTPUT || output == SH_GLSL_330_CORE_OUTPUT ||
114 output == SH_GLSL_400_CORE_OUTPUT || output == SH_GLSL_410_CORE_OUTPUT);
115}
116
Qiankun Miao89dd8f32016-11-09 12:59:30 +0000117bool RemoveInvariant(sh::GLenum shaderType,
118 int shaderVersion,
119 ShShaderOutput outputType,
120 ShCompileOptions compileOptions)
121{
122 if ((compileOptions & SH_DONT_REMOVE_INVARIANT_FOR_FRAGMENT_INPUT) == 0 &&
123 shaderType == GL_FRAGMENT_SHADER && IsGLSL420OrNewer(outputType))
124 return true;
125
126 if ((compileOptions & SH_REMOVE_INVARIANT_AND_CENTROID_FOR_ESSL3) != 0 &&
Qiankun Miao41f9f672016-11-16 17:04:36 +0800127 shaderVersion >= 300 && shaderType == GL_VERTEX_SHADER)
Qiankun Miao89dd8f32016-11-09 12:59:30 +0000128 return true;
129
130 return false;
131}
132
Zhenyao Mo7faf1a12014-04-25 18:03:56 -0700133size_t GetGlobalMaxTokenSize(ShShaderSpec spec)
Jamie Madill88f6e942014-02-19 10:27:53 -0500134{
He Yunchao29ab9ff2015-08-06 16:58:30 +0800135 // WebGL defines a max token length of 256, while ES2 leaves max token
Jamie Madill88f6e942014-02-19 10:27:53 -0500136 // size undefined. ES3 defines a max size of 1024 characters.
Zhenyao Modb9b40b2014-10-29 15:00:04 -0700137 switch (spec)
Jamie Madill88f6e942014-02-19 10:27:53 -0500138 {
Jamie Madillacb4b812016-11-07 13:50:29 -0500139 case SH_WEBGL_SPEC:
140 return 256;
141 default:
142 return 1024;
Jamie Madill88f6e942014-02-19 10:27:53 -0500143 }
144}
145
Shao77891c02017-06-23 16:30:17 +0800146int GetMaxUniformVectorsForShaderType(GLenum shaderType, const ShBuiltInResources &resources)
147{
148 switch (shaderType)
149 {
150 case GL_VERTEX_SHADER:
151 return resources.MaxVertexUniformVectors;
152 case GL_FRAGMENT_SHADER:
153 return resources.MaxFragmentUniformVectors;
Shaob5cc1192017-07-06 10:47:20 +0800154
155 // TODO (jiawei.shao@intel.com): check if we need finer-grained component counting
Shao77891c02017-06-23 16:30:17 +0800156 case GL_COMPUTE_SHADER:
Shao77891c02017-06-23 16:30:17 +0800157 return resources.MaxComputeUniformComponents / 4;
Shaob5cc1192017-07-06 10:47:20 +0800158 case GL_GEOMETRY_SHADER_OES:
159 return resources.MaxGeometryUniformComponents / 4;
Shao77891c02017-06-23 16:30:17 +0800160 default:
Shaob5cc1192017-07-06 10:47:20 +0800161 UNREACHABLE();
Shao77891c02017-06-23 16:30:17 +0800162 return -1;
163 }
164}
165
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500166namespace
167{
Zhenyao Modb9b40b2014-10-29 15:00:04 -0700168
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800169class TScopedPoolAllocator
170{
171 public:
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500172 TScopedPoolAllocator(TPoolAllocator *allocator) : mAllocator(allocator)
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800173 {
Alok Priyadarshibc3f1ac2013-09-23 14:57:02 -0400174 mAllocator->push();
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +0000175 SetGlobalPoolAllocator(mAllocator);
176 }
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800177 ~TScopedPoolAllocator()
178 {
Yunchao Hef81ce4a2017-04-24 10:49:17 +0800179 SetGlobalPoolAllocator(nullptr);
Alok Priyadarshibc3f1ac2013-09-23 14:57:02 -0400180 mAllocator->pop();
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +0000181 }
182
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800183 private:
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500184 TPoolAllocator *mAllocator;
Alok Priyadarshibc3f1ac2013-09-23 14:57:02 -0400185};
186
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800187class TScopedSymbolTableLevel
188{
189 public:
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500190 TScopedSymbolTableLevel(TSymbolTable *table) : mTable(table)
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800191 {
Alok Priyadarshibc3f1ac2013-09-23 14:57:02 -0400192 ASSERT(mTable->atBuiltInLevel());
193 mTable->push();
194 }
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800195 ~TScopedSymbolTableLevel()
196 {
Alok Priyadarshibc3f1ac2013-09-23 14:57:02 -0400197 while (!mTable->atBuiltInLevel())
198 mTable->pop();
199 }
200
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800201 private:
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500202 TSymbolTable *mTable;
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +0000203};
Zhenyao Modb9b40b2014-10-29 15:00:04 -0700204
205int MapSpecToShaderVersion(ShShaderSpec spec)
206{
207 switch (spec)
208 {
Jamie Madillacb4b812016-11-07 13:50:29 -0500209 case SH_GLES2_SPEC:
210 case SH_WEBGL_SPEC:
211 return 100;
212 case SH_GLES3_SPEC:
213 case SH_WEBGL2_SPEC:
214 return 300;
215 case SH_GLES3_1_SPEC:
216 case SH_WEBGL3_SPEC:
217 return 310;
218 default:
219 UNREACHABLE();
220 return 0;
Zhenyao Modb9b40b2014-10-29 15:00:04 -0700221 }
222}
223
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +0000224} // namespace
225
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800226TShHandleBase::TShHandleBase()
227{
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +0000228 allocator.push();
229 SetGlobalPoolAllocator(&allocator);
230}
231
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800232TShHandleBase::~TShHandleBase()
233{
Yunchao Hef81ce4a2017-04-24 10:49:17 +0800234 SetGlobalPoolAllocator(nullptr);
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +0000235 allocator.popAll();
236}
237
Jamie Madill183bde52014-07-02 15:31:19 -0400238TCompiler::TCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
Kenneth Russellbccc65d2016-07-19 16:48:43 -0700239 : variablesCollected(false),
Olli Etuahob12040c2017-06-27 14:20:45 +0300240 mGLPositionInitialized(false),
Kenneth Russellbccc65d2016-07-19 16:48:43 -0700241 shaderType(type),
zmo@google.comf420c422011-09-12 18:27:59 +0000242 shaderSpec(spec),
Jamie Madill68fe74a2014-05-27 12:56:01 -0400243 outputType(output),
Jamie Madilleb1a0102013-07-08 13:31:38 -0400244 maxUniformVectors(0),
245 maxExpressionComplexity(0),
246 maxCallStackDepth(0),
Olli Etuaho19d1dc92016-03-08 17:18:46 +0200247 maxFunctionParameters(0),
shannon.woods%transgaming.com@gtempaccount.comcbb6b6a2013-04-13 03:27:47 +0000248 fragmentPrecisionHigh(false),
shannon.woods@transgaming.com1d432bb2013-01-25 21:57:28 +0000249 clampingStrategy(SH_CLAMP_WITH_CLAMP_INTRINSIC),
Olli Etuaho8efc5ad2015-03-03 17:21:10 +0200250 builtInFunctionEmulator(),
Olli Etuaho77ba4082016-12-16 12:01:18 +0000251 mDiagnostics(infoSink.info),
Yunchao Hef81ce4a2017-04-24 10:49:17 +0800252 mSourcePath(nullptr),
Shaob5cc1192017-07-06 10:47:20 +0800253 mComputeShaderLocalSizeDeclared(false),
254 mGeometryShaderMaxVertices(-1),
255 mGeometryShaderInvocations(0),
256 mGeometryShaderInputPrimitiveType(EptUndefined),
257 mGeometryShaderOutputPrimitiveType(EptUndefined)
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000258{
Martin Radev802abe02016-08-04 17:48:32 +0300259 mComputeShaderLocalSize.fill(1);
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000260}
261
262TCompiler::~TCompiler()
263{
264}
265
Qiankun Miao7ebb97f2016-09-08 18:01:50 +0800266bool TCompiler::shouldRunLoopAndIndexingValidation(ShCompileOptions compileOptions) const
Olli Etuaho5d91dda2015-06-18 15:47:46 +0300267{
268 // If compiling an ESSL 1.00 shader for WebGL, or if its been requested through the API,
269 // validate loop and indexing as well (to verify that the shader only uses minimal functionality
270 // of ESSL 1.00 as in Appendix A of the spec).
271 return (IsWebGLBasedSpec(shaderSpec) && shaderVersion == 100) ||
272 (compileOptions & SH_VALIDATE_LOOP_INDEXING);
273}
274
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500275bool TCompiler::Init(const ShBuiltInResources &resources)
alokp@chromium.org07620a52010-09-23 17:53:56 +0000276{
Shao77891c02017-06-23 16:30:17 +0800277 shaderVersion = 100;
278
279 maxUniformVectors = GetMaxUniformVectorsForShaderType(shaderType, resources);
280
Jamie Madilleb1a0102013-07-08 13:31:38 -0400281 maxExpressionComplexity = resources.MaxExpressionComplexity;
Olli Etuaho19d1dc92016-03-08 17:18:46 +0200282 maxCallStackDepth = resources.MaxCallStackDepth;
283 maxFunctionParameters = resources.MaxFunctionParameters;
Alok Priyadarshibc3f1ac2013-09-23 14:57:02 -0400284
285 SetGlobalPoolAllocator(&allocator);
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +0000286
alokp@chromium.org07620a52010-09-23 17:53:56 +0000287 // Generate built-in symbol table.
288 if (!InitBuiltInSymbolTable(resources))
289 return false;
alokp@chromium.org07620a52010-09-23 17:53:56 +0000290 InitExtensionBehavior(resources, extensionBehavior);
shannon.woods%transgaming.com@gtempaccount.comcbb6b6a2013-04-13 03:27:47 +0000291 fragmentPrecisionHigh = resources.FragmentPrecisionHigh == 1;
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +0000292
shannon.woods@transgaming.com1d432bb2013-01-25 21:57:28 +0000293 arrayBoundsClamper.SetClampingStrategy(resources.ArrayIndexClampingStrategy);
294 clampingStrategy = resources.ArrayIndexClampingStrategy;
295
daniel@transgaming.comc23f4612012-11-28 19:42:57 +0000296 hashFunction = resources.HashFunction;
297
alokp@chromium.org07620a52010-09-23 17:53:56 +0000298 return true;
299}
300
Olli Etuaho6d40bbd2016-09-30 13:49:38 +0100301TIntermBlock *TCompiler::compileTreeForTesting(const char *const shaderStrings[],
302 size_t numStrings,
303 ShCompileOptions compileOptions)
alokp@chromium.org07620a52010-09-23 17:53:56 +0000304{
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200305 return compileTreeImpl(shaderStrings, numStrings, compileOptions);
306}
307
Olli Etuaho6d40bbd2016-09-30 13:49:38 +0100308TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[],
309 size_t numStrings,
310 const ShCompileOptions compileOptions)
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200311{
alokp@chromium.org07620a52010-09-23 17:53:56 +0000312 clearResults();
313
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200314 ASSERT(numStrings > 0);
315 ASSERT(GetGlobalPoolAllocator());
alokp@chromium.org07620a52010-09-23 17:53:56 +0000316
David Yen0fbd1282015-02-02 14:46:09 -0800317 // Reset the extension behavior for each compilation unit.
318 ResetExtensionBehavior(extensionBehavior);
319
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000320 // First string is path of source file if flag is set. The actual source follows.
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +0000321 size_t firstSource = 0;
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000322 if (compileOptions & SH_SOURCE_PATH)
323 {
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200324 mSourcePath = shaderStrings[0];
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000325 ++firstSource;
326 }
327
Olli Etuahof119a262016-08-19 15:54:22 +0300328 TParseContext parseContext(symbolTable, extensionBehavior, shaderType, shaderSpec,
Olli Etuaho77ba4082016-12-16 12:01:18 +0000329 compileOptions, true, &mDiagnostics, getResources());
Olli Etuaho853dc1a2014-11-06 17:25:48 +0200330
Olli Etuahoa6996682015-10-12 14:32:30 +0300331 parseContext.setFragmentPrecisionHighOnESSL1(fragmentPrecisionHigh);
alokp@chromium.org07620a52010-09-23 17:53:56 +0000332
333 // We preserve symbols at the built-in level from compile-to-compile.
334 // Start pushing the user-defined symbols at global level.
Alok Priyadarshibc3f1ac2013-09-23 14:57:02 -0400335 TScopedSymbolTableLevel scopedSymbolLevel(&symbolTable);
alokp@chromium.org07620a52010-09-23 17:53:56 +0000336
337 // Parse shader.
Olli Etuahod10cf692017-11-02 11:06:14 +0200338 if (PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], nullptr,
339 &parseContext) != 0)
340 {
341 return nullptr;
342 }
shannon.woods%transgaming.com@gtempaccount.com0bbed382013-04-13 03:38:07 +0000343
Olli Etuahod10cf692017-11-02 11:06:14 +0200344 if (parseContext.getTreeRoot() == nullptr)
345 {
346 return nullptr;
347 }
348
349 setASTMetadata(parseContext);
350
351 if (MapSpecToShaderVersion(shaderSpec) < shaderVersion)
Zhenyao Modb9b40b2014-10-29 15:00:04 -0700352 {
Olli Etuaho77ba4082016-12-16 12:01:18 +0000353 mDiagnostics.globalError("unsupported shader version");
Olli Etuahod10cf692017-11-02 11:06:14 +0200354 return nullptr;
Zhenyao Modb9b40b2014-10-29 15:00:04 -0700355 }
shannon.woods%transgaming.com@gtempaccount.com0bbed382013-04-13 03:38:07 +0000356
Olli Etuahod10cf692017-11-02 11:06:14 +0200357 TIntermBlock *root = parseContext.getTreeRoot();
358 if (!checkAndSimplifyAST(root, parseContext, compileOptions))
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800359 {
Olli Etuahod10cf692017-11-02 11:06:14 +0200360 return nullptr;
361 }
Zhenyao Mo94ac7b72014-10-15 18:22:08 -0700362
Olli Etuahod10cf692017-11-02 11:06:14 +0200363 return root;
364}
Martin Radev802abe02016-08-04 17:48:32 +0300365
Olli Etuahod10cf692017-11-02 11:06:14 +0200366void TCompiler::setASTMetadata(const TParseContext &parseContext)
367{
368 shaderVersion = parseContext.getShaderVersion();
Olli Etuaho09b04a22016-12-15 13:30:26 +0000369
Olli Etuahod10cf692017-11-02 11:06:14 +0200370 mPragma = parseContext.pragma();
371 symbolTable.setGlobalInvariant(mPragma.stdgl.invariantAll);
alokp@chromium.orgb59a7782010-11-24 18:38:33 +0000372
Olli Etuahod10cf692017-11-02 11:06:14 +0200373 mComputeShaderLocalSizeDeclared = parseContext.isComputeShaderLocalSizeDeclared();
374 mComputeShaderLocalSize = parseContext.getComputeShaderLocalSize();
Olli Etuahoa6996682015-10-12 14:32:30 +0300375
Olli Etuahod10cf692017-11-02 11:06:14 +0200376 mNumViews = parseContext.getNumViews();
377
378 // Highp might have been auto-enabled based on shader version
379 fragmentPrecisionHigh = parseContext.getFragmentPrecisionHigh();
380
381 if (shaderType == GL_GEOMETRY_SHADER_OES)
382 {
383 mGeometryShaderInputPrimitiveType = parseContext.getGeometryShaderInputPrimitiveType();
384 mGeometryShaderOutputPrimitiveType = parseContext.getGeometryShaderOutputPrimitiveType();
385 mGeometryShaderMaxVertices = parseContext.getGeometryShaderMaxVertices();
386 mGeometryShaderInvocations = parseContext.getGeometryShaderInvocations();
387 }
388}
389
390bool TCompiler::checkAndSimplifyAST(TIntermBlock *root,
391 const TParseContext &parseContext,
392 ShCompileOptions compileOptions)
393{
394 // Disallow expressions deemed too complex.
395 if ((compileOptions & SH_LIMIT_EXPRESSION_COMPLEXITY) && !limitExpressionComplexity(root))
396 {
397 return false;
398 }
399
400 // We prune no-ops to work around driver bugs and to keep AST processing and output simple.
401 // The following kinds of no-ops are pruned:
402 // 1. Empty declarations "int;".
403 // 2. Literal statements: "1.0;". The ESSL output doesn't define a default precision
404 // for float, so float literal statements would end up with no precision which is
405 // invalid ESSL.
406 // After this empty declarations are not allowed in the AST.
407 PruneNoOps(root);
408
409 // In case the last case inside a switch statement is a certain type of no-op, GLSL
410 // compilers in drivers may not accept it. In this case we clean up the dead code from the
411 // end of switch statements. This is also required because PruneNoOps may have left switch
412 // statements that only contained an empty declaration inside the final case in an invalid
413 // state. Relies on that PruneNoOps has already been run.
414 RemoveNoOpCasesFromEndOfSwitchStatements(root, &symbolTable);
415
416 // Remove empty switch statements - this makes output simpler.
417 RemoveEmptySwitchStatements(root);
418
419 // Create the function DAG and check there is no recursion
420 if (!initCallDag(root))
421 {
422 return false;
423 }
424
425 if ((compileOptions & SH_LIMIT_CALL_STACK_DEPTH) && !checkCallDepth())
426 {
427 return false;
428 }
429
430 // Checks which functions are used and if "main" exists
431 functionMetadata.clear();
432 functionMetadata.resize(mCallDag.size());
433 if (!tagUsedFunctions())
434 {
435 return false;
436 }
437
438 if (!(compileOptions & SH_DONT_PRUNE_UNUSED_FUNCTIONS))
439 {
440 pruneUnusedFunctions(root);
441 }
442
443 if (shaderVersion >= 310 && !ValidateVaryingLocations(root, &mDiagnostics, shaderType))
444 {
445 return false;
446 }
447
448 if (shaderVersion >= 300 && shaderType == GL_FRAGMENT_SHADER &&
449 !ValidateOutputs(root, getExtensionBehavior(), compileResources.MaxDrawBuffers,
450 &mDiagnostics))
451 {
452 return false;
453 }
454
455 if (shouldRunLoopAndIndexingValidation(compileOptions) &&
456 !ValidateLimitations(root, shaderType, &symbolTable, shaderVersion, &mDiagnostics))
457 {
458 return false;
459 }
460
461 // Fail compilation if precision emulation not supported.
462 if (getResources().WEBGL_debug_shader_precision && getPragma().debugShaderPrecision &&
463 !EmulatePrecision::SupportedInLanguage(outputType))
464 {
465 mDiagnostics.globalError("Precision emulation not supported for this output type.");
466 return false;
467 }
468
469 // Built-in function emulation needs to happen after validateLimitations pass.
470 // TODO(jmadill): Remove global pool allocator.
471 GetGlobalPoolAllocator()->lock();
472 initBuiltInFunctionEmulator(&builtInFunctionEmulator, compileOptions);
473 GetGlobalPoolAllocator()->unlock();
474 builtInFunctionEmulator.markBuiltInFunctionsForEmulation(root);
475
476 // Clamping uniform array bounds needs to happen after validateLimitations pass.
477 if (compileOptions & SH_CLAMP_INDIRECT_ARRAY_BOUNDS)
478 {
479 arrayBoundsClamper.MarkIndirectArrayBoundsForClamping(root);
480 }
481
482 if ((compileOptions & SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW) &&
483 parseContext.isExtensionEnabled(TExtension::OVR_multiview) &&
484 getShaderType() != GL_COMPUTE_SHADER)
485 {
486 DeclareAndInitBuiltinsForInstancedMultiview(root, mNumViews, shaderType, compileOptions,
487 outputType, &symbolTable);
488 }
489
490 // This pass might emit short circuits so keep it before the short circuit unfolding
491 if (compileOptions & SH_REWRITE_DO_WHILE_LOOPS)
492 RewriteDoWhile(root, &symbolTable);
493
494 if (compileOptions & SH_ADD_AND_TRUE_TO_LOOP_CONDITION)
495 sh::AddAndTrueToLoopCondition(root);
496
497 if (compileOptions & SH_UNFOLD_SHORT_CIRCUIT)
498 {
499 UnfoldShortCircuitAST unfoldShortCircuit;
500 root->traverse(&unfoldShortCircuit);
501 unfoldShortCircuit.updateTree();
502 }
503
504 if (compileOptions & SH_REMOVE_POW_WITH_CONSTANT_EXPONENT)
505 {
506 RemovePow(root);
507 }
508
509 if (shouldCollectVariables(compileOptions))
510 {
511 ASSERT(!variablesCollected);
512 CollectVariables(root, &attributes, &outputVariables, &uniforms, &inputVaryings,
513 &outputVaryings, &uniformBlocks, &shaderStorageBlocks, &inBlocks,
514 hashFunction, &symbolTable, shaderVersion, shaderType, extensionBehavior);
515 collectInterfaceBlocks();
516 variablesCollected = true;
517 if (compileOptions & SH_USE_UNUSED_STANDARD_SHARED_BLOCKS)
Shaob5cc1192017-07-06 10:47:20 +0800518 {
Olli Etuahod10cf692017-11-02 11:06:14 +0200519 useAllMembersInUnusedStandardAndSharedBlocks(root);
Shaob5cc1192017-07-06 10:47:20 +0800520 }
Olli Etuahod10cf692017-11-02 11:06:14 +0200521 if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS)
Corentin Wallez71d147f2015-02-11 11:15:24 -0800522 {
Olli Etuahod10cf692017-11-02 11:06:14 +0200523 // Returns true if, after applying the packing rules in the GLSL ES 1.00.17 spec
524 // Appendix A, section 7, the shader does not use too many uniforms.
525 if (!CheckVariablesInPackingLimits(maxUniformVectors, uniforms))
Jamie Madilld5696192016-10-06 11:09:24 -0400526 {
Olli Etuahod10cf692017-11-02 11:06:14 +0200527 mDiagnostics.globalError("too many uniforms");
528 return false;
Jamie Madilld5696192016-10-06 11:09:24 -0400529 }
530 }
Olli Etuahod10cf692017-11-02 11:06:14 +0200531 if (compileOptions & SH_INIT_OUTPUT_VARIABLES)
Olli Etuaho8efc5ad2015-03-03 17:21:10 +0200532 {
Olli Etuahod10cf692017-11-02 11:06:14 +0200533 initializeOutputVariables(root);
Olli Etuahoab918822017-07-14 17:03:42 +0300534 }
alokp@chromium.org07620a52010-09-23 17:53:56 +0000535 }
536
Olli Etuahod10cf692017-11-02 11:06:14 +0200537 // gl_Position is always written in compatibility output mode.
538 // It may have been already initialized among other output variables, in that case we don't
539 // need to initialize it twice.
540 if (shaderType == GL_VERTEX_SHADER && !mGLPositionInitialized &&
541 ((compileOptions & SH_INIT_GL_POSITION) || (outputType == SH_GLSL_COMPATIBILITY_OUTPUT)))
542 {
543 initializeGLPosition(root);
544 mGLPositionInitialized = true;
545 }
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200546
Olli Etuahod10cf692017-11-02 11:06:14 +0200547 // Removing invariant declarations must be done after collecting variables.
548 // Otherwise, built-in invariant declarations don't apply.
549 if (RemoveInvariant(shaderType, shaderVersion, outputType, compileOptions))
550 {
551 sh::RemoveInvariantDeclaration(root);
552 }
553
554 if (compileOptions & SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS)
555 {
556 ScalarizeVecAndMatConstructorArgs(root, shaderType, fragmentPrecisionHigh, &symbolTable);
557 }
558
559 if (compileOptions & SH_REGENERATE_STRUCT_NAMES)
560 {
561 RegenerateStructNames gen(&symbolTable, shaderVersion);
562 root->traverse(&gen);
563 }
564
565 if (shaderType == GL_FRAGMENT_SHADER && shaderVersion == 100 &&
566 compileResources.EXT_draw_buffers && compileResources.MaxDrawBuffers > 1 &&
567 IsExtensionEnabled(extensionBehavior, TExtension::EXT_draw_buffers))
568 {
569 EmulateGLFragColorBroadcast(root, compileResources.MaxDrawBuffers, &outputVariables,
570 &symbolTable, shaderVersion);
571 }
572
573 DeferGlobalInitializers(root, needToInitializeGlobalsInAST(), &symbolTable);
574
575 // Split multi declarations and remove calls to array length().
576 // Note that SimplifyLoopConditions needs to be run before any other AST transformations
577 // that may need to generate new statements from loop conditions or loop expressions.
578 SimplifyLoopConditions(
579 root,
580 IntermNodePatternMatcher::kMultiDeclaration | IntermNodePatternMatcher::kArrayLengthMethod,
581 &getSymbolTable(), getShaderVersion());
582
583 // Note that separate declarations need to be run before other AST transformations that
584 // generate new statements from expressions.
585 SeparateDeclarations(root);
586
587 SplitSequenceOperator(root, IntermNodePatternMatcher::kArrayLengthMethod, &getSymbolTable(),
588 getShaderVersion());
589
590 RemoveArrayLengthMethod(root);
591
592 if ((compileOptions & SH_INITIALIZE_UNINITIALIZED_LOCALS) && getOutputType())
593 {
594 // Initialize uninitialized local variables.
595 // In some cases initializing can generate extra statements in the parent block, such as
596 // when initializing nameless structs or initializing arrays in ESSL 1.00. In that case
597 // we need to first simplify loop conditions. We've already separated declarations
598 // earlier, which is also required. If we don't follow the Appendix A limitations, loop
599 // init statements can declare arrays or nameless structs and have multiple
600 // declarations.
601
602 if (!shouldRunLoopAndIndexingValidation(compileOptions))
603 {
604 SimplifyLoopConditions(root,
605 IntermNodePatternMatcher::kArrayDeclaration |
606 IntermNodePatternMatcher::kNamelessStructDeclaration,
607 &getSymbolTable(), getShaderVersion());
608 }
609 InitializeUninitializedLocals(root, getShaderVersion());
610 }
611
612 if (getShaderType() == GL_VERTEX_SHADER && (compileOptions & SH_CLAMP_POINT_SIZE))
613 {
614 ClampPointSize(root, compileResources.MaxPointSize, &getSymbolTable());
615 }
616
617 return true;
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200618}
619
Qiankun Miao7ebb97f2016-09-08 18:01:50 +0800620bool TCompiler::compile(const char *const shaderStrings[],
621 size_t numStrings,
622 ShCompileOptions compileOptionsIn)
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200623{
Corentin Wallez28b65282016-06-16 07:24:50 -0700624#if defined(ANGLE_ENABLE_FUZZER_CORPUS_OUTPUT)
625 DumpFuzzerCase(shaderStrings, numStrings, shaderType, shaderSpec, outputType, compileOptionsIn);
626#endif // defined(ANGLE_ENABLE_FUZZER_CORPUS_OUTPUT)
627
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200628 if (numStrings == 0)
629 return true;
630
Qiankun Miao7ebb97f2016-09-08 18:01:50 +0800631 ShCompileOptions compileOptions = compileOptionsIn;
Kenneth Russellbccc65d2016-07-19 16:48:43 -0700632
633 // Apply key workarounds.
634 if (shouldFlattenPragmaStdglInvariantAll())
635 {
636 // This should be harmless to do in all cases, but for the moment, do it only conditionally.
637 compileOptions |= SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL;
638 }
639
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200640 TScopedPoolAllocator scopedAlloc(&allocator);
Olli Etuaho6d40bbd2016-09-30 13:49:38 +0100641 TIntermBlock *root = compileTreeImpl(shaderStrings, numStrings, compileOptions);
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200642
643 if (root)
644 {
645 if (compileOptions & SH_INTERMEDIATE_TREE)
Olli Etuahocccf2b02017-07-05 14:50:54 +0300646 OutputTree(root, infoSink.info);
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200647
648 if (compileOptions & SH_OBJECT_CODE)
Olli Etuaho89a69a02017-10-23 12:20:45 +0300649 {
650 PerformanceDiagnostics perfDiagnostics(&mDiagnostics);
651 translate(root, compileOptions, &perfDiagnostics);
652 }
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200653
654 // The IntermNode tree doesn't need to be deleted here, since the
655 // memory will be freed in a big chunk by the PoolAllocator.
656 return true;
657 }
658 return false;
alokp@chromium.org07620a52010-09-23 17:53:56 +0000659}
660
Nicolas Capens49a88872013-06-20 09:54:03 -0400661bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
alokp@chromium.org07620a52010-09-23 17:53:56 +0000662{
Olli Etuaho28cb0362016-11-22 15:42:37 +0000663 if (resources.MaxDrawBuffers < 1)
664 {
665 return false;
666 }
667 if (resources.EXT_blend_func_extended && resources.MaxDualSourceDrawBuffers < 1)
668 {
669 return false;
670 }
671
shannon.woods%transgaming.com@gtempaccount.com18b4c4b2013-04-13 03:31:40 +0000672 compileResources = resources;
Shannon Woods2d76e5f2014-05-16 17:46:41 -0400673 setResourceString();
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000674
Olli Etuaho977ee7e2017-07-21 11:38:27 +0300675 ASSERT(symbolTable.isEmpty());
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500676 symbolTable.push(); // COMMON_BUILTINS
677 symbolTable.push(); // ESSL1_BUILTINS
678 symbolTable.push(); // ESSL3_BUILTINS
679 symbolTable.push(); // ESSL3_1_BUILTINS
Olli Etuaho977ee7e2017-07-21 11:38:27 +0300680 symbolTable.push(); // GLSL_BUILTINS
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000681
Jamie Madillacb4b812016-11-07 13:50:29 -0500682 switch (shaderType)
Nicolas Capens49a88872013-06-20 09:54:03 -0400683 {
Jamie Madillacb4b812016-11-07 13:50:29 -0500684 case GL_FRAGMENT_SHADER:
Olli Etuahocce89652017-06-19 16:04:09 +0300685 symbolTable.setDefaultPrecision(EbtInt, EbpMedium);
Jamie Madillacb4b812016-11-07 13:50:29 -0500686 break;
687 case GL_VERTEX_SHADER:
Jamie Madillacb4b812016-11-07 13:50:29 -0500688 case GL_COMPUTE_SHADER:
Shaob5cc1192017-07-06 10:47:20 +0800689 case GL_GEOMETRY_SHADER_OES:
Olli Etuahocce89652017-06-19 16:04:09 +0300690 symbolTable.setDefaultPrecision(EbtInt, EbpHigh);
691 symbolTable.setDefaultPrecision(EbtFloat, EbpHigh);
Jamie Madillacb4b812016-11-07 13:50:29 -0500692 break;
693 default:
Shaob5cc1192017-07-06 10:47:20 +0800694 UNREACHABLE();
Nicolas Capens49a88872013-06-20 09:54:03 -0400695 }
Olli Etuaho183d7e22015-11-20 15:59:09 +0200696 // Set defaults for sampler types that have default precision, even those that are
Zhenyao Moa5a1dfc2013-09-23 14:57:03 -0400697 // only available if an extension exists.
Olli Etuaho183d7e22015-11-20 15:59:09 +0200698 // New sampler types in ESSL3 don't have default precision. ESSL1 types do.
699 initSamplerDefaultPrecision(EbtSampler2D);
700 initSamplerDefaultPrecision(EbtSamplerCube);
701 // SamplerExternalOES is specified in the extension to have default precision.
702 initSamplerDefaultPrecision(EbtSamplerExternalOES);
Andrei Volykhina5527072017-03-22 16:46:30 +0300703 // SamplerExternal2DY2YEXT is specified in the extension to have default precision.
704 initSamplerDefaultPrecision(EbtSamplerExternal2DY2YEXT);
Olli Etuaho183d7e22015-11-20 15:59:09 +0200705 // It isn't specified whether Sampler2DRect has default precision.
706 initSamplerDefaultPrecision(EbtSampler2DRect);
Nicolas Capens49a88872013-06-20 09:54:03 -0400707
Olli Etuahocce89652017-06-19 16:04:09 +0300708 symbolTable.setDefaultPrecision(EbtAtomicCounter, EbpHigh);
jchen104cdac9e2017-05-08 11:01:20 +0800709
Jamie Madill1b452142013-07-12 14:51:11 -0400710 InsertBuiltInFunctions(shaderType, shaderSpec, resources, symbolTable);
Nicolas Capens49a88872013-06-20 09:54:03 -0400711
712 IdentifyBuiltIns(shaderType, shaderSpec, resources, symbolTable);
713
714 return true;
alokp@chromium.org07620a52010-09-23 17:53:56 +0000715}
716
Olli Etuaho183d7e22015-11-20 15:59:09 +0200717void TCompiler::initSamplerDefaultPrecision(TBasicType samplerType)
718{
719 ASSERT(samplerType > EbtGuardSamplerBegin && samplerType < EbtGuardSamplerEnd);
Olli Etuahocce89652017-06-19 16:04:09 +0300720 symbolTable.setDefaultPrecision(samplerType, EbpLow);
Olli Etuaho183d7e22015-11-20 15:59:09 +0200721}
722
Shannon Woods2d76e5f2014-05-16 17:46:41 -0400723void TCompiler::setResourceString()
724{
725 std::ostringstream strstream;
Geoff Langb66a9092016-05-16 15:59:14 -0400726
727 // clang-format off
Shannon Woods2d76e5f2014-05-16 17:46:41 -0400728 strstream << ":MaxVertexAttribs:" << compileResources.MaxVertexAttribs
Jamie Madillacb4b812016-11-07 13:50:29 -0500729 << ":MaxVertexUniformVectors:" << compileResources.MaxVertexUniformVectors
730 << ":MaxVaryingVectors:" << compileResources.MaxVaryingVectors
731 << ":MaxVertexTextureImageUnits:" << compileResources.MaxVertexTextureImageUnits
732 << ":MaxCombinedTextureImageUnits:" << compileResources.MaxCombinedTextureImageUnits
733 << ":MaxTextureImageUnits:" << compileResources.MaxTextureImageUnits
734 << ":MaxFragmentUniformVectors:" << compileResources.MaxFragmentUniformVectors
735 << ":MaxDrawBuffers:" << compileResources.MaxDrawBuffers
736 << ":OES_standard_derivatives:" << compileResources.OES_standard_derivatives
737 << ":OES_EGL_image_external:" << compileResources.OES_EGL_image_external
738 << ":OES_EGL_image_external_essl3:" << compileResources.OES_EGL_image_external_essl3
739 << ":NV_EGL_stream_consumer_external:" << compileResources.NV_EGL_stream_consumer_external
740 << ":ARB_texture_rectangle:" << compileResources.ARB_texture_rectangle
741 << ":EXT_draw_buffers:" << compileResources.EXT_draw_buffers
742 << ":FragmentPrecisionHigh:" << compileResources.FragmentPrecisionHigh
743 << ":MaxExpressionComplexity:" << compileResources.MaxExpressionComplexity
744 << ":MaxCallStackDepth:" << compileResources.MaxCallStackDepth
745 << ":MaxFunctionParameters:" << compileResources.MaxFunctionParameters
746 << ":EXT_blend_func_extended:" << compileResources.EXT_blend_func_extended
747 << ":EXT_frag_depth:" << compileResources.EXT_frag_depth
748 << ":EXT_shader_texture_lod:" << compileResources.EXT_shader_texture_lod
749 << ":EXT_shader_framebuffer_fetch:" << compileResources.EXT_shader_framebuffer_fetch
750 << ":NV_shader_framebuffer_fetch:" << compileResources.NV_shader_framebuffer_fetch
751 << ":ARM_shader_framebuffer_fetch:" << compileResources.ARM_shader_framebuffer_fetch
Martin Radev318f9aa2017-05-17 17:47:28 +0300752 << ":OVR_multiview:" << compileResources.OVR_multiview
Andrei Volykhina5527072017-03-22 16:46:30 +0300753 << ":EXT_YUV_target:" << compileResources.EXT_YUV_target
Shaob5cc1192017-07-06 10:47:20 +0800754 << ":OES_geometry_shader:" << compileResources.OES_geometry_shader
Jamie Madillacb4b812016-11-07 13:50:29 -0500755 << ":MaxVertexOutputVectors:" << compileResources.MaxVertexOutputVectors
756 << ":MaxFragmentInputVectors:" << compileResources.MaxFragmentInputVectors
757 << ":MinProgramTexelOffset:" << compileResources.MinProgramTexelOffset
758 << ":MaxProgramTexelOffset:" << compileResources.MaxProgramTexelOffset
759 << ":MaxDualSourceDrawBuffers:" << compileResources.MaxDualSourceDrawBuffers
Martin Radev318f9aa2017-05-17 17:47:28 +0300760 << ":MaxViewsOVR:" << compileResources.MaxViewsOVR
Jamie Madillacb4b812016-11-07 13:50:29 -0500761 << ":NV_draw_buffers:" << compileResources.NV_draw_buffers
762 << ":WEBGL_debug_shader_precision:" << compileResources.WEBGL_debug_shader_precision
Martin Radev84aa2dc2017-09-11 15:51:02 +0300763 << ":MinProgramTextureGatherOffset:" << compileResources.MinProgramTextureGatherOffset
764 << ":MaxProgramTextureGatherOffset:" << compileResources.MaxProgramTextureGatherOffset
Jamie Madillacb4b812016-11-07 13:50:29 -0500765 << ":MaxImageUnits:" << compileResources.MaxImageUnits
766 << ":MaxVertexImageUniforms:" << compileResources.MaxVertexImageUniforms
767 << ":MaxFragmentImageUniforms:" << compileResources.MaxFragmentImageUniforms
768 << ":MaxComputeImageUniforms:" << compileResources.MaxComputeImageUniforms
769 << ":MaxCombinedImageUniforms:" << compileResources.MaxCombinedImageUniforms
770 << ":MaxCombinedShaderOutputResources:" << compileResources.MaxCombinedShaderOutputResources
771 << ":MaxComputeWorkGroupCountX:" << compileResources.MaxComputeWorkGroupCount[0]
772 << ":MaxComputeWorkGroupCountY:" << compileResources.MaxComputeWorkGroupCount[1]
773 << ":MaxComputeWorkGroupCountZ:" << compileResources.MaxComputeWorkGroupCount[2]
774 << ":MaxComputeWorkGroupSizeX:" << compileResources.MaxComputeWorkGroupSize[0]
775 << ":MaxComputeWorkGroupSizeY:" << compileResources.MaxComputeWorkGroupSize[1]
776 << ":MaxComputeWorkGroupSizeZ:" << compileResources.MaxComputeWorkGroupSize[2]
777 << ":MaxComputeUniformComponents:" << compileResources.MaxComputeUniformComponents
778 << ":MaxComputeTextureImageUnits:" << compileResources.MaxComputeTextureImageUnits
779 << ":MaxComputeAtomicCounters:" << compileResources.MaxComputeAtomicCounters
780 << ":MaxComputeAtomicCounterBuffers:" << compileResources.MaxComputeAtomicCounterBuffers
781 << ":MaxVertexAtomicCounters:" << compileResources.MaxVertexAtomicCounters
782 << ":MaxFragmentAtomicCounters:" << compileResources.MaxFragmentAtomicCounters
783 << ":MaxCombinedAtomicCounters:" << compileResources.MaxCombinedAtomicCounters
784 << ":MaxAtomicCounterBindings:" << compileResources.MaxAtomicCounterBindings
785 << ":MaxVertexAtomicCounterBuffers:" << compileResources.MaxVertexAtomicCounterBuffers
786 << ":MaxFragmentAtomicCounterBuffers:" << compileResources.MaxFragmentAtomicCounterBuffers
787 << ":MaxCombinedAtomicCounterBuffers:" << compileResources.MaxCombinedAtomicCounterBuffers
Shaob5cc1192017-07-06 10:47:20 +0800788 << ":MaxAtomicCounterBufferSize:" << compileResources.MaxAtomicCounterBufferSize
Shaob5cc1192017-07-06 10:47:20 +0800789 << ":MaxGeometryUniformComponents:" << compileResources.MaxGeometryUniformComponents
Jiawei Shaod27f5c82017-08-23 09:38:08 +0800790 << ":MaxGeometryUniformBlocks:" << compileResources.MaxGeometryUniformBlocks
791 << ":MaxGeometryInputComponents:" << compileResources.MaxGeometryInputComponents
792 << ":MaxGeometryOutputComponents:" << compileResources.MaxGeometryOutputComponents
793 << ":MaxGeometryOutputVertices:" << compileResources.MaxGeometryOutputVertices
794 << ":MaxGeometryTotalOutputComponents:" << compileResources.MaxGeometryTotalOutputComponents
795 << ":MaxGeometryTextureImageUnits:" << compileResources.MaxGeometryTextureImageUnits
796 << ":MaxGeometryAtomicCounterBuffers:" << compileResources.MaxGeometryAtomicCounterBuffers
797 << ":MaxGeometryAtomicCounters:" << compileResources.MaxGeometryAtomicCounters
798 << ":MaxGeometryShaderStorageBlocks:" << compileResources.MaxGeometryShaderStorageBlocks
799 << ":MaxGeometryShaderInvocations:" << compileResources.MaxGeometryShaderInvocations
800 << ":MaxGeometryImageUniforms:" << compileResources.MaxGeometryImageUniforms;
Geoff Langb66a9092016-05-16 15:59:14 -0400801 // clang-format on
Shannon Woods2d76e5f2014-05-16 17:46:41 -0400802
803 builtInResourcesString = strstream.str();
804}
805
Jiajia Qin9b11ea42017-07-11 16:50:08 +0800806void TCompiler::collectInterfaceBlocks()
807{
808 ASSERT(interfaceBlocks.empty());
Jiawei Shaod8105a02017-08-08 09:54:36 +0800809 interfaceBlocks.reserve(uniformBlocks.size() + shaderStorageBlocks.size() + inBlocks.size());
Jiajia Qin9b11ea42017-07-11 16:50:08 +0800810 interfaceBlocks.insert(interfaceBlocks.end(), uniformBlocks.begin(), uniformBlocks.end());
811 interfaceBlocks.insert(interfaceBlocks.end(), shaderStorageBlocks.begin(),
812 shaderStorageBlocks.end());
Jiawei Shaod8105a02017-08-08 09:54:36 +0800813 interfaceBlocks.insert(interfaceBlocks.end(), inBlocks.begin(), inBlocks.end());
Jiajia Qin9b11ea42017-07-11 16:50:08 +0800814}
815
alokp@chromium.org07620a52010-09-23 17:53:56 +0000816void TCompiler::clearResults()
817{
daniel@transgaming.com4167cc92013-01-11 04:11:53 +0000818 arrayBoundsClamper.Cleanup();
alokp@chromium.org07620a52010-09-23 17:53:56 +0000819 infoSink.info.erase();
820 infoSink.obj.erase();
821 infoSink.debug.erase();
Olli Etuaho77ba4082016-12-16 12:01:18 +0000822 mDiagnostics.resetErrorCount();
alokp@chromium.org07620a52010-09-23 17:53:56 +0000823
Jamie Madilled27c722014-07-02 15:31:23 -0400824 attributes.clear();
825 outputVariables.clear();
alokp@chromium.org07620a52010-09-23 17:53:56 +0000826 uniforms.clear();
Jiawei-Shaodf7d7c92017-07-31 09:34:04 +0800827 inputVaryings.clear();
828 outputVaryings.clear();
Jamie Madilled27c722014-07-02 15:31:23 -0400829 interfaceBlocks.clear();
Jiajia Qin9b11ea42017-07-11 16:50:08 +0800830 uniformBlocks.clear();
831 shaderStorageBlocks.clear();
Jiawei Shaod8105a02017-08-08 09:54:36 +0800832 inBlocks.clear();
Kenneth Russellbccc65d2016-07-19 16:48:43 -0700833 variablesCollected = false;
Olli Etuahob12040c2017-06-27 14:20:45 +0300834 mGLPositionInitialized = false;
zmo@google.coma3b4ab42011-09-16 00:53:26 +0000835
Olli Etuaho09b04a22016-12-15 13:30:26 +0000836 mNumViews = -1;
837
Shaob5cc1192017-07-06 10:47:20 +0800838 mGeometryShaderInputPrimitiveType = EptUndefined;
839 mGeometryShaderOutputPrimitiveType = EptUndefined;
840 mGeometryShaderInvocations = 0;
841 mGeometryShaderMaxVertices = -1;
842
Olli Etuahodfa75e82017-01-23 09:43:06 -0800843 builtInFunctionEmulator.cleanup();
daniel@transgaming.com0aa3b5a2012-11-28 19:43:24 +0000844
845 nameMap.clear();
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200846
Yunchao Hed7297bf2017-04-19 15:27:10 +0800847 mSourcePath = nullptr;
alokp@chromium.org07620a52010-09-23 17:53:56 +0000848}
849
Corentin Wallez71d147f2015-02-11 11:15:24 -0800850bool TCompiler::initCallDag(TIntermNode *root)
zmo@google.comb1762df2011-07-30 02:04:23 +0000851{
Corentin Wallez71d147f2015-02-11 11:15:24 -0800852 mCallDag.clear();
853
Olli Etuaho77ba4082016-12-16 12:01:18 +0000854 switch (mCallDag.init(root, &mDiagnostics))
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800855 {
Jamie Madillacb4b812016-11-07 13:50:29 -0500856 case CallDAG::INITDAG_SUCCESS:
857 return true;
858 case CallDAG::INITDAG_RECURSION:
Jamie Madillacb4b812016-11-07 13:50:29 -0500859 case CallDAG::INITDAG_UNDEFINED:
Olli Etuaho77ba4082016-12-16 12:01:18 +0000860 // Error message has already been written out.
861 ASSERT(mDiagnostics.numErrors() > 0);
Jamie Madillacb4b812016-11-07 13:50:29 -0500862 return false;
Corentin Wallez71d147f2015-02-11 11:15:24 -0800863 }
864
865 UNREACHABLE();
866 return true;
867}
868
869bool TCompiler::checkCallDepth()
870{
871 std::vector<int> depths(mCallDag.size());
872
873 for (size_t i = 0; i < mCallDag.size(); i++)
874 {
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500875 int depth = 0;
Corentin Wallez71d147f2015-02-11 11:15:24 -0800876 auto &record = mCallDag.getRecordFromIndex(i);
877
878 for (auto &calleeIndex : record.callees)
879 {
880 depth = std::max(depth, depths[calleeIndex] + 1);
881 }
882
883 depths[i] = depth;
884
885 if (depth >= maxCallStackDepth)
886 {
887 // Trace back the function chain to have a meaningful info log.
Olli Etuaho77ba4082016-12-16 12:01:18 +0000888 std::stringstream errorStream;
889 errorStream << "Call stack too deep (larger than " << maxCallStackDepth
890 << ") with the following call chain: " << record.name;
Corentin Wallez71d147f2015-02-11 11:15:24 -0800891
Cooper Partin4d61f7e2015-08-12 10:56:50 -0700892 int currentFunction = static_cast<int>(i);
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500893 int currentDepth = depth;
Corentin Wallez71d147f2015-02-11 11:15:24 -0800894
895 while (currentFunction != -1)
896 {
Olli Etuaho77ba4082016-12-16 12:01:18 +0000897 errorStream << " -> " << mCallDag.getRecordFromIndex(currentFunction).name;
Corentin Wallez71d147f2015-02-11 11:15:24 -0800898
899 int nextFunction = -1;
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500900 for (auto &calleeIndex : mCallDag.getRecordFromIndex(currentFunction).callees)
Corentin Wallez71d147f2015-02-11 11:15:24 -0800901 {
902 if (depths[calleeIndex] == currentDepth - 1)
903 {
904 currentDepth--;
905 nextFunction = calleeIndex;
906 }
907 }
908
909 currentFunction = nextFunction;
910 }
911
Olli Etuaho77ba4082016-12-16 12:01:18 +0000912 std::string errorStr = errorStream.str();
913 mDiagnostics.globalError(errorStr.c_str());
914
Corentin Wallez71d147f2015-02-11 11:15:24 -0800915 return false;
916 }
917 }
918
919 return true;
920}
921
922bool TCompiler::tagUsedFunctions()
923{
924 // Search from main, starting from the end of the DAG as it usually is the root.
Cooper Partin4d61f7e2015-08-12 10:56:50 -0700925 for (size_t i = mCallDag.size(); i-- > 0;)
Corentin Wallez71d147f2015-02-11 11:15:24 -0800926 {
Olli Etuahoec9232b2017-03-27 17:01:37 +0300927 if (mCallDag.getRecordFromIndex(i).name == "main")
Corentin Wallez71d147f2015-02-11 11:15:24 -0800928 {
929 internalTagUsedFunction(i);
930 return true;
931 }
932 }
933
Olli Etuaho77ba4082016-12-16 12:01:18 +0000934 mDiagnostics.globalError("Missing main()");
Corentin Wallez71d147f2015-02-11 11:15:24 -0800935 return false;
936}
937
938void TCompiler::internalTagUsedFunction(size_t index)
939{
940 if (functionMetadata[index].used)
941 {
942 return;
943 }
944
945 functionMetadata[index].used = true;
946
947 for (int calleeIndex : mCallDag.getRecordFromIndex(index).callees)
948 {
949 internalTagUsedFunction(calleeIndex);
zmo@google.comb1762df2011-07-30 02:04:23 +0000950 }
951}
952
Corentin Walleza094a8a2015-04-07 11:53:06 -0700953// A predicate for the stl that returns if a top-level node is unused
954class TCompiler::UnusedPredicate
955{
956 public:
957 UnusedPredicate(const CallDAG *callDag, const std::vector<FunctionMetadata> *metadatas)
Jamie Madillacb4b812016-11-07 13:50:29 -0500958 : mCallDag(callDag), mMetadatas(metadatas)
Corentin Walleza094a8a2015-04-07 11:53:06 -0700959 {
960 }
961
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500962 bool operator()(TIntermNode *node)
Corentin Walleza094a8a2015-04-07 11:53:06 -0700963 {
Olli Etuaho16c745a2017-01-16 17:02:27 +0000964 const TIntermFunctionPrototype *asFunctionPrototype = node->getAsFunctionPrototypeNode();
965 const TIntermFunctionDefinition *asFunctionDefinition = node->getAsFunctionDefinition();
Corentin Walleza094a8a2015-04-07 11:53:06 -0700966
Olli Etuaho336b1472016-10-05 16:37:55 +0100967 const TFunctionSymbolInfo *functionInfo = nullptr;
968
Olli Etuaho16c745a2017-01-16 17:02:27 +0000969 if (asFunctionDefinition)
Olli Etuaho336b1472016-10-05 16:37:55 +0100970 {
Olli Etuaho16c745a2017-01-16 17:02:27 +0000971 functionInfo = asFunctionDefinition->getFunctionSymbolInfo();
Olli Etuaho336b1472016-10-05 16:37:55 +0100972 }
Olli Etuaho16c745a2017-01-16 17:02:27 +0000973 else if (asFunctionPrototype)
Olli Etuaho336b1472016-10-05 16:37:55 +0100974 {
Olli Etuaho16c745a2017-01-16 17:02:27 +0000975 functionInfo = asFunctionPrototype->getFunctionSymbolInfo();
Olli Etuaho336b1472016-10-05 16:37:55 +0100976 }
977 if (functionInfo == nullptr)
Corentin Walleza094a8a2015-04-07 11:53:06 -0700978 {
979 return false;
980 }
981
Olli Etuaho336b1472016-10-05 16:37:55 +0100982 size_t callDagIndex = mCallDag->findIndex(functionInfo);
Corentin Walleza094a8a2015-04-07 11:53:06 -0700983 if (callDagIndex == CallDAG::InvalidIndex)
984 {
985 // This happens only for unimplemented prototypes which are thus unused
Olli Etuaho16c745a2017-01-16 17:02:27 +0000986 ASSERT(asFunctionPrototype);
Corentin Walleza094a8a2015-04-07 11:53:06 -0700987 return true;
988 }
989
990 ASSERT(callDagIndex < mMetadatas->size());
991 return !(*mMetadatas)[callDagIndex].used;
992 }
993
994 private:
995 const CallDAG *mCallDag;
996 const std::vector<FunctionMetadata> *mMetadatas;
997};
998
Olli Etuahod10cf692017-11-02 11:06:14 +0200999void TCompiler::pruneUnusedFunctions(TIntermBlock *root)
Corentin Walleza094a8a2015-04-07 11:53:06 -07001000{
Corentin Walleza094a8a2015-04-07 11:53:06 -07001001 UnusedPredicate isUnused(&mCallDag, &functionMetadata);
Olli Etuaho6d40bbd2016-09-30 13:49:38 +01001002 TIntermSequence *sequence = root->getSequence();
Corentin Wallezb081e782015-07-20 05:40:04 -07001003
1004 if (!sequence->empty())
1005 {
Jamie Madilld7b1ab52016-12-12 14:42:19 -05001006 sequence->erase(std::remove_if(sequence->begin(), sequence->end(), isUnused),
1007 sequence->end());
Corentin Wallezb081e782015-07-20 05:40:04 -07001008 }
Corentin Walleza094a8a2015-04-07 11:53:06 -07001009}
1010
Olli Etuahob4279202017-05-18 15:08:24 +03001011bool TCompiler::limitExpressionComplexity(TIntermBlock *root)
Jamie Madilleb1a0102013-07-08 13:31:38 -04001012{
Olli Etuahocccf2b02017-07-05 14:50:54 +03001013 if (!IsASTDepthBelowLimit(root, maxExpressionComplexity))
Jamie Madill6654bc92014-03-26 14:01:57 -04001014 {
Olli Etuaho77ba4082016-12-16 12:01:18 +00001015 mDiagnostics.globalError("Expression too complex.");
Jamie Madill6654bc92014-03-26 14:01:57 -04001016 return false;
1017 }
1018
Olli Etuahob4279202017-05-18 15:08:24 +03001019 if (!ValidateMaxParameters(root, maxFunctionParameters))
Olli Etuaho19d1dc92016-03-08 17:18:46 +02001020 {
Olli Etuaho77ba4082016-12-16 12:01:18 +00001021 mDiagnostics.globalError("Function has too many parameters.");
Olli Etuaho19d1dc92016-03-08 17:18:46 +02001022 return false;
1023 }
1024
Jamie Madilleb1a0102013-07-08 13:31:38 -04001025 return true;
1026}
1027
Corentin Wallez1df16022016-10-27 08:16:56 -04001028bool TCompiler::shouldCollectVariables(ShCompileOptions compileOptions)
1029{
1030 return (compileOptions & SH_VARIABLES) != 0;
1031}
1032
1033bool TCompiler::wereVariablesCollected() const
1034{
1035 return variablesCollected;
1036}
1037
Olli Etuaho9cbc07c2017-05-10 18:22:01 +03001038void TCompiler::initializeGLPosition(TIntermBlock *root)
Zhenyao Mo4a667fe2014-02-11 12:35:01 -08001039{
Zhenyao Mo72111912016-07-20 17:45:56 -07001040 InitVariableList list;
Olli Etuahoe7c28572017-10-23 16:29:33 +03001041 sh::ShaderVariable var(GL_FLOAT_VEC4);
Zhenyao Mo72111912016-07-20 17:45:56 -07001042 var.name = "gl_Position";
1043 list.push_back(var);
Olli Etuahodaaff1c2017-07-05 18:03:26 +03001044 InitializeVariables(root, list, symbolTable, shaderVersion, extensionBehavior);
Zhenyao Mo4a667fe2014-02-11 12:35:01 -08001045}
1046
Olli Etuaho9cbc07c2017-05-10 18:22:01 +03001047void TCompiler::useAllMembersInUnusedStandardAndSharedBlocks(TIntermBlock *root)
Qin Jiajia7835b522016-10-08 11:20:17 +08001048{
1049 sh::InterfaceBlockList list;
1050
Jiajia Qin9b11ea42017-07-11 16:50:08 +08001051 for (auto block : uniformBlocks)
Qin Jiajia7835b522016-10-08 11:20:17 +08001052 {
1053 if (!block.staticUse &&
Qin Jiajiaca68d982017-09-18 16:41:56 +08001054 (block.layout == sh::BLOCKLAYOUT_STD140 || block.layout == sh::BLOCKLAYOUT_SHARED))
Qin Jiajia7835b522016-10-08 11:20:17 +08001055 {
1056 list.push_back(block);
1057 }
1058 }
1059
Zhenyao Mod7490962016-11-09 15:49:51 -08001060 sh::UseInterfaceBlockFields(root, list, symbolTable);
Qin Jiajia7835b522016-10-08 11:20:17 +08001061}
1062
Olli Etuaho9cbc07c2017-05-10 18:22:01 +03001063void TCompiler::initializeOutputVariables(TIntermBlock *root)
Zhenyao Mo4a667fe2014-02-11 12:35:01 -08001064{
Zhenyao Mo72111912016-07-20 17:45:56 -07001065 InitVariableList list;
Jiawei Shaod27f5c82017-08-23 09:38:08 +08001066 if (shaderType == GL_VERTEX_SHADER || shaderType == GL_GEOMETRY_SHADER_OES)
Zhenyao Mo4a667fe2014-02-11 12:35:01 -08001067 {
Jiawei-Shaodf7d7c92017-07-31 09:34:04 +08001068 for (auto var : outputVaryings)
Zhenyao Mo4a667fe2014-02-11 12:35:01 -08001069 {
Zhenyao Mof9312682016-07-22 12:51:31 -07001070 list.push_back(var);
Olli Etuahob12040c2017-06-27 14:20:45 +03001071 if (var.name == "gl_Position")
1072 {
1073 ASSERT(!mGLPositionInitialized);
1074 mGLPositionInitialized = true;
1075 }
Zhenyao Mo4a667fe2014-02-11 12:35:01 -08001076 }
Zhenyao Mo4a667fe2014-02-11 12:35:01 -08001077 }
Zhenyao Mo72111912016-07-20 17:45:56 -07001078 else
1079 {
1080 ASSERT(shaderType == GL_FRAGMENT_SHADER);
1081 for (auto var : outputVariables)
1082 {
1083 list.push_back(var);
1084 }
1085 }
Olli Etuahodaaff1c2017-07-05 18:03:26 +03001086 InitializeVariables(root, list, symbolTable, shaderVersion, extensionBehavior);
Zhenyao Mo4a667fe2014-02-11 12:35:01 -08001087}
1088
Jamie Madilld7b1ab52016-12-12 14:42:19 -05001089const TExtensionBehavior &TCompiler::getExtensionBehavior() const
zmo@google.com5601ea02011-06-10 18:23:25 +00001090{
1091 return extensionBehavior;
1092}
zmo@google.com32e97312011-08-24 01:03:11 +00001093
Olli Etuahoa3a5cc62015-02-13 13:12:22 +02001094const char *TCompiler::getSourcePath() const
1095{
1096 return mSourcePath;
1097}
1098
Jamie Madilld7b1ab52016-12-12 14:42:19 -05001099const ShBuiltInResources &TCompiler::getResources() const
shannon.woods%transgaming.com@gtempaccount.com18b4c4b2013-04-13 03:31:40 +00001100{
1101 return compileResources;
1102}
1103
Jamie Madilld7b1ab52016-12-12 14:42:19 -05001104const ArrayBoundsClamper &TCompiler::getArrayBoundsClamper() const
daniel@transgaming.com4167cc92013-01-11 04:11:53 +00001105{
1106 return arrayBoundsClamper;
1107}
1108
shannon.woods@transgaming.com1d432bb2013-01-25 21:57:28 +00001109ShArrayIndexClampingStrategy TCompiler::getArrayIndexClampingStrategy() const
1110{
1111 return clampingStrategy;
1112}
1113
Jamie Madilld7b1ab52016-12-12 14:42:19 -05001114const BuiltInFunctionEmulator &TCompiler::getBuiltInFunctionEmulator() const
shannon.woods@transgaming.com1d432bb2013-01-25 21:57:28 +00001115{
1116 return builtInFunctionEmulator;
1117}
Zhenyao Mo94ac7b72014-10-15 18:22:08 -07001118
Qiankun Miao7ebb97f2016-09-08 18:01:50 +08001119void TCompiler::writePragma(ShCompileOptions compileOptions)
Zhenyao Mo94ac7b72014-10-15 18:22:08 -07001120{
Kenneth Russellbccc65d2016-07-19 16:48:43 -07001121 if (!(compileOptions & SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL))
1122 {
1123 TInfoSinkBase &sink = infoSink.obj;
1124 if (mPragma.stdgl.invariantAll)
1125 sink << "#pragma STDGL invariant(all)\n";
1126 }
1127}
1128
1129bool TCompiler::isVaryingDefined(const char *varyingName)
1130{
1131 ASSERT(variablesCollected);
Jiawei-Shaodf7d7c92017-07-31 09:34:04 +08001132 for (size_t ii = 0; ii < inputVaryings.size(); ++ii)
Kenneth Russellbccc65d2016-07-19 16:48:43 -07001133 {
Jiawei-Shaodf7d7c92017-07-31 09:34:04 +08001134 if (inputVaryings[ii].name == varyingName)
1135 {
1136 return true;
1137 }
1138 }
1139 for (size_t ii = 0; ii < outputVaryings.size(); ++ii)
1140 {
1141 if (outputVaryings[ii].name == varyingName)
Kenneth Russellbccc65d2016-07-19 16:48:43 -07001142 {
1143 return true;
1144 }
1145 }
1146
1147 return false;
Zhenyao Mo94ac7b72014-10-15 18:22:08 -07001148}
Jamie Madillacb4b812016-11-07 13:50:29 -05001149
1150} // namespace sh