Blender  V3.3
constant_fold.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #ifndef __CONSTANT_FOLD_H__
5 #define __CONSTANT_FOLD_H__
6 
7 #include "kernel/svm/types.h"
8 #include "util/types.h"
9 
11 
12 class Scene;
13 class ShaderGraph;
14 class ShaderInput;
15 class ShaderNode;
16 class ShaderOutput;
17 
19  public:
21  ShaderNode *const node;
23 
25 
27 
28  bool all_inputs_constant() const;
29 
30  /* Constant folding helpers */
31  void make_constant(float value) const;
32  void make_constant(float3 value) const;
33  void make_constant_clamp(float value, bool clamp) const;
34  void make_constant_clamp(float3 value, bool clamp) const;
35  void make_zero() const;
36  void make_one() const;
37 
38  /* Bypass node, relinking to another output socket. */
39  void bypass(ShaderOutput *output) const;
40 
41  /* For closure nodes, discard node entirely or bypass to one of its inputs. */
42  void discard() const;
43  void bypass_or_discard(ShaderInput *input) const;
44 
45  /* Bypass or make constant, unless we can't due to clamp being true. */
46  bool try_bypass_or_make_constant(ShaderInput *input, bool clamp = false) const;
47 
48  /* Test if shader inputs of the current nodes have fixed values. */
49  bool is_zero(ShaderInput *input) const;
50  bool is_one(ShaderInput *input) const;
51 
52  /* Specific nodes. */
53  void fold_mix(NodeMix type, bool clamp) const;
54  void fold_math(NodeMathType type) const;
56  void fold_mapping(NodeMappingType type) const;
57 };
58 
60 
61 #endif /* __CONSTANT_FOLD_H__ */
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
void make_one() const
void make_constant_clamp(float value, bool clamp) const
void discard() const
void bypass(ShaderOutput *output) const
void bypass_or_discard(ShaderInput *input) const
void fold_mapping(NodeMappingType type) const
ShaderGraph *const graph
Definition: constant_fold.h:20
bool all_inputs_constant() const
ConstantFolder(ShaderGraph *graph, ShaderNode *node, ShaderOutput *output, Scene *scene)
bool try_bypass_or_make_constant(ShaderInput *input, bool clamp=false) const
void make_zero() const
bool is_zero(ShaderInput *input) const
bool is_one(ShaderInput *input) const
void fold_math(NodeMathType type) const
void make_constant(float value) const
ShaderOutput *const output
Definition: constant_fold.h:22
void fold_mix(NodeMix type, bool clamp) const
void fold_vector_math(NodeVectorMathType type) const
ShaderNode *const node
Definition: constant_fold.h:21
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
ccl_global KernelShaderEvalInput * input
NodeMathType
NodeMappingType
NodeVectorMathType
T clamp(const T &a, const T &min, const T &max)