alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 1 | // |
Jamie Madill | 88f6e94 | 2014-02-19 10:27:53 -0500 | [diff] [blame] | 2 | // Copyright (c) 2002-2014 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 | |
Geoff Lang | 1773282 | 2013-08-29 13:46:49 -0400 | [diff] [blame] | 7 | #include "compiler/translator/BuiltInFunctionEmulator.h" |
Jamie Madill | d4a3a31 | 2014-06-25 16:04:56 -0400 | [diff] [blame] | 8 | #include "compiler/translator/Compiler.h" |
Geoff Lang | 1773282 | 2013-08-29 13:46:49 -0400 | [diff] [blame] | 9 | #include "compiler/translator/DetectCallDepth.h" |
| 10 | #include "compiler/translator/ForLoopUnroll.h" |
| 11 | #include "compiler/translator/Initialize.h" |
Geoff Lang | 1773282 | 2013-08-29 13:46:49 -0400 | [diff] [blame] | 12 | #include "compiler/translator/InitializeParseContext.h" |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 13 | #include "compiler/translator/InitializeVariables.h" |
Jamie Madill | 6b9cb25 | 2013-10-17 10:45:47 -0400 | [diff] [blame] | 14 | #include "compiler/translator/ParseContext.h" |
Geoff Lang | 1773282 | 2013-08-29 13:46:49 -0400 | [diff] [blame] | 15 | #include "compiler/translator/RenameFunction.h" |
Zhenyao Mo | 7cab38b | 2013-10-15 12:59:30 -0700 | [diff] [blame] | 16 | #include "compiler/translator/UnfoldShortCircuitAST.h" |
Geoff Lang | 1773282 | 2013-08-29 13:46:49 -0400 | [diff] [blame] | 17 | #include "compiler/translator/ValidateLimitations.h" |
| 18 | #include "compiler/translator/ValidateOutputs.h" |
| 19 | #include "compiler/translator/VariablePacker.h" |
| 20 | #include "compiler/translator/depgraph/DependencyGraph.h" |
| 21 | #include "compiler/translator/depgraph/DependencyGraphOutput.h" |
| 22 | #include "compiler/translator/timing/RestrictFragmentShaderTiming.h" |
| 23 | #include "compiler/translator/timing/RestrictVertexShaderTiming.h" |
shannon.woods@transgaming.com | da1ed36 | 2013-01-25 21:54:57 +0000 | [diff] [blame] | 24 | #include "third_party/compiler/ArrayBoundsClamper.h" |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 25 | #include "angle_gl.h" |
Jamie Madill | aa72d78 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 26 | #include "common/utilities.h" |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 27 | |
Jamie Madill | 5508f39 | 2014-02-20 13:31:36 -0500 | [diff] [blame] | 28 | bool IsWebGLBasedSpec(ShShaderSpec spec) |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 29 | { |
| 30 | return spec == SH_WEBGL_SPEC || spec == SH_CSS_SHADERS_SPEC; |
| 31 | } |
| 32 | |
Zhenyao Mo | 7faf1a1 | 2014-04-25 18:03:56 -0700 | [diff] [blame] | 33 | size_t GetGlobalMaxTokenSize(ShShaderSpec spec) |
Jamie Madill | 88f6e94 | 2014-02-19 10:27:53 -0500 | [diff] [blame] | 34 | { |
Jamie Madill | 88f6e94 | 2014-02-19 10:27:53 -0500 | [diff] [blame] | 35 | // WebGL defines a max token legnth of 256, while ES2 leaves max token |
| 36 | // size undefined. ES3 defines a max size of 1024 characters. |
Zhenyao Mo | 7faf1a1 | 2014-04-25 18:03:56 -0700 | [diff] [blame] | 37 | if (IsWebGLBasedSpec(spec)) |
Jamie Madill | 88f6e94 | 2014-02-19 10:27:53 -0500 | [diff] [blame] | 38 | { |
| 39 | return 256; |
| 40 | } |
| 41 | else |
| 42 | { |
| 43 | return 1024; |
| 44 | } |
| 45 | } |
| 46 | |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 47 | namespace { |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 48 | class TScopedPoolAllocator |
| 49 | { |
| 50 | public: |
| 51 | TScopedPoolAllocator(TPoolAllocator* allocator) : mAllocator(allocator) |
| 52 | { |
Alok Priyadarshi | bc3f1ac | 2013-09-23 14:57:02 -0400 | [diff] [blame] | 53 | mAllocator->push(); |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 54 | SetGlobalPoolAllocator(mAllocator); |
| 55 | } |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 56 | ~TScopedPoolAllocator() |
| 57 | { |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 58 | SetGlobalPoolAllocator(NULL); |
Alok Priyadarshi | bc3f1ac | 2013-09-23 14:57:02 -0400 | [diff] [blame] | 59 | mAllocator->pop(); |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 62 | private: |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 63 | TPoolAllocator* mAllocator; |
Alok Priyadarshi | bc3f1ac | 2013-09-23 14:57:02 -0400 | [diff] [blame] | 64 | }; |
| 65 | |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 66 | class TScopedSymbolTableLevel |
| 67 | { |
| 68 | public: |
| 69 | TScopedSymbolTableLevel(TSymbolTable* table) : mTable(table) |
| 70 | { |
Alok Priyadarshi | bc3f1ac | 2013-09-23 14:57:02 -0400 | [diff] [blame] | 71 | ASSERT(mTable->atBuiltInLevel()); |
| 72 | mTable->push(); |
| 73 | } |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 74 | ~TScopedSymbolTableLevel() |
| 75 | { |
Alok Priyadarshi | bc3f1ac | 2013-09-23 14:57:02 -0400 | [diff] [blame] | 76 | while (!mTable->atBuiltInLevel()) |
| 77 | mTable->pop(); |
| 78 | } |
| 79 | |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 80 | private: |
Alok Priyadarshi | bc3f1ac | 2013-09-23 14:57:02 -0400 | [diff] [blame] | 81 | TSymbolTable* mTable; |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 82 | }; |
| 83 | } // namespace |
| 84 | |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 85 | TShHandleBase::TShHandleBase() |
| 86 | { |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 87 | allocator.push(); |
| 88 | SetGlobalPoolAllocator(&allocator); |
| 89 | } |
| 90 | |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 91 | TShHandleBase::~TShHandleBase() |
| 92 | { |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 93 | SetGlobalPoolAllocator(NULL); |
| 94 | allocator.popAll(); |
| 95 | } |
| 96 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 97 | TCompiler::TCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output) |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 98 | : shaderType(type), |
zmo@google.com | f420c42 | 2011-09-12 18:27:59 +0000 | [diff] [blame] | 99 | shaderSpec(spec), |
Jamie Madill | 68fe74a | 2014-05-27 12:56:01 -0400 | [diff] [blame] | 100 | outputType(output), |
Jamie Madill | eb1a010 | 2013-07-08 13:31:38 -0400 | [diff] [blame] | 101 | maxUniformVectors(0), |
| 102 | maxExpressionComplexity(0), |
| 103 | maxCallStackDepth(0), |
shannon.woods%transgaming.com@gtempaccount.com | cbb6b6a | 2013-04-13 03:27:47 +0000 | [diff] [blame] | 104 | fragmentPrecisionHigh(false), |
shannon.woods@transgaming.com | 1d432bb | 2013-01-25 21:57:28 +0000 | [diff] [blame] | 105 | clampingStrategy(SH_CLAMP_WITH_CLAMP_INTRINSIC), |
zmo@google.com | 9996b8e | 2012-01-19 01:43:55 +0000 | [diff] [blame] | 106 | builtInFunctionEmulator(type) |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 107 | { |
| 108 | } |
| 109 | |
| 110 | TCompiler::~TCompiler() |
| 111 | { |
| 112 | } |
| 113 | |
| 114 | bool TCompiler::Init(const ShBuiltInResources& resources) |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 115 | { |
shannon.woods%transgaming.com@gtempaccount.com | 0bbed38 | 2013-04-13 03:38:07 +0000 | [diff] [blame] | 116 | shaderVersion = 100; |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 117 | maxUniformVectors = (shaderType == GL_VERTEX_SHADER) ? |
gman@chromium.org | 8d80479 | 2012-10-17 21:33:48 +0000 | [diff] [blame] | 118 | resources.MaxVertexUniformVectors : |
| 119 | resources.MaxFragmentUniformVectors; |
Jamie Madill | eb1a010 | 2013-07-08 13:31:38 -0400 | [diff] [blame] | 120 | maxExpressionComplexity = resources.MaxExpressionComplexity; |
| 121 | maxCallStackDepth = resources.MaxCallStackDepth; |
Alok Priyadarshi | bc3f1ac | 2013-09-23 14:57:02 -0400 | [diff] [blame] | 122 | |
| 123 | SetGlobalPoolAllocator(&allocator); |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 124 | |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 125 | // Generate built-in symbol table. |
| 126 | if (!InitBuiltInSymbolTable(resources)) |
| 127 | return false; |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 128 | InitExtensionBehavior(resources, extensionBehavior); |
shannon.woods%transgaming.com@gtempaccount.com | cbb6b6a | 2013-04-13 03:27:47 +0000 | [diff] [blame] | 129 | fragmentPrecisionHigh = resources.FragmentPrecisionHigh == 1; |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 130 | |
shannon.woods@transgaming.com | 1d432bb | 2013-01-25 21:57:28 +0000 | [diff] [blame] | 131 | arrayBoundsClamper.SetClampingStrategy(resources.ArrayIndexClampingStrategy); |
| 132 | clampingStrategy = resources.ArrayIndexClampingStrategy; |
| 133 | |
daniel@transgaming.com | c23f461 | 2012-11-28 19:42:57 +0000 | [diff] [blame] | 134 | hashFunction = resources.HashFunction; |
| 135 | |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 136 | return true; |
| 137 | } |
| 138 | |
| 139 | bool TCompiler::compile(const char* const shaderStrings[], |
shannon.woods@transgaming.com | d64b3da | 2013-02-28 23:19:26 +0000 | [diff] [blame] | 140 | size_t numStrings, |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 141 | int compileOptions) |
| 142 | { |
Alok Priyadarshi | bc3f1ac | 2013-09-23 14:57:02 -0400 | [diff] [blame] | 143 | TScopedPoolAllocator scopedAlloc(&allocator); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 144 | clearResults(); |
| 145 | |
| 146 | if (numStrings == 0) |
| 147 | return true; |
| 148 | |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 149 | // If compiling for WebGL, validate loop and indexing as well. |
Jamie Madill | 5508f39 | 2014-02-20 13:31:36 -0500 | [diff] [blame] | 150 | if (IsWebGLBasedSpec(shaderSpec)) |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 151 | compileOptions |= SH_VALIDATE_LOOP_INDEXING; |
alokp@chromium.org | 1f29954 | 2010-11-12 15:50:23 +0000 | [diff] [blame] | 152 | |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 153 | // First string is path of source file if flag is set. The actual source follows. |
| 154 | const char* sourcePath = NULL; |
shannon.woods@transgaming.com | d64b3da | 2013-02-28 23:19:26 +0000 | [diff] [blame] | 155 | size_t firstSource = 0; |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 156 | if (compileOptions & SH_SOURCE_PATH) |
| 157 | { |
| 158 | sourcePath = shaderStrings[0]; |
| 159 | ++firstSource; |
| 160 | } |
| 161 | |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 162 | TIntermediate intermediate(infoSink); |
| 163 | TParseContext parseContext(symbolTable, extensionBehavior, intermediate, |
zmo@google.com | dc4b4f8 | 2011-06-17 00:42:53 +0000 | [diff] [blame] | 164 | shaderType, shaderSpec, compileOptions, true, |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 165 | sourcePath, infoSink); |
shannon.woods%transgaming.com@gtempaccount.com | cbb6b6a | 2013-04-13 03:27:47 +0000 | [diff] [blame] | 166 | parseContext.fragmentPrecisionHigh = fragmentPrecisionHigh; |
Alok Priyadarshi | 8156b6b | 2013-09-23 14:56:58 -0400 | [diff] [blame] | 167 | SetGlobalParseContext(&parseContext); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 168 | |
| 169 | // We preserve symbols at the built-in level from compile-to-compile. |
| 170 | // Start pushing the user-defined symbols at global level. |
Alok Priyadarshi | bc3f1ac | 2013-09-23 14:57:02 -0400 | [diff] [blame] | 171 | TScopedSymbolTableLevel scopedSymbolLevel(&symbolTable); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 172 | |
| 173 | // Parse shader. |
| 174 | bool success = |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 175 | (PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], NULL, &parseContext) == 0) && |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 176 | (parseContext.treeRoot != NULL); |
shannon.woods%transgaming.com@gtempaccount.com | 0bbed38 | 2013-04-13 03:38:07 +0000 | [diff] [blame] | 177 | |
shannon.woods%transgaming.com@gtempaccount.com | 5524db0 | 2013-04-13 03:38:16 +0000 | [diff] [blame] | 178 | shaderVersion = parseContext.getShaderVersion(); |
shannon.woods%transgaming.com@gtempaccount.com | 0bbed38 | 2013-04-13 03:38:07 +0000 | [diff] [blame] | 179 | |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 180 | if (success) |
| 181 | { |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 182 | TIntermNode* root = parseContext.treeRoot; |
| 183 | success = intermediate.postProcess(root); |
| 184 | |
Jamie Madill | 6654bc9 | 2014-03-26 14:01:57 -0400 | [diff] [blame] | 185 | // Disallow expressions deemed too complex. |
| 186 | if (success && (compileOptions & SH_LIMIT_EXPRESSION_COMPLEXITY)) |
| 187 | success = limitExpressionComplexity(root); |
| 188 | |
zmo@google.com | b1762df | 2011-07-30 02:04:23 +0000 | [diff] [blame] | 189 | if (success) |
Jamie Madill | eb1a010 | 2013-07-08 13:31:38 -0400 | [diff] [blame] | 190 | success = detectCallDepth(root, infoSink, (compileOptions & SH_LIMIT_CALL_STACK_DEPTH) != 0); |
zmo@google.com | b1762df | 2011-07-30 02:04:23 +0000 | [diff] [blame] | 191 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 192 | if (success && shaderVersion == 300 && shaderType == GL_FRAGMENT_SHADER) |
Jamie Madill | 05a80ce | 2013-06-20 11:55:49 -0400 | [diff] [blame] | 193 | success = validateOutputs(root); |
| 194 | |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 195 | if (success && (compileOptions & SH_VALIDATE_LOOP_INDEXING)) |
| 196 | success = validateLimitations(root); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 197 | |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 198 | if (success && (compileOptions & SH_TIMING_RESTRICTIONS)) |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 199 | success = enforceTimingRestrictions(root, (compileOptions & SH_DEPENDENCY_GRAPH) != 0); |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 200 | |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 201 | if (success && shaderSpec == SH_CSS_SHADERS_SPEC) |
| 202 | rewriteCSSShader(root); |
| 203 | |
zmo@google.com | 0c6bb7a | 2011-08-17 19:39:58 +0000 | [diff] [blame] | 204 | // Unroll for-loop markup needs to happen after validateLimitations pass. |
| 205 | if (success && (compileOptions & SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX)) |
Zhenyao Mo | 3cdfcce | 2014-03-07 13:00:08 -0800 | [diff] [blame] | 206 | { |
| 207 | ForLoopUnrollMarker marker(ForLoopUnrollMarker::kIntegerIndex); |
Zhenyao Mo | 550c600 | 2014-02-26 15:40:48 -0800 | [diff] [blame] | 208 | root->traverse(&marker); |
| 209 | } |
| 210 | if (success && (compileOptions & SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX)) |
Zhenyao Mo | 3cdfcce | 2014-03-07 13:00:08 -0800 | [diff] [blame] | 211 | { |
| 212 | ForLoopUnrollMarker marker(ForLoopUnrollMarker::kSamplerArrayIndex); |
Zhenyao Mo | 550c600 | 2014-02-26 15:40:48 -0800 | [diff] [blame] | 213 | root->traverse(&marker); |
| 214 | if (marker.samplerArrayIndexIsFloatLoopIndex()) |
| 215 | { |
| 216 | infoSink.info.prefix(EPrefixError); |
| 217 | infoSink.info << "sampler array index is float loop index"; |
| 218 | success = false; |
| 219 | } |
| 220 | } |
zmo@google.com | 0c6bb7a | 2011-08-17 19:39:58 +0000 | [diff] [blame] | 221 | |
zmo@google.com | 32e9731 | 2011-08-24 01:03:11 +0000 | [diff] [blame] | 222 | // Built-in function emulation needs to happen after validateLimitations pass. |
| 223 | if (success && (compileOptions & SH_EMULATE_BUILT_IN_FUNCTIONS)) |
| 224 | builtInFunctionEmulator.MarkBuiltInFunctionsForEmulation(root); |
| 225 | |
daniel@transgaming.com | 4167cc9 | 2013-01-11 04:11:53 +0000 | [diff] [blame] | 226 | // Clamping uniform array bounds needs to happen after validateLimitations pass. |
| 227 | if (success && (compileOptions & SH_CLAMP_INDIRECT_ARRAY_BOUNDS)) |
| 228 | arrayBoundsClamper.MarkIndirectArrayBoundsForClamping(root); |
| 229 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 230 | if (success && shaderType == GL_VERTEX_SHADER && (compileOptions & SH_INIT_GL_POSITION)) |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 231 | initializeGLPosition(root); |
Zhenyao Mo | ac44cd2 | 2013-09-23 14:57:09 -0400 | [diff] [blame] | 232 | |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 233 | if (success && (compileOptions & SH_UNFOLD_SHORT_CIRCUIT)) |
| 234 | { |
Zhenyao Mo | 7cab38b | 2013-10-15 12:59:30 -0700 | [diff] [blame] | 235 | UnfoldShortCircuitAST unfoldShortCircuit; |
| 236 | root->traverse(&unfoldShortCircuit); |
| 237 | unfoldShortCircuit.updateTree(); |
| 238 | } |
| 239 | |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 240 | if (success && (compileOptions & SH_VARIABLES)) |
| 241 | { |
Zhenyao Mo | 74da9f2 | 2013-09-23 14:57:01 -0400 | [diff] [blame] | 242 | collectVariables(root); |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 243 | if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS) |
| 244 | { |
gman@chromium.org | 8d80479 | 2012-10-17 21:33:48 +0000 | [diff] [blame] | 245 | success = enforcePackingRestrictions(); |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 246 | if (!success) |
| 247 | { |
Jamie Madill | 075edd8 | 2013-07-08 13:30:19 -0400 | [diff] [blame] | 248 | infoSink.info.prefix(EPrefixError); |
| 249 | infoSink.info << "too many uniforms"; |
gman@chromium.org | 8d80479 | 2012-10-17 21:33:48 +0000 | [diff] [blame] | 250 | } |
| 251 | } |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 252 | if (success && shaderType == GL_VERTEX_SHADER && |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 253 | (compileOptions & SH_INIT_VARYINGS_WITHOUT_STATIC_USE)) |
| 254 | initializeVaryingsWithoutStaticUse(root); |
gman@chromium.org | 8d80479 | 2012-10-17 21:33:48 +0000 | [diff] [blame] | 255 | } |
zmo@google.com | fd747b8 | 2011-04-23 01:30:07 +0000 | [diff] [blame] | 256 | |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 257 | if (success && (compileOptions & SH_INTERMEDIATE_TREE)) |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 258 | intermediate.outputTree(root); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 259 | |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 260 | if (success && (compileOptions & SH_OBJECT_CODE)) |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 261 | translate(root); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | // Cleanup memory. |
| 265 | intermediate.remove(parseContext.treeRoot); |
Zhenyao Mo | 7faf1a1 | 2014-04-25 18:03:56 -0700 | [diff] [blame] | 266 | SetGlobalParseContext(NULL); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 267 | return success; |
| 268 | } |
| 269 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 270 | bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources) |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 271 | { |
shannon.woods%transgaming.com@gtempaccount.com | 18b4c4b | 2013-04-13 03:31:40 +0000 | [diff] [blame] | 272 | compileResources = resources; |
Shannon Woods | 2d76e5f | 2014-05-16 17:46:41 -0400 | [diff] [blame] | 273 | setResourceString(); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 274 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 275 | assert(symbolTable.isEmpty()); |
| 276 | symbolTable.push(); // COMMON_BUILTINS |
| 277 | symbolTable.push(); // ESSL1_BUILTINS |
| 278 | symbolTable.push(); // ESSL3_BUILTINS |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 279 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 280 | TPublicType integer; |
| 281 | integer.type = EbtInt; |
| 282 | integer.primarySize = 1; |
| 283 | integer.secondarySize = 1; |
| 284 | integer.array = false; |
| 285 | |
| 286 | TPublicType floatingPoint; |
| 287 | floatingPoint.type = EbtFloat; |
| 288 | floatingPoint.primarySize = 1; |
| 289 | floatingPoint.secondarySize = 1; |
| 290 | floatingPoint.array = false; |
| 291 | |
Zhenyao Mo | a5a1dfc | 2013-09-23 14:57:03 -0400 | [diff] [blame] | 292 | TPublicType sampler; |
| 293 | sampler.primarySize = 1; |
| 294 | sampler.secondarySize = 1; |
| 295 | sampler.array = false; |
| 296 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 297 | switch(shaderType) |
| 298 | { |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 299 | case GL_FRAGMENT_SHADER: |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 300 | symbolTable.setDefaultPrecision(integer, EbpMedium); |
| 301 | break; |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 302 | case GL_VERTEX_SHADER: |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 303 | symbolTable.setDefaultPrecision(integer, EbpHigh); |
| 304 | symbolTable.setDefaultPrecision(floatingPoint, EbpHigh); |
| 305 | break; |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 306 | default: |
| 307 | assert(false && "Language not supported"); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 308 | } |
Zhenyao Mo | a5a1dfc | 2013-09-23 14:57:03 -0400 | [diff] [blame] | 309 | // We set defaults for all the sampler types, even those that are |
| 310 | // only available if an extension exists. |
| 311 | for (int samplerType = EbtGuardSamplerBegin + 1; |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 312 | samplerType < EbtGuardSamplerEnd; ++samplerType) |
| 313 | { |
Zhenyao Mo | a5a1dfc | 2013-09-23 14:57:03 -0400 | [diff] [blame] | 314 | sampler.type = static_cast<TBasicType>(samplerType); |
| 315 | symbolTable.setDefaultPrecision(sampler, EbpLow); |
| 316 | } |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 317 | |
Jamie Madill | 1b45214 | 2013-07-12 14:51:11 -0400 | [diff] [blame] | 318 | InsertBuiltInFunctions(shaderType, shaderSpec, resources, symbolTable); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 319 | |
| 320 | IdentifyBuiltIns(shaderType, shaderSpec, resources, symbolTable); |
| 321 | |
| 322 | return true; |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 323 | } |
| 324 | |
Shannon Woods | 2d76e5f | 2014-05-16 17:46:41 -0400 | [diff] [blame] | 325 | void TCompiler::setResourceString() |
| 326 | { |
| 327 | std::ostringstream strstream; |
| 328 | strstream << ":MaxVertexAttribs:" << compileResources.MaxVertexAttribs |
| 329 | << ":MaxVertexUniformVectors:" << compileResources.MaxVertexUniformVectors |
| 330 | << ":MaxVaryingVectors:" << compileResources.MaxVaryingVectors |
| 331 | << ":MaxVertexTextureImageUnits:" << compileResources.MaxVertexTextureImageUnits |
| 332 | << ":MaxCombinedTextureImageUnits:" << compileResources.MaxCombinedTextureImageUnits |
| 333 | << ":MaxTextureImageUnits:" << compileResources.MaxTextureImageUnits |
| 334 | << ":MaxFragmentUniformVectors:" << compileResources.MaxFragmentUniformVectors |
| 335 | << ":MaxDrawBuffers:" << compileResources.MaxDrawBuffers |
| 336 | << ":OES_standard_derivatives:" << compileResources.OES_standard_derivatives |
| 337 | << ":OES_EGL_image_external:" << compileResources.OES_EGL_image_external |
| 338 | << ":ARB_texture_rectangle:" << compileResources.ARB_texture_rectangle |
| 339 | << ":EXT_draw_buffers:" << compileResources.EXT_draw_buffers |
| 340 | << ":FragmentPrecisionHigh:" << compileResources.FragmentPrecisionHigh |
| 341 | << ":MaxExpressionComplexity:" << compileResources.MaxExpressionComplexity |
| 342 | << ":MaxCallStackDepth:" << compileResources.MaxCallStackDepth |
| 343 | << ":EXT_frag_depth:" << compileResources.EXT_frag_depth |
| 344 | << ":EXT_shader_texture_lod:" << compileResources.EXT_shader_texture_lod |
| 345 | << ":MaxVertexOutputVectors:" << compileResources.MaxVertexOutputVectors |
| 346 | << ":MaxFragmentInputVectors:" << compileResources.MaxFragmentInputVectors |
| 347 | << ":MinProgramTexelOffset:" << compileResources.MinProgramTexelOffset |
| 348 | << ":MaxProgramTexelOffset:" << compileResources.MaxProgramTexelOffset; |
| 349 | |
| 350 | builtInResourcesString = strstream.str(); |
| 351 | } |
| 352 | |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 353 | void TCompiler::clearResults() |
| 354 | { |
daniel@transgaming.com | 4167cc9 | 2013-01-11 04:11:53 +0000 | [diff] [blame] | 355 | arrayBoundsClamper.Cleanup(); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 356 | infoSink.info.erase(); |
| 357 | infoSink.obj.erase(); |
| 358 | infoSink.debug.erase(); |
| 359 | |
| 360 | attribs.clear(); |
| 361 | uniforms.clear(); |
Zhenyao Mo | d2d340b | 2013-09-23 14:57:05 -0400 | [diff] [blame] | 362 | varyings.clear(); |
zmo@google.com | a3b4ab4 | 2011-09-16 00:53:26 +0000 | [diff] [blame] | 363 | |
| 364 | builtInFunctionEmulator.Cleanup(); |
daniel@transgaming.com | 0aa3b5a | 2012-11-28 19:43:24 +0000 | [diff] [blame] | 365 | |
| 366 | nameMap.clear(); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 367 | } |
| 368 | |
Jamie Madill | eb1a010 | 2013-07-08 13:31:38 -0400 | [diff] [blame] | 369 | bool TCompiler::detectCallDepth(TIntermNode* root, TInfoSink& infoSink, bool limitCallStackDepth) |
zmo@google.com | b1762df | 2011-07-30 02:04:23 +0000 | [diff] [blame] | 370 | { |
Jamie Madill | eb1a010 | 2013-07-08 13:31:38 -0400 | [diff] [blame] | 371 | DetectCallDepth detect(infoSink, limitCallStackDepth, maxCallStackDepth); |
zmo@google.com | b1762df | 2011-07-30 02:04:23 +0000 | [diff] [blame] | 372 | root->traverse(&detect); |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 373 | switch (detect.detectCallDepth()) |
| 374 | { |
| 375 | case DetectCallDepth::kErrorNone: |
| 376 | return true; |
| 377 | case DetectCallDepth::kErrorMissingMain: |
| 378 | infoSink.info.prefix(EPrefixError); |
| 379 | infoSink.info << "Missing main()"; |
| 380 | return false; |
| 381 | case DetectCallDepth::kErrorRecursion: |
| 382 | infoSink.info.prefix(EPrefixError); |
| 383 | infoSink.info << "Function recursion detected"; |
| 384 | return false; |
| 385 | case DetectCallDepth::kErrorMaxDepthExceeded: |
| 386 | infoSink.info.prefix(EPrefixError); |
| 387 | infoSink.info << "Function call stack too deep"; |
| 388 | return false; |
| 389 | default: |
| 390 | UNREACHABLE(); |
| 391 | return false; |
zmo@google.com | b1762df | 2011-07-30 02:04:23 +0000 | [diff] [blame] | 392 | } |
| 393 | } |
| 394 | |
Jamie Madill | 05a80ce | 2013-06-20 11:55:49 -0400 | [diff] [blame] | 395 | bool TCompiler::validateOutputs(TIntermNode* root) |
| 396 | { |
| 397 | ValidateOutputs validateOutputs(infoSink.info, compileResources.MaxDrawBuffers); |
| 398 | root->traverse(&validateOutputs); |
| 399 | return (validateOutputs.numErrors() == 0); |
| 400 | } |
| 401 | |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 402 | void TCompiler::rewriteCSSShader(TIntermNode* root) |
| 403 | { |
| 404 | RenameFunction renamer("main(", "css_main("); |
| 405 | root->traverse(&renamer); |
| 406 | } |
| 407 | |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 408 | bool TCompiler::validateLimitations(TIntermNode* root) |
| 409 | { |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 410 | ValidateLimitations validate(shaderType, infoSink.info); |
| 411 | root->traverse(&validate); |
| 412 | return validate.numErrors() == 0; |
| 413 | } |
| 414 | |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 415 | bool TCompiler::enforceTimingRestrictions(TIntermNode* root, bool outputGraph) |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 416 | { |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 417 | if (shaderSpec != SH_WEBGL_SPEC) |
| 418 | { |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 419 | infoSink.info << "Timing restrictions must be enforced under the WebGL spec."; |
| 420 | return false; |
| 421 | } |
| 422 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 423 | if (shaderType == GL_FRAGMENT_SHADER) |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 424 | { |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 425 | TDependencyGraph graph(root); |
| 426 | |
| 427 | // Output any errors first. |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 428 | bool success = enforceFragmentShaderTimingRestrictions(graph); |
Jamie Madill | 5508f39 | 2014-02-20 13:31:36 -0500 | [diff] [blame] | 429 | |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 430 | // Then, output the dependency graph. |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 431 | if (outputGraph) |
| 432 | { |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 433 | TDependencyGraphOutput output(infoSink.info); |
| 434 | output.outputAllSpanningTrees(graph); |
| 435 | } |
Jamie Madill | 5508f39 | 2014-02-20 13:31:36 -0500 | [diff] [blame] | 436 | |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 437 | return success; |
| 438 | } |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 439 | else |
| 440 | { |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 441 | return enforceVertexShaderTimingRestrictions(root); |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 442 | } |
| 443 | } |
| 444 | |
Jamie Madill | eb1a010 | 2013-07-08 13:31:38 -0400 | [diff] [blame] | 445 | bool TCompiler::limitExpressionComplexity(TIntermNode* root) |
| 446 | { |
Jamie Madill | 6654bc9 | 2014-03-26 14:01:57 -0400 | [diff] [blame] | 447 | TMaxDepthTraverser traverser(maxExpressionComplexity+1); |
Jamie Madill | eb1a010 | 2013-07-08 13:31:38 -0400 | [diff] [blame] | 448 | root->traverse(&traverser); |
Jamie Madill | 6654bc9 | 2014-03-26 14:01:57 -0400 | [diff] [blame] | 449 | |
| 450 | if (traverser.getMaxDepth() > maxExpressionComplexity) |
| 451 | { |
| 452 | infoSink.info << "Expression too complex."; |
| 453 | return false; |
| 454 | } |
| 455 | |
Jamie Madill | eb1a010 | 2013-07-08 13:31:38 -0400 | [diff] [blame] | 456 | TDependencyGraph graph(root); |
| 457 | |
| 458 | for (TFunctionCallVector::const_iterator iter = graph.beginUserDefinedFunctionCalls(); |
| 459 | iter != graph.endUserDefinedFunctionCalls(); |
| 460 | ++iter) |
| 461 | { |
| 462 | TGraphFunctionCall* samplerSymbol = *iter; |
| 463 | TDependencyGraphTraverser graphTraverser; |
| 464 | samplerSymbol->traverse(&graphTraverser); |
| 465 | } |
| 466 | |
Jamie Madill | eb1a010 | 2013-07-08 13:31:38 -0400 | [diff] [blame] | 467 | return true; |
| 468 | } |
| 469 | |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 470 | bool TCompiler::enforceFragmentShaderTimingRestrictions(const TDependencyGraph& graph) |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 471 | { |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 472 | RestrictFragmentShaderTiming restrictor(infoSink.info); |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 473 | restrictor.enforceRestrictions(graph); |
| 474 | return restrictor.numErrors() == 0; |
| 475 | } |
| 476 | |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 477 | bool TCompiler::enforceVertexShaderTimingRestrictions(TIntermNode* root) |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 478 | { |
maxvujovic@gmail.com | 77222c9 | 2012-06-04 21:06:05 +0000 | [diff] [blame] | 479 | RestrictVertexShaderTiming restrictor(infoSink.info); |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 480 | restrictor.enforceRestrictions(root); |
| 481 | return restrictor.numErrors() == 0; |
| 482 | } |
| 483 | |
Zhenyao Mo | 74da9f2 | 2013-09-23 14:57:01 -0400 | [diff] [blame] | 484 | void TCompiler::collectVariables(TIntermNode* root) |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 485 | { |
Zhenyao Mo | 74da9f2 | 2013-09-23 14:57:01 -0400 | [diff] [blame] | 486 | CollectVariables collect(attribs, uniforms, varyings, hashFunction); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 487 | root->traverse(&collect); |
| 488 | } |
zmo@google.com | fd747b8 | 2011-04-23 01:30:07 +0000 | [diff] [blame] | 489 | |
gman@chromium.org | 8d80479 | 2012-10-17 21:33:48 +0000 | [diff] [blame] | 490 | bool TCompiler::enforcePackingRestrictions() |
| 491 | { |
| 492 | VariablePacker packer; |
| 493 | return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, uniforms); |
| 494 | } |
| 495 | |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 496 | void TCompiler::initializeGLPosition(TIntermNode* root) |
| 497 | { |
| 498 | InitializeVariables::InitVariableInfoList variables; |
| 499 | InitializeVariables::InitVariableInfo var( |
| 500 | "gl_Position", TType(EbtFloat, EbpUndefined, EvqPosition, 4)); |
| 501 | variables.push_back(var); |
| 502 | InitializeVariables initializer(variables); |
| 503 | root->traverse(&initializer); |
| 504 | } |
| 505 | |
| 506 | void TCompiler::initializeVaryingsWithoutStaticUse(TIntermNode* root) |
| 507 | { |
| 508 | InitializeVariables::InitVariableInfoList variables; |
| 509 | for (size_t ii = 0; ii < varyings.size(); ++ii) |
| 510 | { |
| 511 | const TVariableInfo& varying = varyings[ii]; |
| 512 | if (varying.staticUse) |
| 513 | continue; |
Jamie Madill | aa72d78 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 514 | unsigned char primarySize = static_cast<unsigned char>(gl::VariableColumnCount(varying.type)); |
| 515 | unsigned char secondarySize = static_cast<unsigned char>(gl::VariableRowCount(varying.type)); |
Zhenyao Mo | 66e5dda | 2014-04-28 11:13:25 -0700 | [diff] [blame] | 516 | TType type(EbtFloat, EbpUndefined, EvqVaryingOut, primarySize, secondarySize, varying.isArray); |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 517 | TString name = varying.name.c_str(); |
| 518 | if (varying.isArray) |
| 519 | { |
| 520 | type.setArraySize(varying.size); |
| 521 | name = name.substr(0, name.find_first_of('[')); |
| 522 | } |
| 523 | |
| 524 | InitializeVariables::InitVariableInfo var(name, type); |
| 525 | variables.push_back(var); |
| 526 | } |
| 527 | InitializeVariables initializer(variables); |
| 528 | root->traverse(&initializer); |
| 529 | } |
| 530 | |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 531 | const TExtensionBehavior& TCompiler::getExtensionBehavior() const |
| 532 | { |
| 533 | return extensionBehavior; |
| 534 | } |
zmo@google.com | 32e9731 | 2011-08-24 01:03:11 +0000 | [diff] [blame] | 535 | |
shannon.woods%transgaming.com@gtempaccount.com | 18b4c4b | 2013-04-13 03:31:40 +0000 | [diff] [blame] | 536 | const ShBuiltInResources& TCompiler::getResources() const |
| 537 | { |
| 538 | return compileResources; |
| 539 | } |
| 540 | |
daniel@transgaming.com | 4167cc9 | 2013-01-11 04:11:53 +0000 | [diff] [blame] | 541 | const ArrayBoundsClamper& TCompiler::getArrayBoundsClamper() const |
| 542 | { |
| 543 | return arrayBoundsClamper; |
| 544 | } |
| 545 | |
shannon.woods@transgaming.com | 1d432bb | 2013-01-25 21:57:28 +0000 | [diff] [blame] | 546 | ShArrayIndexClampingStrategy TCompiler::getArrayIndexClampingStrategy() const |
| 547 | { |
| 548 | return clampingStrategy; |
| 549 | } |
| 550 | |
| 551 | const BuiltInFunctionEmulator& TCompiler::getBuiltInFunctionEmulator() const |
| 552 | { |
| 553 | return builtInFunctionEmulator; |
| 554 | } |