daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | // |
shannon.woods%transgaming.com@gtempaccount.com | 0bbed38 | 2013-04-13 03:38:07 +0000 | [diff] [blame] | 2 | // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +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 | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 7 | #ifndef COMPILER_TRANSLATOR_COMPILER_H_ |
| 8 | #define COMPILER_TRANSLATOR_COMPILER_H_ |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 9 | |
| 10 | // |
| 11 | // Machine independent part of the compiler private objects |
| 12 | // sent as ShHandle to the driver. |
| 13 | // |
| 14 | // This should not be included by driver code. |
| 15 | // |
| 16 | |
Olli Etuaho | 8efc5ad | 2015-03-03 17:21:10 +0200 | [diff] [blame] | 17 | #include "compiler/translator/BuiltInFunctionEmulator.h" |
Corentin Wallez | 71d147f | 2015-02-11 11:15:24 -0800 | [diff] [blame] | 18 | #include "compiler/translator/CallDAG.h" |
Geoff Lang | 1773282 | 2013-08-29 13:46:49 -0400 | [diff] [blame] | 19 | #include "compiler/translator/ExtensionBehavior.h" |
| 20 | #include "compiler/translator/HashNames.h" |
| 21 | #include "compiler/translator/InfoSink.h" |
Zhenyao Mo | 94ac7b7 | 2014-10-15 18:22:08 -0700 | [diff] [blame] | 22 | #include "compiler/translator/Pragma.h" |
Geoff Lang | 1773282 | 2013-08-29 13:46:49 -0400 | [diff] [blame] | 23 | #include "compiler/translator/SymbolTable.h" |
| 24 | #include "compiler/translator/VariableInfo.h" |
shannon.woods@transgaming.com | da1ed36 | 2013-01-25 21:54:57 +0000 | [diff] [blame] | 25 | #include "third_party/compiler/ArrayBoundsClamper.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 26 | |
Jamie Madill | acb4b81 | 2016-11-07 13:50:29 -0500 | [diff] [blame^] | 27 | namespace sh |
| 28 | { |
| 29 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 30 | class TCompiler; |
Daniel Bratell | 73941de | 2015-02-25 14:34:49 +0100 | [diff] [blame] | 31 | #ifdef ANGLE_ENABLE_HLSL |
daniel@transgaming.com | 043da13 | 2012-12-20 21:12:22 +0000 | [diff] [blame] | 32 | class TranslatorHLSL; |
Daniel Bratell | 73941de | 2015-02-25 14:34:49 +0100 | [diff] [blame] | 33 | #endif // ANGLE_ENABLE_HLSL |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 34 | |
| 35 | // |
Qiankun Miao | c2c5fc4 | 2016-08-31 15:24:22 +0800 | [diff] [blame] | 36 | // Helper function to identify specs that are based on the WebGL spec. |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 37 | // |
Jamie Madill | 5508f39 | 2014-02-20 13:31:36 -0500 | [diff] [blame] | 38 | bool IsWebGLBasedSpec(ShShaderSpec spec); |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 39 | |
| 40 | // |
Qingqing Deng | ad0d079 | 2015-04-08 14:25:06 -0700 | [diff] [blame] | 41 | // Helper function to check if the shader type is GLSL. |
| 42 | // |
| 43 | bool IsGLSL130OrNewer(ShShaderOutput output); |
Qiankun Miao | 705a919 | 2016-08-29 10:05:27 +0800 | [diff] [blame] | 44 | bool IsGLSL420OrNewer(ShShaderOutput output); |
Qingqing Deng | ad0d079 | 2015-04-08 14:25:06 -0700 | [diff] [blame] | 45 | |
| 46 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 47 | // The base class used to back handles returned to the driver. |
| 48 | // |
| 49 | class TShHandleBase { |
| 50 | public: |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 51 | TShHandleBase(); |
| 52 | virtual ~TShHandleBase(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 53 | virtual TCompiler* getAsCompiler() { return 0; } |
Daniel Bratell | 73941de | 2015-02-25 14:34:49 +0100 | [diff] [blame] | 54 | #ifdef ANGLE_ENABLE_HLSL |
daniel@transgaming.com | 043da13 | 2012-12-20 21:12:22 +0000 | [diff] [blame] | 55 | virtual TranslatorHLSL* getAsTranslatorHLSL() { return 0; } |
Daniel Bratell | 73941de | 2015-02-25 14:34:49 +0100 | [diff] [blame] | 56 | #endif // ANGLE_ENABLE_HLSL |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 57 | |
| 58 | protected: |
| 59 | // Memory allocator. Allocates and tracks memory required by the compiler. |
| 60 | // Deallocates all memory when compiler is destructed. |
| 61 | TPoolAllocator allocator; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 65 | // The base class for the machine dependent compiler to derive from |
| 66 | // for managing object code from the compile. |
| 67 | // |
Jamie Madill | a718c1e | 2014-07-02 15:31:22 -0400 | [diff] [blame] | 68 | class TCompiler : public TShHandleBase |
| 69 | { |
| 70 | public: |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 71 | TCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output); |
Corentin Wallez | e5a1f27 | 2015-08-21 02:58:25 +0200 | [diff] [blame] | 72 | ~TCompiler() override; |
| 73 | TCompiler *getAsCompiler() override { return this; } |
alokp@chromium.org | 76b8208 | 2010-03-24 17:59:39 +0000 | [diff] [blame] | 74 | |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 75 | bool Init(const ShBuiltInResources& resources); |
Olli Etuaho | a3a5cc6 | 2015-02-13 13:12:22 +0200 | [diff] [blame] | 76 | |
| 77 | // compileTreeForTesting should be used only when tests require access to |
| 78 | // the AST. Users of this function need to manually manage the global pool |
Olli Etuaho | 6d40bbd | 2016-09-30 13:49:38 +0100 | [diff] [blame] | 79 | // allocator. Returns nullptr whenever there are compilation errors. |
| 80 | TIntermBlock *compileTreeForTesting(const char *const shaderStrings[], |
| 81 | size_t numStrings, |
| 82 | ShCompileOptions compileOptions); |
Olli Etuaho | a3a5cc6 | 2015-02-13 13:12:22 +0200 | [diff] [blame] | 83 | |
Qiankun Miao | 7ebb97f | 2016-09-08 18:01:50 +0800 | [diff] [blame] | 84 | bool compile(const char *const shaderStrings[], |
| 85 | size_t numStrings, |
| 86 | ShCompileOptions compileOptions); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 87 | |
| 88 | // Get results of the last compilation. |
shannon.woods%transgaming.com@gtempaccount.com | 0bbed38 | 2013-04-13 03:38:07 +0000 | [diff] [blame] | 89 | int getShaderVersion() const { return shaderVersion; } |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 90 | TInfoSink& getInfoSink() { return infoSink; } |
Jamie Madill | ed27c72 | 2014-07-02 15:31:23 -0400 | [diff] [blame] | 91 | |
Martin Radev | 802abe0 | 2016-08-04 17:48:32 +0300 | [diff] [blame] | 92 | bool isComputeShaderLocalSizeDeclared() const { return mComputeShaderLocalSizeDeclared; } |
Martin Radev | 4c4c8e7 | 2016-08-04 12:25:34 +0300 | [diff] [blame] | 93 | const sh::WorkGroupSize &getComputeShaderLocalSize() { return mComputeShaderLocalSize; } |
Martin Radev | 802abe0 | 2016-08-04 17:48:32 +0300 | [diff] [blame] | 94 | |
Dmitry Skiba | 2539fff | 2015-06-16 17:56:09 -0700 | [diff] [blame] | 95 | // Clears the results from the previous compilation. |
| 96 | void clearResults(); |
| 97 | |
Jamie Madill | ed27c72 | 2014-07-02 15:31:23 -0400 | [diff] [blame] | 98 | const std::vector<sh::Attribute> &getAttributes() const { return attributes; } |
Jamie Madill | a0a9e12 | 2015-09-02 15:54:30 -0400 | [diff] [blame] | 99 | const std::vector<sh::OutputVariable> &getOutputVariables() const { return outputVariables; } |
Jamie Madill | a718c1e | 2014-07-02 15:31:22 -0400 | [diff] [blame] | 100 | const std::vector<sh::Uniform> &getUniforms() const { return uniforms; } |
| 101 | const std::vector<sh::Varying> &getVaryings() const { return varyings; } |
Jamie Madill | ed27c72 | 2014-07-02 15:31:23 -0400 | [diff] [blame] | 102 | const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return interfaceBlocks; } |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 103 | |
daniel@transgaming.com | c23f461 | 2012-11-28 19:42:57 +0000 | [diff] [blame] | 104 | ShHashFunction64 getHashFunction() const { return hashFunction; } |
daniel@transgaming.com | 0aa3b5a | 2012-11-28 19:43:24 +0000 | [diff] [blame] | 105 | NameMap& getNameMap() { return nameMap; } |
| 106 | TSymbolTable& getSymbolTable() { return symbolTable; } |
Zhenyao Mo | 7faf1a1 | 2014-04-25 18:03:56 -0700 | [diff] [blame] | 107 | ShShaderSpec getShaderSpec() const { return shaderSpec; } |
Jamie Madill | 68fe74a | 2014-05-27 12:56:01 -0400 | [diff] [blame] | 108 | ShShaderOutput getOutputType() const { return outputType; } |
Zhenyao Mo | 4de44cb | 2014-10-29 18:03:46 -0700 | [diff] [blame] | 109 | const std::string &getBuiltInResourcesString() const { return builtInResourcesString; } |
daniel@transgaming.com | c23f461 | 2012-11-28 19:42:57 +0000 | [diff] [blame] | 110 | |
Qiankun Miao | 7ebb97f | 2016-09-08 18:01:50 +0800 | [diff] [blame] | 111 | bool shouldRunLoopAndIndexingValidation(ShCompileOptions compileOptions) const; |
Olli Etuaho | 5d91dda | 2015-06-18 15:47:46 +0300 | [diff] [blame] | 112 | |
Jamie Madill | 54ad4f8 | 2014-09-03 09:40:46 -0400 | [diff] [blame] | 113 | // Get the resources set by InitBuiltInSymbolTable |
| 114 | const ShBuiltInResources& getResources() const; |
| 115 | |
Jamie Madill | a718c1e | 2014-07-02 15:31:22 -0400 | [diff] [blame] | 116 | protected: |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 117 | sh::GLenum getShaderType() const { return shaderType; } |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 118 | // Initialize symbol-table with built-in symbols. |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 119 | bool InitBuiltInSymbolTable(const ShBuiltInResources& resources); |
Shannon Woods | 2d76e5f | 2014-05-16 17:46:41 -0400 | [diff] [blame] | 120 | // Compute the string representation of the built-in resources |
| 121 | void setResourceString(); |
Corentin Wallez | 71d147f | 2015-02-11 11:15:24 -0800 | [diff] [blame] | 122 | // Return false if the call depth is exceeded. |
| 123 | bool checkCallDepth(); |
Jamie Madill | 05a80ce | 2013-06-20 11:55:49 -0400 | [diff] [blame] | 124 | // Returns true if a program has no conflicting or missing fragment outputs |
| 125 | bool validateOutputs(TIntermNode* root); |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 126 | // Returns true if the given shader does not exceed the minimum |
| 127 | // functionality mandated in GLSL 1.0 spec Appendix A. |
| 128 | bool validateLimitations(TIntermNode* root); |
Olli Etuaho | 8efc5ad | 2015-03-03 17:21:10 +0200 | [diff] [blame] | 129 | // Add emulated functions to the built-in function emulator. |
Qiankun Miao | 7ebb97f | 2016-09-08 18:01:50 +0800 | [diff] [blame] | 130 | virtual void initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu, |
| 131 | ShCompileOptions compileOptions){}; |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 132 | // Translate to object code. |
Qiankun Miao | 7ebb97f | 2016-09-08 18:01:50 +0800 | [diff] [blame] | 133 | virtual void translate(TIntermNode *root, ShCompileOptions compileOptions) = 0; |
gman@chromium.org | 8d80479 | 2012-10-17 21:33:48 +0000 | [diff] [blame] | 134 | // Returns true if, after applying the packing rules in the GLSL 1.017 spec |
| 135 | // Appendix A, section 7, the shader does not use too many uniforms. |
| 136 | bool enforcePackingRestrictions(); |
Qin Jiajia | 7835b52 | 2016-10-08 11:20:17 +0800 | [diff] [blame] | 137 | // Insert statements to reference all members in unused uniform blocks with standard and shared |
| 138 | // layout. This is to work around a Mac driver that treats unused standard/shared |
| 139 | // uniform blocks as inactive. |
| 140 | void useAllMembersInUnusedStandardAndSharedBlocks(TIntermNode *root); |
Zhenyao Mo | 7211191 | 2016-07-20 17:45:56 -0700 | [diff] [blame] | 141 | // Insert statements to initialize output variables in the beginning of main(). |
| 142 | // This is to avoid undefined behaviors. |
Olli Etuaho | 27776e3 | 2016-07-22 14:00:56 +0300 | [diff] [blame] | 143 | void initializeOutputVariables(TIntermNode *root); |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 144 | // Insert gl_Position = vec4(0,0,0,0) to the beginning of main(). |
| 145 | // It is to work around a Linux driver bug where missing this causes compile failure |
| 146 | // while spec says it is allowed. |
| 147 | // This function should only be applied to vertex shaders. |
| 148 | void initializeGLPosition(TIntermNode* root); |
Jamie Madill | eb1a010 | 2013-07-08 13:31:38 -0400 | [diff] [blame] | 149 | // Return true if the maximum expression complexity is below the limit. |
| 150 | bool limitExpressionComplexity(TIntermNode* root); |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 151 | // Get built-in extensions with default behavior. |
| 152 | const TExtensionBehavior& getExtensionBehavior() const; |
Olli Etuaho | a3a5cc6 | 2015-02-13 13:12:22 +0200 | [diff] [blame] | 153 | const char *getSourcePath() const; |
Zhenyao Mo | 94ac7b7 | 2014-10-15 18:22:08 -0700 | [diff] [blame] | 154 | const TPragma& getPragma() const { return mPragma; } |
Qiankun Miao | 7ebb97f | 2016-09-08 18:01:50 +0800 | [diff] [blame] | 155 | void writePragma(ShCompileOptions compileOptions); |
Corentin Wallez | d4b5054 | 2015-09-28 12:19:26 -0700 | [diff] [blame] | 156 | unsigned int *getTemporaryIndex() { return &mTemporaryIndex; } |
Kenneth Russell | bccc65d | 2016-07-19 16:48:43 -0700 | [diff] [blame] | 157 | // Relies on collectVariables having been called. |
| 158 | bool isVaryingDefined(const char *varyingName); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 159 | |
daniel@transgaming.com | 4167cc9 | 2013-01-11 04:11:53 +0000 | [diff] [blame] | 160 | const ArrayBoundsClamper& getArrayBoundsClamper() const; |
shannon.woods@transgaming.com | 1d432bb | 2013-01-25 21:57:28 +0000 | [diff] [blame] | 161 | ShArrayIndexClampingStrategy getArrayIndexClampingStrategy() const; |
Olli Etuaho | 8efc5ad | 2015-03-03 17:21:10 +0200 | [diff] [blame] | 162 | const BuiltInFunctionEmulator& getBuiltInFunctionEmulator() const; |
zmo@google.com | 32e9731 | 2011-08-24 01:03:11 +0000 | [diff] [blame] | 163 | |
Kenneth Russell | bccc65d | 2016-07-19 16:48:43 -0700 | [diff] [blame] | 164 | virtual bool shouldFlattenPragmaStdglInvariantAll() = 0; |
Corentin Wallez | 1df1602 | 2016-10-27 08:16:56 -0400 | [diff] [blame] | 165 | virtual bool shouldCollectVariables(ShCompileOptions compileOptions); |
Kenneth Russell | bccc65d | 2016-07-19 16:48:43 -0700 | [diff] [blame] | 166 | |
Corentin Wallez | 1df1602 | 2016-10-27 08:16:56 -0400 | [diff] [blame] | 167 | bool wereVariablesCollected() const; |
Jamie Madill | ed27c72 | 2014-07-02 15:31:23 -0400 | [diff] [blame] | 168 | std::vector<sh::Attribute> attributes; |
Jamie Madill | a0a9e12 | 2015-09-02 15:54:30 -0400 | [diff] [blame] | 169 | std::vector<sh::OutputVariable> outputVariables; |
Jamie Madill | ed27c72 | 2014-07-02 15:31:23 -0400 | [diff] [blame] | 170 | std::vector<sh::Uniform> uniforms; |
Jamie Madill | 42bcf32 | 2014-08-25 16:20:46 -0400 | [diff] [blame] | 171 | std::vector<sh::ShaderVariable> expandedUniforms; |
Jamie Madill | ed27c72 | 2014-07-02 15:31:23 -0400 | [diff] [blame] | 172 | std::vector<sh::Varying> varyings; |
| 173 | std::vector<sh::InterfaceBlock> interfaceBlocks; |
Olli Etuaho | 4dfe809 | 2015-08-21 17:44:35 +0300 | [diff] [blame] | 174 | |
Jamie Madill | a718c1e | 2014-07-02 15:31:22 -0400 | [diff] [blame] | 175 | private: |
Corentin Wallez | 71d147f | 2015-02-11 11:15:24 -0800 | [diff] [blame] | 176 | // Creates the function call DAG for further analysis, returning false if there is a recursion |
| 177 | bool initCallDag(TIntermNode *root); |
| 178 | // Return false if "main" doesn't exist |
| 179 | bool tagUsedFunctions(); |
| 180 | void internalTagUsedFunction(size_t index); |
| 181 | |
Olli Etuaho | 183d7e2 | 2015-11-20 15:59:09 +0200 | [diff] [blame] | 182 | void initSamplerDefaultPrecision(TBasicType samplerType); |
| 183 | |
Corentin Wallez | 1df1602 | 2016-10-27 08:16:56 -0400 | [diff] [blame] | 184 | // Collect info for all attribs, uniforms, varyings. |
| 185 | void collectVariables(TIntermNode *root); |
| 186 | |
| 187 | bool variablesCollected; |
| 188 | |
Corentin Wallez | a094a8a | 2015-04-07 11:53:06 -0700 | [diff] [blame] | 189 | // Removes unused function declarations and prototypes from the AST |
| 190 | class UnusedPredicate; |
Olli Etuaho | 6d40bbd | 2016-09-30 13:49:38 +0100 | [diff] [blame] | 191 | bool pruneUnusedFunctions(TIntermBlock *root); |
Corentin Wallez | a094a8a | 2015-04-07 11:53:06 -0700 | [diff] [blame] | 192 | |
Olli Etuaho | 6d40bbd | 2016-09-30 13:49:38 +0100 | [diff] [blame] | 193 | TIntermBlock *compileTreeImpl(const char *const shaderStrings[], |
| 194 | size_t numStrings, |
| 195 | const ShCompileOptions compileOptions); |
Olli Etuaho | a3a5cc6 | 2015-02-13 13:12:22 +0200 | [diff] [blame] | 196 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 197 | sh::GLenum shaderType; |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 198 | ShShaderSpec shaderSpec; |
Jamie Madill | 68fe74a | 2014-05-27 12:56:01 -0400 | [diff] [blame] | 199 | ShShaderOutput outputType; |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 200 | |
Corentin Wallez | 71d147f | 2015-02-11 11:15:24 -0800 | [diff] [blame] | 201 | struct FunctionMetadata |
| 202 | { |
| 203 | FunctionMetadata() |
| 204 | : used(false) |
| 205 | { |
| 206 | } |
| 207 | bool used; |
| 208 | }; |
| 209 | |
| 210 | CallDAG mCallDag; |
| 211 | std::vector<FunctionMetadata> functionMetadata; |
| 212 | |
gman@chromium.org | 8d80479 | 2012-10-17 21:33:48 +0000 | [diff] [blame] | 213 | int maxUniformVectors; |
Jamie Madill | eb1a010 | 2013-07-08 13:31:38 -0400 | [diff] [blame] | 214 | int maxExpressionComplexity; |
| 215 | int maxCallStackDepth; |
Olli Etuaho | 19d1dc9 | 2016-03-08 17:18:46 +0200 | [diff] [blame] | 216 | int maxFunctionParameters; |
gman@chromium.org | 8d80479 | 2012-10-17 21:33:48 +0000 | [diff] [blame] | 217 | |
shannon.woods%transgaming.com@gtempaccount.com | 18b4c4b | 2013-04-13 03:31:40 +0000 | [diff] [blame] | 218 | ShBuiltInResources compileResources; |
Shannon Woods | 2d76e5f | 2014-05-16 17:46:41 -0400 | [diff] [blame] | 219 | std::string builtInResourcesString; |
shannon.woods%transgaming.com@gtempaccount.com | 18b4c4b | 2013-04-13 03:31:40 +0000 | [diff] [blame] | 220 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 221 | // Built-in symbol table for the given language, spec, and resources. |
| 222 | // It is preserved from compile-to-compile. |
| 223 | TSymbolTable symbolTable; |
alokp@chromium.org | ad771eb | 2010-09-07 17:36:23 +0000 | [diff] [blame] | 224 | // Built-in extensions with default behavior. |
| 225 | TExtensionBehavior extensionBehavior; |
shannon.woods%transgaming.com@gtempaccount.com | cbb6b6a | 2013-04-13 03:27:47 +0000 | [diff] [blame] | 226 | bool fragmentPrecisionHigh; |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 227 | |
daniel@transgaming.com | 4167cc9 | 2013-01-11 04:11:53 +0000 | [diff] [blame] | 228 | ArrayBoundsClamper arrayBoundsClamper; |
shannon.woods@transgaming.com | 1d432bb | 2013-01-25 21:57:28 +0000 | [diff] [blame] | 229 | ShArrayIndexClampingStrategy clampingStrategy; |
Olli Etuaho | 8efc5ad | 2015-03-03 17:21:10 +0200 | [diff] [blame] | 230 | BuiltInFunctionEmulator builtInFunctionEmulator; |
zmo@google.com | 32e9731 | 2011-08-24 01:03:11 +0000 | [diff] [blame] | 231 | |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 232 | // Results of compilation. |
shannon.woods%transgaming.com@gtempaccount.com | 0bbed38 | 2013-04-13 03:38:07 +0000 | [diff] [blame] | 233 | int shaderVersion; |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 234 | TInfoSink infoSink; // Output sink. |
Olli Etuaho | a3a5cc6 | 2015-02-13 13:12:22 +0200 | [diff] [blame] | 235 | const char *mSourcePath; // Path of source file or NULL |
zmo@google.com | 24c08c4 | 2011-05-27 17:40:48 +0000 | [diff] [blame] | 236 | |
Martin Radev | 802abe0 | 2016-08-04 17:48:32 +0300 | [diff] [blame] | 237 | // compute shader local group size |
| 238 | bool mComputeShaderLocalSizeDeclared; |
Martin Radev | 4c4c8e7 | 2016-08-04 12:25:34 +0300 | [diff] [blame] | 239 | sh::WorkGroupSize mComputeShaderLocalSize; |
Martin Radev | 802abe0 | 2016-08-04 17:48:32 +0300 | [diff] [blame] | 240 | |
daniel@transgaming.com | c23f461 | 2012-11-28 19:42:57 +0000 | [diff] [blame] | 241 | // name hashing. |
| 242 | ShHashFunction64 hashFunction; |
| 243 | NameMap nameMap; |
Zhenyao Mo | 94ac7b7 | 2014-10-15 18:22:08 -0700 | [diff] [blame] | 244 | |
| 245 | TPragma mPragma; |
Corentin Wallez | d4b5054 | 2015-09-28 12:19:26 -0700 | [diff] [blame] | 246 | |
| 247 | unsigned int mTemporaryIndex; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 248 | }; |
| 249 | |
| 250 | // |
| 251 | // This is the interface between the machine independent code |
| 252 | // and the machine dependent code. |
| 253 | // |
| 254 | // The machine dependent code should derive from the classes |
Jamie Madill | d4a3a31 | 2014-06-25 16:04:56 -0400 | [diff] [blame] | 255 | // above. Then Construct*() and Delete*() will create and |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 256 | // destroy the machine dependent objects, which contain the |
| 257 | // above machine independent information. |
| 258 | // |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 259 | TCompiler* ConstructCompiler( |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 260 | sh::GLenum type, ShShaderSpec spec, ShShaderOutput output); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 261 | void DeleteCompiler(TCompiler*); |
| 262 | |
Jamie Madill | acb4b81 | 2016-11-07 13:50:29 -0500 | [diff] [blame^] | 263 | } // namespace sh |
| 264 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 265 | #endif // COMPILER_TRANSLATOR_COMPILER_H_ |