| 1 | // |
| 2 | // Copyright 2020 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | // ReplaceClipCullDistanceVariable.h: Find any references to gl_ClipDistance or gl_CullDistance and |
| 7 | // replace it with ANGLEClipDistance or ANGLECullDistance. |
| 8 | // |
| 9 | |
| 10 | #ifndef COMPILER_TRANSLATOR_TREEUTIL_REPLACECLIPCULLDISTANCEVARIABLE_H_ |
| 11 | #define COMPILER_TRANSLATOR_TREEUTIL_REPLACECLIPCULLDISTANCEVARIABLE_H_ |
| 12 | |
| 13 | #include "GLSLANG/ShaderLang.h" |
| 14 | #include "common/angleutils.h" |
| 15 | |
| 16 | namespace sh |
| 17 | { |
| 18 | |
| 19 | struct InterfaceBlock; |
| 20 | class TCompiler; |
| 21 | class TIntermBlock; |
| 22 | class TSymbolTable; |
| 23 | class TIntermTyped; |
| 24 | |
| 25 | // Replace every gl_ClipDistance assignment with assignment to "ANGLEClipDistance", |
| 26 | // then at the end of shader re-assign the values of this global variable to gl_ClipDistance. |
| 27 | // This to solve some complex usages such as user passing gl_ClipDistance as output reference |
| 28 | // to a function. |
| 29 | // Furthermore, at the end shader, some disabled gl_ClipDistance[i] can be skipped from the |
| 30 | // assignment. |
| 31 | [[nodiscard]] bool ReplaceClipDistanceAssignments(TCompiler *compiler, |
| 32 | TIntermBlock *root, |
| 33 | TSymbolTable *symbolTable, |
| 34 | const GLenum shaderType, |
| 35 | const TIntermTyped *clipDistanceEnableFlags); |
| 36 | |
| 37 | [[nodiscard]] bool ReplaceCullDistanceAssignments(TCompiler *compiler, |
| 38 | TIntermBlock *root, |
| 39 | TSymbolTable *symbolTable, |
| 40 | const GLenum shaderType); |
| 41 | |
| 42 | [[nodiscard]] bool ZeroDisabledClipDistanceAssignments(TCompiler *compiler, |
| 43 | TIntermBlock *root, |
| 44 | TSymbolTable *symbolTable, |
| 45 | const GLenum shaderType, |
| 46 | const TIntermTyped *clipDistanceEnableFlags); |
| 47 | } // namespace sh |
| 48 | |
| 49 | #endif |
| 50 | |