xref: /aosp_15_r20/external/angle/src/compiler/translator/tree_ops/hlsl/ExpandIntegerPowExpressions.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1 //
2 // Copyright 2016 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 // This mutating tree traversal works around a bug in the HLSL compiler optimizer with "pow" that
7 // manifests under the following conditions:
8 //
9 // - If pow() has a literal exponent value
10 // - ... and this value is integer or within 10e-6 of an integer
11 // - ... and it is in {-4, -3, -2, 2, 3, 4, 5, 6, 7, 8}
12 //
13 // The workaround is to replace the pow with a series of multiplies.
14 // See http://anglebug.com/40096900
15 
16 #ifndef COMPILER_TRANSLATOR_TREEOPS_HLSL_EXPANDINTEGERPOWEXPRESSIONS_H_
17 #define COMPILER_TRANSLATOR_TREEOPS_HLSL_EXPANDINTEGERPOWEXPRESSIONS_H_
18 
19 #include "common/angleutils.h"
20 
21 namespace sh
22 {
23 
24 class TCompiler;
25 class TIntermNode;
26 class TSymbolTable;
27 
28 [[nodiscard]] bool ExpandIntegerPowExpressions(TCompiler *compiler,
29                                                TIntermNode *root,
30                                                TSymbolTable *symbolTable);
31 
32 }  // namespace sh
33 
34 #endif  // COMPILER_TRANSLATOR_TREEOPS_HLSL_EXPANDINTEGERPOWEXPRESSIONS_H_
35