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 | 78ed6cd | 2017-08-09 16:19:00 +0300 | [diff] [blame] | 17 | #include <GLSLANG/ShaderVars.h> |
| 18 | |
Olli Etuaho | 8efc5ad | 2015-03-03 17:21:10 +0200 | [diff] [blame] | 19 | #include "compiler/translator/BuiltInFunctionEmulator.h" |
Corentin Wallez | 71d147f | 2015-02-11 11:15:24 -0800 | [diff] [blame] | 20 | #include "compiler/translator/CallDAG.h" |
Olli Etuaho | 77ba408 | 2016-12-16 12:01:18 +0000 | [diff] [blame] | 21 | #include "compiler/translator/Diagnostics.h" |
Geoff Lang | 1773282 | 2013-08-29 13:46:49 -0400 | [diff] [blame] | 22 | #include "compiler/translator/ExtensionBehavior.h" |
| 23 | #include "compiler/translator/HashNames.h" |
| 24 | #include "compiler/translator/InfoSink.h" |
Zhenyao Mo | 94ac7b7 | 2014-10-15 18:22:08 -0700 | [diff] [blame] | 25 | #include "compiler/translator/Pragma.h" |
Geoff Lang | 1773282 | 2013-08-29 13:46:49 -0400 | [diff] [blame] | 26 | #include "compiler/translator/SymbolTable.h" |
Shahbaz Youssefi | 91d469a | 2018-08-27 10:47:25 -0400 | [diff] [blame] | 27 | #include "compiler/translator/ValidateAST.h" |
shannon.woods@transgaming.com | da1ed36 | 2013-01-25 21:54:57 +0000 | [diff] [blame] | 28 | #include "third_party/compiler/ArrayBoundsClamper.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 29 | |
Jamie Madill | acb4b81 | 2016-11-07 13:50:29 -0500 | [diff] [blame] | 30 | namespace sh |
| 31 | { |
| 32 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 33 | class TCompiler; |
Olli Etuaho | d10cf69 | 2017-11-02 11:06:14 +0200 | [diff] [blame] | 34 | class TParseContext; |
Daniel Bratell | 73941de | 2015-02-25 14:34:49 +0100 | [diff] [blame] | 35 | #ifdef ANGLE_ENABLE_HLSL |
daniel@transgaming.com | 043da13 | 2012-12-20 21:12:22 +0000 | [diff] [blame] | 36 | class TranslatorHLSL; |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 37 | #endif // ANGLE_ENABLE_HLSL |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 38 | |
| 39 | // |
Qingqing Deng | ad0d079 | 2015-04-08 14:25:06 -0700 | [diff] [blame] | 40 | // Helper function to check if the shader type is GLSL. |
| 41 | // |
| 42 | bool IsGLSL130OrNewer(ShShaderOutput output); |
Qiankun Miao | 705a919 | 2016-08-29 10:05:27 +0800 | [diff] [blame] | 43 | bool IsGLSL420OrNewer(ShShaderOutput output); |
Zhenyao Mo | b7bf742 | 2016-11-08 14:44:05 -0800 | [diff] [blame] | 44 | bool IsGLSL410OrOlder(ShShaderOutput output); |
Qingqing Deng | ad0d079 | 2015-04-08 14:25:06 -0700 | [diff] [blame] | 45 | |
| 46 | // |
Qiankun Miao | 89dd8f3 | 2016-11-09 12:59:30 +0000 | [diff] [blame] | 47 | // Helper function to check if the invariant qualifier can be removed. |
| 48 | // |
| 49 | bool RemoveInvariant(sh::GLenum shaderType, |
| 50 | int shaderVersion, |
| 51 | ShShaderOutput outputType, |
| 52 | ShCompileOptions compileOptions); |
| 53 | |
| 54 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 55 | // The base class used to back handles returned to the driver. |
| 56 | // |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 57 | class TShHandleBase |
| 58 | { |
| 59 | public: |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 60 | TShHandleBase(); |
| 61 | virtual ~TShHandleBase(); |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 62 | virtual TCompiler *getAsCompiler() { return 0; } |
Daniel Bratell | 73941de | 2015-02-25 14:34:49 +0100 | [diff] [blame] | 63 | #ifdef ANGLE_ENABLE_HLSL |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 64 | virtual TranslatorHLSL *getAsTranslatorHLSL() { return 0; } |
| 65 | #endif // ANGLE_ENABLE_HLSL |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 66 | |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 67 | protected: |
alokp@chromium.org | bafcbaa | 2010-11-23 19:07:43 +0000 | [diff] [blame] | 68 | // Memory allocator. Allocates and tracks memory required by the compiler. |
| 69 | // Deallocates all memory when compiler is destructed. |
Tobin Ehlis | 47ca1b2 | 2019-01-23 16:11:41 +0000 | [diff] [blame] | 70 | TPoolAllocator allocator; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 74 | // The base class for the machine dependent compiler to derive from |
| 75 | // for managing object code from the compile. |
| 76 | // |
Jamie Madill | a718c1e | 2014-07-02 15:31:22 -0400 | [diff] [blame] | 77 | class TCompiler : public TShHandleBase |
| 78 | { |
| 79 | public: |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 80 | TCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output); |
Corentin Wallez | e5a1f27 | 2015-08-21 02:58:25 +0200 | [diff] [blame] | 81 | ~TCompiler() override; |
| 82 | TCompiler *getAsCompiler() override { return this; } |
alokp@chromium.org | 76b8208 | 2010-03-24 17:59:39 +0000 | [diff] [blame] | 83 | |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 84 | bool Init(const ShBuiltInResources &resources); |
Olli Etuaho | a3a5cc6 | 2015-02-13 13:12:22 +0200 | [diff] [blame] | 85 | |
| 86 | // compileTreeForTesting should be used only when tests require access to |
| 87 | // 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] | 88 | // allocator. Returns nullptr whenever there are compilation errors. |
| 89 | TIntermBlock *compileTreeForTesting(const char *const shaderStrings[], |
| 90 | size_t numStrings, |
| 91 | ShCompileOptions compileOptions); |
Olli Etuaho | a3a5cc6 | 2015-02-13 13:12:22 +0200 | [diff] [blame] | 92 | |
Qiankun Miao | 7ebb97f | 2016-09-08 18:01:50 +0800 | [diff] [blame] | 93 | bool compile(const char *const shaderStrings[], |
| 94 | size_t numStrings, |
| 95 | ShCompileOptions compileOptions); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 96 | |
| 97 | // Get results of the last compilation. |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 98 | int getShaderVersion() const { return mShaderVersion; } |
| 99 | TInfoSink &getInfoSink() { return mInfoSink; } |
Jamie Madill | ed27c72 | 2014-07-02 15:31:23 -0400 | [diff] [blame] | 100 | |
Martin Radev | 802abe0 | 2016-08-04 17:48:32 +0300 | [diff] [blame] | 101 | bool isComputeShaderLocalSizeDeclared() const { return mComputeShaderLocalSizeDeclared; } |
Olli Etuaho | 09b04a2 | 2016-12-15 13:30:26 +0000 | [diff] [blame] | 102 | const sh::WorkGroupSize &getComputeShaderLocalSize() const { return mComputeShaderLocalSize; } |
| 103 | int getNumViews() const { return mNumViews; } |
Martin Radev | 802abe0 | 2016-08-04 17:48:32 +0300 | [diff] [blame] | 104 | |
Dmitry Skiba | 2539fff | 2015-06-16 17:56:09 -0700 | [diff] [blame] | 105 | // Clears the results from the previous compilation. |
| 106 | void clearResults(); |
| 107 | |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 108 | const std::vector<sh::Attribute> &getAttributes() const { return mAttributes; } |
| 109 | const std::vector<sh::OutputVariable> &getOutputVariables() const { return mOutputVariables; } |
| 110 | const std::vector<sh::Uniform> &getUniforms() const { return mUniforms; } |
| 111 | const std::vector<sh::Varying> &getInputVaryings() const { return mInputVaryings; } |
| 112 | const std::vector<sh::Varying> &getOutputVaryings() const { return mOutputVaryings; } |
| 113 | const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return mInterfaceBlocks; } |
| 114 | const std::vector<sh::InterfaceBlock> &getUniformBlocks() const { return mUniformBlocks; } |
Jiajia Qin | 9b11ea4 | 2017-07-11 16:50:08 +0800 | [diff] [blame] | 115 | const std::vector<sh::InterfaceBlock> &getShaderStorageBlocks() const |
| 116 | { |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 117 | return mShaderStorageBlocks; |
Jiajia Qin | 9b11ea4 | 2017-07-11 16:50:08 +0800 | [diff] [blame] | 118 | } |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 119 | const std::vector<sh::InterfaceBlock> &getInBlocks() const { return mInBlocks; } |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 120 | |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 121 | ShHashFunction64 getHashFunction() const { return mResources.HashFunction; } |
| 122 | NameMap &getNameMap() { return mNameMap; } |
| 123 | TSymbolTable &getSymbolTable() { return mSymbolTable; } |
| 124 | ShShaderSpec getShaderSpec() const { return mShaderSpec; } |
| 125 | ShShaderOutput getOutputType() const { return mOutputType; } |
| 126 | const std::string &getBuiltInResourcesString() const { return mBuiltInResourcesString; } |
daniel@transgaming.com | c23f461 | 2012-11-28 19:42:57 +0000 | [diff] [blame] | 127 | |
Qiankun Miao | 7ebb97f | 2016-09-08 18:01:50 +0800 | [diff] [blame] | 128 | bool shouldRunLoopAndIndexingValidation(ShCompileOptions compileOptions) const; |
Olli Etuaho | 5d91dda | 2015-06-18 15:47:46 +0300 | [diff] [blame] | 129 | |
Jamie Madill | 54ad4f8 | 2014-09-03 09:40:46 -0400 | [diff] [blame] | 130 | // Get the resources set by InitBuiltInSymbolTable |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 131 | const ShBuiltInResources &getResources() const; |
Jamie Madill | 54ad4f8 | 2014-09-03 09:40:46 -0400 | [diff] [blame] | 132 | |
Shao | b5cc119 | 2017-07-06 10:47:20 +0800 | [diff] [blame] | 133 | int getGeometryShaderMaxVertices() const { return mGeometryShaderMaxVertices; } |
| 134 | int getGeometryShaderInvocations() const { return mGeometryShaderInvocations; } |
| 135 | TLayoutPrimitiveType getGeometryShaderInputPrimitiveType() const |
| 136 | { |
| 137 | return mGeometryShaderInputPrimitiveType; |
| 138 | } |
| 139 | TLayoutPrimitiveType getGeometryShaderOutputPrimitiveType() const |
| 140 | { |
| 141 | return mGeometryShaderOutputPrimitiveType; |
| 142 | } |
| 143 | |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 144 | sh::GLenum getShaderType() const { return mShaderType; } |
Shao | b5cc119 | 2017-07-06 10:47:20 +0800 | [diff] [blame] | 145 | |
| 146 | protected: |
Olli Etuaho | 8efc5ad | 2015-03-03 17:21:10 +0200 | [diff] [blame] | 147 | // Add emulated functions to the built-in function emulator. |
Qiankun Miao | 7ebb97f | 2016-09-08 18:01:50 +0800 | [diff] [blame] | 148 | virtual void initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu, |
Jamie Madill | c09ae15 | 2019-02-01 14:16:32 -0500 | [diff] [blame^] | 149 | ShCompileOptions compileOptions) |
| 150 | {} |
Olli Etuaho | 89a69a0 | 2017-10-23 12:20:45 +0300 | [diff] [blame] | 151 | // Translate to object code. May generate performance warnings through the diagnostics. |
| 152 | virtual void translate(TIntermBlock *root, |
| 153 | ShCompileOptions compileOptions, |
| 154 | PerformanceDiagnostics *perfDiagnostics) = 0; |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 155 | // Get built-in extensions with default behavior. |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 156 | const TExtensionBehavior &getExtensionBehavior() const; |
Olli Etuaho | a3a5cc6 | 2015-02-13 13:12:22 +0200 | [diff] [blame] | 157 | const char *getSourcePath() const; |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 158 | const TPragma &getPragma() const { return mPragma; } |
Qiankun Miao | 7ebb97f | 2016-09-08 18:01:50 +0800 | [diff] [blame] | 159 | void writePragma(ShCompileOptions compileOptions); |
Kenneth Russell | bccc65d | 2016-07-19 16:48:43 -0700 | [diff] [blame] | 160 | // Relies on collectVariables having been called. |
| 161 | bool isVaryingDefined(const char *varyingName); |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 162 | |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 163 | const ArrayBoundsClamper &getArrayBoundsClamper() const; |
shannon.woods@transgaming.com | 1d432bb | 2013-01-25 21:57:28 +0000 | [diff] [blame] | 164 | ShArrayIndexClampingStrategy getArrayIndexClampingStrategy() const; |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 165 | const BuiltInFunctionEmulator &getBuiltInFunctionEmulator() const; |
zmo@google.com | 32e9731 | 2011-08-24 01:03:11 +0000 | [diff] [blame] | 166 | |
Kenneth Russell | bccc65d | 2016-07-19 16:48:43 -0700 | [diff] [blame] | 167 | virtual bool shouldFlattenPragmaStdglInvariantAll() = 0; |
Corentin Wallez | 1df1602 | 2016-10-27 08:16:56 -0400 | [diff] [blame] | 168 | virtual bool shouldCollectVariables(ShCompileOptions compileOptions); |
Kenneth Russell | bccc65d | 2016-07-19 16:48:43 -0700 | [diff] [blame] | 169 | |
Corentin Wallez | 1df1602 | 2016-10-27 08:16:56 -0400 | [diff] [blame] | 170 | bool wereVariablesCollected() const; |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 171 | std::vector<sh::Attribute> mAttributes; |
| 172 | std::vector<sh::OutputVariable> mOutputVariables; |
| 173 | std::vector<sh::Uniform> mUniforms; |
| 174 | std::vector<sh::Varying> mInputVaryings; |
| 175 | std::vector<sh::Varying> mOutputVaryings; |
| 176 | std::vector<sh::InterfaceBlock> mInterfaceBlocks; |
| 177 | std::vector<sh::InterfaceBlock> mUniformBlocks; |
| 178 | std::vector<sh::InterfaceBlock> mShaderStorageBlocks; |
| 179 | std::vector<sh::InterfaceBlock> mInBlocks; |
Olli Etuaho | 4dfe809 | 2015-08-21 17:44:35 +0300 | [diff] [blame] | 180 | |
Jamie Madill | a718c1e | 2014-07-02 15:31:22 -0400 | [diff] [blame] | 181 | private: |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 182 | // Initialize symbol-table with built-in symbols. |
| 183 | bool initBuiltInSymbolTable(const ShBuiltInResources &resources); |
| 184 | // Compute the string representation of the built-in resources |
| 185 | void setResourceString(); |
| 186 | // Return false if the call depth is exceeded. |
| 187 | bool checkCallDepth(); |
| 188 | // Insert statements to reference all members in unused uniform blocks with standard and shared |
| 189 | // layout. This is to work around a Mac driver that treats unused standard/shared |
| 190 | // uniform blocks as inactive. |
| 191 | void useAllMembersInUnusedStandardAndSharedBlocks(TIntermBlock *root); |
| 192 | // Insert statements to initialize output variables in the beginning of main(). |
| 193 | // This is to avoid undefined behaviors. |
| 194 | void initializeOutputVariables(TIntermBlock *root); |
| 195 | // Insert gl_Position = vec4(0,0,0,0) to the beginning of main(). |
| 196 | // It is to work around a Linux driver bug where missing this causes compile failure |
| 197 | // while spec says it is allowed. |
| 198 | // This function should only be applied to vertex shaders. |
| 199 | void initializeGLPosition(TIntermBlock *root); |
| 200 | // Return true if the maximum expression complexity is below the limit. |
| 201 | bool limitExpressionComplexity(TIntermBlock *root); |
Corentin Wallez | 71d147f | 2015-02-11 11:15:24 -0800 | [diff] [blame] | 202 | // Creates the function call DAG for further analysis, returning false if there is a recursion |
| 203 | bool initCallDag(TIntermNode *root); |
| 204 | // Return false if "main" doesn't exist |
| 205 | bool tagUsedFunctions(); |
| 206 | void internalTagUsedFunction(size_t index); |
| 207 | |
Jiajia Qin | 9b11ea4 | 2017-07-11 16:50:08 +0800 | [diff] [blame] | 208 | void collectInterfaceBlocks(); |
| 209 | |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 210 | bool mVariablesCollected; |
Corentin Wallez | 1df1602 | 2016-10-27 08:16:56 -0400 | [diff] [blame] | 211 | |
Olli Etuaho | b12040c | 2017-06-27 14:20:45 +0300 | [diff] [blame] | 212 | bool mGLPositionInitialized; |
| 213 | |
Corentin Wallez | a094a8a | 2015-04-07 11:53:06 -0700 | [diff] [blame] | 214 | // Removes unused function declarations and prototypes from the AST |
| 215 | class UnusedPredicate; |
Olli Etuaho | d10cf69 | 2017-11-02 11:06:14 +0200 | [diff] [blame] | 216 | void pruneUnusedFunctions(TIntermBlock *root); |
Corentin Wallez | a094a8a | 2015-04-07 11:53:06 -0700 | [diff] [blame] | 217 | |
Olli Etuaho | 6d40bbd | 2016-09-30 13:49:38 +0100 | [diff] [blame] | 218 | TIntermBlock *compileTreeImpl(const char *const shaderStrings[], |
| 219 | size_t numStrings, |
| 220 | const ShCompileOptions compileOptions); |
Olli Etuaho | a3a5cc6 | 2015-02-13 13:12:22 +0200 | [diff] [blame] | 221 | |
Olli Etuaho | d10cf69 | 2017-11-02 11:06:14 +0200 | [diff] [blame] | 222 | // Fetches and stores shader metadata that is not stored within the AST itself, such as shader |
| 223 | // version. |
| 224 | void setASTMetadata(const TParseContext &parseContext); |
| 225 | |
Jiawei Shao | e41df65 | 2018-02-09 14:31:39 +0800 | [diff] [blame] | 226 | // Check if shader version meets the requirement. |
| 227 | bool checkShaderVersion(TParseContext *parseContext); |
| 228 | |
Olli Etuaho | d10cf69 | 2017-11-02 11:06:14 +0200 | [diff] [blame] | 229 | // Does checks that need to be run after parsing is complete and returns true if they pass. |
| 230 | bool checkAndSimplifyAST(TIntermBlock *root, |
| 231 | const TParseContext &parseContext, |
| 232 | ShCompileOptions compileOptions); |
| 233 | |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 234 | sh::GLenum mShaderType; |
| 235 | ShShaderSpec mShaderSpec; |
| 236 | ShShaderOutput mOutputType; |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 237 | |
Corentin Wallez | 71d147f | 2015-02-11 11:15:24 -0800 | [diff] [blame] | 238 | struct FunctionMetadata |
| 239 | { |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 240 | FunctionMetadata() : used(false) {} |
Corentin Wallez | 71d147f | 2015-02-11 11:15:24 -0800 | [diff] [blame] | 241 | bool used; |
| 242 | }; |
| 243 | |
| 244 | CallDAG mCallDag; |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 245 | std::vector<FunctionMetadata> mFunctionMetadata; |
Corentin Wallez | 71d147f | 2015-02-11 11:15:24 -0800 | [diff] [blame] | 246 | |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 247 | ShBuiltInResources mResources; |
| 248 | std::string mBuiltInResourcesString; |
shannon.woods%transgaming.com@gtempaccount.com | 18b4c4b | 2013-04-13 03:31:40 +0000 | [diff] [blame] | 249 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 250 | // Built-in symbol table for the given language, spec, and resources. |
| 251 | // It is preserved from compile-to-compile. |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 252 | TSymbolTable mSymbolTable; |
alokp@chromium.org | ad771eb | 2010-09-07 17:36:23 +0000 | [diff] [blame] | 253 | // Built-in extensions with default behavior. |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 254 | TExtensionBehavior mExtensionBehavior; |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 255 | |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 256 | ArrayBoundsClamper mArrayBoundsClamper; |
| 257 | BuiltInFunctionEmulator mBuiltInFunctionEmulator; |
zmo@google.com | 32e9731 | 2011-08-24 01:03:11 +0000 | [diff] [blame] | 258 | |
alokp@chromium.org | 07620a5 | 2010-09-23 17:53:56 +0000 | [diff] [blame] | 259 | // Results of compilation. |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 260 | int mShaderVersion; |
| 261 | TInfoSink mInfoSink; // Output sink. |
Olli Etuaho | 77ba408 | 2016-12-16 12:01:18 +0000 | [diff] [blame] | 262 | TDiagnostics mDiagnostics; |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 263 | const char *mSourcePath; // Path of source file or NULL |
zmo@google.com | 24c08c4 | 2011-05-27 17:40:48 +0000 | [diff] [blame] | 264 | |
Martin Radev | 802abe0 | 2016-08-04 17:48:32 +0300 | [diff] [blame] | 265 | // compute shader local group size |
| 266 | bool mComputeShaderLocalSizeDeclared; |
Martin Radev | 4c4c8e7 | 2016-08-04 12:25:34 +0300 | [diff] [blame] | 267 | sh::WorkGroupSize mComputeShaderLocalSize; |
Martin Radev | 802abe0 | 2016-08-04 17:48:32 +0300 | [diff] [blame] | 268 | |
Olli Etuaho | 09b04a2 | 2016-12-15 13:30:26 +0000 | [diff] [blame] | 269 | // GL_OVR_multiview num_views. |
| 270 | int mNumViews; |
| 271 | |
Shao | b5cc119 | 2017-07-06 10:47:20 +0800 | [diff] [blame] | 272 | // geometry shader parameters. |
| 273 | int mGeometryShaderMaxVertices; |
| 274 | int mGeometryShaderInvocations; |
| 275 | TLayoutPrimitiveType mGeometryShaderInputPrimitiveType; |
| 276 | TLayoutPrimitiveType mGeometryShaderOutputPrimitiveType; |
| 277 | |
daniel@transgaming.com | c23f461 | 2012-11-28 19:42:57 +0000 | [diff] [blame] | 278 | // name hashing. |
Olli Etuaho | 6f591c9 | 2018-09-21 11:20:47 +0300 | [diff] [blame] | 279 | NameMap mNameMap; |
Zhenyao Mo | 94ac7b7 | 2014-10-15 18:22:08 -0700 | [diff] [blame] | 280 | |
| 281 | TPragma mPragma; |
Shahbaz Youssefi | 91d469a | 2018-08-27 10:47:25 -0400 | [diff] [blame] | 282 | |
| 283 | // Track what should be validated given passes currently applied. |
| 284 | ValidateASTOptions mValidateASTOptions; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 285 | }; |
| 286 | |
| 287 | // |
| 288 | // This is the interface between the machine independent code |
| 289 | // and the machine dependent code. |
| 290 | // |
| 291 | // The machine dependent code should derive from the classes |
Jamie Madill | d4a3a31 | 2014-06-25 16:04:56 -0400 | [diff] [blame] | 292 | // above. Then Construct*() and Delete*() will create and |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 293 | // destroy the machine dependent objects, which contain the |
| 294 | // above machine independent information. |
| 295 | // |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 296 | TCompiler *ConstructCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output); |
| 297 | void DeleteCompiler(TCompiler *); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 298 | |
Jamie Madill | acb4b81 | 2016-11-07 13:50:29 -0500 | [diff] [blame] | 299 | } // namespace sh |
| 300 | |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 301 | #endif // COMPILER_TRANSLATOR_COMPILER_H_ |