alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 1 | // |
zmo@google.com | b9f64aa | 2012-01-20 00:35:15 +0000 | [diff] [blame] | 2 | // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
zmo@google.com | 32e9731 | 2011-08-24 01:03:11 +0000 | [diff] [blame] | 7 | #include "compiler/BuiltInFunctionEmulator.h" |
zmo@google.com | b1762df | 2011-07-30 02:04:23 +0000 | [diff] [blame] | 8 | #include "compiler/DetectRecursion.h" |
zmo@google.com | 0c6bb7a | 2011-08-17 19:39:58 +0000 | [diff] [blame] | 9 | #include "compiler/ForLoopUnroll.h" |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 10 | #include "compiler/Initialize.h" |
zmo@google.com | b9f64aa | 2012-01-20 00:35:15 +0000 | [diff] [blame] | 11 | #include "compiler/MapLongVariableNames.h" |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 12 | #include "compiler/ParseHelper.h" |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 13 | #include "compiler/RenameFunction.h" |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 14 | #include "compiler/ShHandle.h" |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 15 | #include "compiler/ValidateLimitations.h" |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 16 | #include "compiler/depgraph/DependencyGraph.h" |
| 17 | #include "compiler/depgraph/DependencyGraphOutput.h" |
| 18 | #include "compiler/timing/RestrictFragmentShaderTiming.h" |
| 19 | #include "compiler/timing/RestrictVertexShaderTiming.h" |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 20 | |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 21 | bool isWebGLBasedSpec(ShShaderSpec spec) |
| 22 | { |
| 23 | return spec == SH_WEBGL_SPEC || spec == SH_CSS_SHADERS_SPEC; |
| 24 | } |
| 25 | |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 26 | namespace { |
| 27 | bool InitializeSymbolTable( |
| 28 | const TBuiltInStrings& builtInStrings, |
| 29 | ShShaderType type, ShShaderSpec spec, const ShBuiltInResources& resources, |
| 30 | TInfoSink& infoSink, TSymbolTable& symbolTable) |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 31 | { |
| 32 | TIntermediate intermediate(infoSink); |
| 33 | TExtensionBehavior extBehavior; |
zmo@google.com | 09c323a | 2011-08-12 18:22:25 +0000 | [diff] [blame] | 34 | InitExtensionBehavior(resources, extBehavior); |
zmo@google.com | dc4b4f8 | 2011-06-17 00:42:53 +0000 | [diff] [blame] | 35 | // The builtins deliberately don't specify precisions for the function |
| 36 | // arguments and return types. For that reason we don't try to check them. |
| 37 | TParseContext parseContext(symbolTable, extBehavior, intermediate, type, spec, 0, false, NULL, infoSink); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 38 | |
| 39 | GlobalParseContext = &parseContext; |
| 40 | |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 41 | assert(symbolTable.isEmpty()); |
| 42 | // |
| 43 | // Parse the built-ins. This should only happen once per |
| 44 | // language symbol table. |
| 45 | // |
| 46 | // Push the symbol table to give it an initial scope. This |
| 47 | // push should not have a corresponding pop, so that built-ins |
| 48 | // are preserved, and the test for an empty table fails. |
| 49 | // |
| 50 | symbolTable.push(); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 51 | |
| 52 | for (TBuiltInStrings::const_iterator i = builtInStrings.begin(); i != builtInStrings.end(); ++i) |
| 53 | { |
alokp@chromium.org | 570bfc7 | 2010-09-24 17:19:25 +0000 | [diff] [blame] | 54 | const char* builtInShaders = i->c_str(); |
| 55 | int builtInLengths = static_cast<int>(i->size()); |
| 56 | if (builtInLengths <= 0) |
| 57 | continue; |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 58 | |
alokp@chromium.org | 044a5cf | 2010-11-12 15:42:16 +0000 | [diff] [blame] | 59 | if (PaParseStrings(1, &builtInShaders, &builtInLengths, &parseContext) != 0) |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 60 | { |
| 61 | infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins"); |
| 62 | return false; |
| 63 | } |
| 64 | } |
| 65 | |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 66 | IdentifyBuiltIns(type, spec, resources, symbolTable); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 67 | |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 68 | return true; |
| 69 | } |
| 70 | |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 71 | class TScopedPoolAllocator { |
| 72 | public: |
| 73 | TScopedPoolAllocator(TPoolAllocator* allocator, bool pushPop) |
| 74 | : mAllocator(allocator), mPushPopAllocator(pushPop) { |
| 75 | if (mPushPopAllocator) mAllocator->push(); |
| 76 | SetGlobalPoolAllocator(mAllocator); |
| 77 | } |
| 78 | ~TScopedPoolAllocator() { |
| 79 | SetGlobalPoolAllocator(NULL); |
| 80 | if (mPushPopAllocator) mAllocator->pop(); |
| 81 | } |
| 82 | |
| 83 | private: |
| 84 | TPoolAllocator* mAllocator; |
| 85 | bool mPushPopAllocator; |
| 86 | }; |
| 87 | } // namespace |
| 88 | |
| 89 | TShHandleBase::TShHandleBase() { |
| 90 | allocator.push(); |
| 91 | SetGlobalPoolAllocator(&allocator); |
| 92 | } |
| 93 | |
| 94 | TShHandleBase::~TShHandleBase() { |
| 95 | SetGlobalPoolAllocator(NULL); |
| 96 | allocator.popAll(); |
| 97 | } |
| 98 | |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 99 | TCompiler::TCompiler(ShShaderType type, ShShaderSpec spec) |
| 100 | : shaderType(type), |
zmo@google.com | f420c42 | 2011-09-12 18:27:59 +0000 | [diff] [blame] | 101 | shaderSpec(spec), |
zmo@google.com | 9996b8e | 2012-01-19 01:43:55 +0000 | [diff] [blame] | 102 | builtInFunctionEmulator(type) |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 103 | { |
zmo@google.com | b9f64aa | 2012-01-20 00:35:15 +0000 | [diff] [blame] | 104 | longNameMap = LongNameMap::GetInstance(); |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | TCompiler::~TCompiler() |
| 108 | { |
zmo@google.com | b9f64aa | 2012-01-20 00:35:15 +0000 | [diff] [blame] | 109 | ASSERT(longNameMap); |
| 110 | longNameMap->Release(); |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | bool TCompiler::Init(const ShBuiltInResources& resources) |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 114 | { |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 115 | TScopedPoolAllocator scopedAlloc(&allocator, false); |
| 116 | |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 117 | // Generate built-in symbol table. |
| 118 | if (!InitBuiltInSymbolTable(resources)) |
| 119 | return false; |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 120 | InitExtensionBehavior(resources, extensionBehavior); |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 121 | |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 122 | return true; |
| 123 | } |
| 124 | |
| 125 | bool TCompiler::compile(const char* const shaderStrings[], |
| 126 | const int numStrings, |
| 127 | int compileOptions) |
| 128 | { |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 129 | TScopedPoolAllocator scopedAlloc(&allocator, true); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 130 | clearResults(); |
| 131 | |
| 132 | if (numStrings == 0) |
| 133 | return true; |
| 134 | |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 135 | // If compiling for WebGL, validate loop and indexing as well. |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 136 | if (isWebGLBasedSpec(shaderSpec)) |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 137 | compileOptions |= SH_VALIDATE_LOOP_INDEXING; |
alokp@chromium.org | 1f29954 | 2010-11-12 15:50:23 +0000 | [diff] [blame] | 138 | |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 139 | // First string is path of source file if flag is set. The actual source follows. |
| 140 | const char* sourcePath = NULL; |
| 141 | int firstSource = 0; |
| 142 | if (compileOptions & SH_SOURCE_PATH) |
| 143 | { |
| 144 | sourcePath = shaderStrings[0]; |
| 145 | ++firstSource; |
| 146 | } |
| 147 | |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 148 | TIntermediate intermediate(infoSink); |
| 149 | TParseContext parseContext(symbolTable, extensionBehavior, intermediate, |
zmo@google.com | dc4b4f8 | 2011-06-17 00:42:53 +0000 | [diff] [blame] | 150 | shaderType, shaderSpec, compileOptions, true, |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 151 | sourcePath, infoSink); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 152 | GlobalParseContext = &parseContext; |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 153 | |
| 154 | // We preserve symbols at the built-in level from compile-to-compile. |
| 155 | // Start pushing the user-defined symbols at global level. |
| 156 | symbolTable.push(); |
| 157 | if (!symbolTable.atGlobalLevel()) |
| 158 | infoSink.info.message(EPrefixInternalError, "Wrong symbol table level"); |
| 159 | |
| 160 | // Parse shader. |
| 161 | bool success = |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 162 | (PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], NULL, &parseContext) == 0) && |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 163 | (parseContext.treeRoot != NULL); |
| 164 | if (success) { |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 165 | TIntermNode* root = parseContext.treeRoot; |
| 166 | success = intermediate.postProcess(root); |
| 167 | |
zmo@google.com | b1762df | 2011-07-30 02:04:23 +0000 | [diff] [blame] | 168 | if (success) |
| 169 | success = detectRecursion(root); |
| 170 | |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 171 | if (success && (compileOptions & SH_VALIDATE_LOOP_INDEXING)) |
| 172 | success = validateLimitations(root); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 173 | |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 174 | if (success && (compileOptions & SH_TIMING_RESTRICTIONS)) |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 175 | success = enforceTimingRestrictions(root, (compileOptions & SH_DEPENDENCY_GRAPH) != 0); |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 176 | |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 177 | if (success && shaderSpec == SH_CSS_SHADERS_SPEC) |
| 178 | rewriteCSSShader(root); |
| 179 | |
zmo@google.com | 0c6bb7a | 2011-08-17 19:39:58 +0000 | [diff] [blame] | 180 | // Unroll for-loop markup needs to happen after validateLimitations pass. |
| 181 | if (success && (compileOptions & SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX)) |
| 182 | ForLoopUnroll::MarkForLoopsWithIntegerIndicesForUnrolling(root); |
| 183 | |
zmo@google.com | 32e9731 | 2011-08-24 01:03:11 +0000 | [diff] [blame] | 184 | // Built-in function emulation needs to happen after validateLimitations pass. |
| 185 | if (success && (compileOptions & SH_EMULATE_BUILT_IN_FUNCTIONS)) |
| 186 | builtInFunctionEmulator.MarkBuiltInFunctionsForEmulation(root); |
| 187 | |
zmo@google.com | fd747b8 | 2011-04-23 01:30:07 +0000 | [diff] [blame] | 188 | // Call mapLongVariableNames() before collectAttribsUniforms() so in |
| 189 | // collectAttribsUniforms() we already have the mapped symbol names and |
| 190 | // we could composite mapped and original variable names. |
zmo@google.com | b1762df | 2011-07-30 02:04:23 +0000 | [diff] [blame] | 191 | if (success && (compileOptions & SH_MAP_LONG_VARIABLE_NAMES)) |
zmo@google.com | fd747b8 | 2011-04-23 01:30:07 +0000 | [diff] [blame] | 192 | mapLongVariableNames(root); |
| 193 | |
| 194 | if (success && (compileOptions & SH_ATTRIBUTES_UNIFORMS)) |
| 195 | collectAttribsUniforms(root); |
| 196 | |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 197 | if (success && (compileOptions & SH_INTERMEDIATE_TREE)) |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 198 | intermediate.outputTree(root); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 199 | |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 200 | if (success && (compileOptions & SH_OBJECT_CODE)) |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 201 | translate(root); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | // Cleanup memory. |
| 205 | intermediate.remove(parseContext.treeRoot); |
| 206 | // Ensure symbol table is returned to the built-in level, |
| 207 | // throwing away all but the built-ins. |
| 208 | while (!symbolTable.atBuiltInLevel()) |
| 209 | symbolTable.pop(); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 210 | |
| 211 | return success; |
| 212 | } |
| 213 | |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 214 | bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources& resources) |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 215 | { |
| 216 | TBuiltIns builtIns; |
| 217 | |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 218 | builtIns.initialize(shaderType, shaderSpec, resources); |
| 219 | return InitializeSymbolTable(builtIns.getBuiltInStrings(), |
| 220 | shaderType, shaderSpec, resources, infoSink, symbolTable); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | void TCompiler::clearResults() |
| 224 | { |
| 225 | infoSink.info.erase(); |
| 226 | infoSink.obj.erase(); |
| 227 | infoSink.debug.erase(); |
| 228 | |
| 229 | attribs.clear(); |
| 230 | uniforms.clear(); |
zmo@google.com | a3b4ab4 | 2011-09-16 00:53:26 +0000 | [diff] [blame] | 231 | |
| 232 | builtInFunctionEmulator.Cleanup(); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 233 | } |
| 234 | |
zmo@google.com | b1762df | 2011-07-30 02:04:23 +0000 | [diff] [blame] | 235 | bool TCompiler::detectRecursion(TIntermNode* root) |
| 236 | { |
| 237 | DetectRecursion detect; |
| 238 | root->traverse(&detect); |
| 239 | switch (detect.detectRecursion()) { |
| 240 | case DetectRecursion::kErrorNone: |
| 241 | return true; |
| 242 | case DetectRecursion::kErrorMissingMain: |
| 243 | infoSink.info.message(EPrefixError, "Missing main()"); |
| 244 | return false; |
| 245 | case DetectRecursion::kErrorRecursion: |
| 246 | infoSink.info.message(EPrefixError, "Function recursion detected"); |
| 247 | return false; |
| 248 | default: |
| 249 | UNREACHABLE(); |
| 250 | return false; |
| 251 | } |
| 252 | } |
| 253 | |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 254 | void TCompiler::rewriteCSSShader(TIntermNode* root) |
| 255 | { |
| 256 | RenameFunction renamer("main(", "css_main("); |
| 257 | root->traverse(&renamer); |
| 258 | } |
| 259 | |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 260 | bool TCompiler::validateLimitations(TIntermNode* root) { |
| 261 | ValidateLimitations validate(shaderType, infoSink.info); |
| 262 | root->traverse(&validate); |
| 263 | return validate.numErrors() == 0; |
| 264 | } |
| 265 | |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 266 | bool TCompiler::enforceTimingRestrictions(TIntermNode* root, bool outputGraph) |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 267 | { |
| 268 | if (shaderSpec != SH_WEBGL_SPEC) { |
| 269 | infoSink.info << "Timing restrictions must be enforced under the WebGL spec."; |
| 270 | return false; |
| 271 | } |
| 272 | |
| 273 | if (shaderType == SH_FRAGMENT_SHADER) { |
| 274 | TDependencyGraph graph(root); |
| 275 | |
| 276 | // Output any errors first. |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 277 | bool success = enforceFragmentShaderTimingRestrictions(graph); |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 278 | |
| 279 | // Then, output the dependency graph. |
| 280 | if (outputGraph) { |
| 281 | TDependencyGraphOutput output(infoSink.info); |
| 282 | output.outputAllSpanningTrees(graph); |
| 283 | } |
| 284 | |
| 285 | return success; |
| 286 | } |
| 287 | else { |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 288 | return enforceVertexShaderTimingRestrictions(root); |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 289 | } |
| 290 | } |
| 291 | |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 292 | bool TCompiler::enforceFragmentShaderTimingRestrictions(const TDependencyGraph& graph) |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 293 | { |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 294 | RestrictFragmentShaderTiming restrictor(infoSink.info); |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 295 | restrictor.enforceRestrictions(graph); |
| 296 | return restrictor.numErrors() == 0; |
| 297 | } |
| 298 | |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 299 | bool TCompiler::enforceVertexShaderTimingRestrictions(TIntermNode* root) |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 300 | { |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 301 | RestrictVertexShaderTiming restrictor(infoSink.info); |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 302 | restrictor.enforceRestrictions(root); |
| 303 | return restrictor.numErrors() == 0; |
| 304 | } |
| 305 | |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 306 | void TCompiler::collectAttribsUniforms(TIntermNode* root) |
| 307 | { |
| 308 | CollectAttribsUniforms collect(attribs, uniforms); |
| 309 | root->traverse(&collect); |
| 310 | } |
zmo@google.com | fd747b8 | 2011-04-23 01:30:07 +0000 | [diff] [blame] | 311 | |
| 312 | void TCompiler::mapLongVariableNames(TIntermNode* root) |
| 313 | { |
zmo@google.com | b9f64aa | 2012-01-20 00:35:15 +0000 | [diff] [blame] | 314 | ASSERT(longNameMap); |
| 315 | MapLongVariableNames map(longNameMap); |
zmo@google.com | 9996b8e | 2012-01-19 01:43:55 +0000 | [diff] [blame] | 316 | root->traverse(&map); |
zmo@google.com | fd747b8 | 2011-04-23 01:30:07 +0000 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | int TCompiler::getMappedNameMaxLength() const |
| 320 | { |
kbr@chromium.org | 2215211 | 2011-10-26 01:18:28 +0000 | [diff] [blame] | 321 | return MAX_SHORTENED_IDENTIFIER_SIZE + 1; |
zmo@google.com | fd747b8 | 2011-04-23 01:30:07 +0000 | [diff] [blame] | 322 | } |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 323 | |
| 324 | const TExtensionBehavior& TCompiler::getExtensionBehavior() const |
| 325 | { |
| 326 | return extensionBehavior; |
| 327 | } |
zmo@google.com | 32e9731 | 2011-08-24 01:03:11 +0000 | [diff] [blame] | 328 | |
| 329 | const BuiltInFunctionEmulator& TCompiler::getBuiltInFunctionEmulator() const |
| 330 | { |
| 331 | return builtInFunctionEmulator; |
| 332 | } |