Blender  V2.93
svm_math.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2013 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 ccl_device void svm_node_math(KernelGlobals *kg,
20  ShaderData *sd,
21  float *stack,
22  uint type,
23  uint inputs_stack_offsets,
24  uint result_stack_offset,
25  int *offset)
26 {
27  uint a_stack_offset, b_stack_offset, c_stack_offset;
28  svm_unpack_node_uchar3(inputs_stack_offsets, &a_stack_offset, &b_stack_offset, &c_stack_offset);
29 
30  float a = stack_load_float(stack, a_stack_offset);
31  float b = stack_load_float(stack, b_stack_offset);
32  float c = stack_load_float(stack, c_stack_offset);
33  float result = svm_math((NodeMathType)type, a, b, c);
34 
35  stack_store_float(stack, result_stack_offset, result);
36 }
37 
38 ccl_device void svm_node_vector_math(KernelGlobals *kg,
39  ShaderData *sd,
40  float *stack,
41  uint type,
42  uint inputs_stack_offsets,
43  uint outputs_stack_offsets,
44  int *offset)
45 {
46  uint value_stack_offset, vector_stack_offset;
47  uint a_stack_offset, b_stack_offset, param1_stack_offset;
49  inputs_stack_offsets, &a_stack_offset, &b_stack_offset, &param1_stack_offset);
50  svm_unpack_node_uchar2(outputs_stack_offsets, &value_stack_offset, &vector_stack_offset);
51 
52  float3 a = stack_load_float3(stack, a_stack_offset);
53  float3 b = stack_load_float3(stack, b_stack_offset);
54  float3 c = make_float3(0.0f, 0.0f, 0.0f);
55  float param1 = stack_load_float(stack, param1_stack_offset);
56 
57  float value;
58  float3 vector;
59 
60  /* 3 Vector Operators */
62  uint4 extra_node = read_node(kg, offset);
63  c = stack_load_float3(stack, extra_node.x);
64  }
65 
66  svm_vector_math(&value, &vector, (NodeVectorMathType)type, a, b, c, param1);
67 
68  if (stack_valid(value_stack_offset))
69  stack_store_float(stack, value_stack_offset, value);
70  if (stack_valid(vector_stack_offset))
71  stack_store_float3(stack, vector_stack_offset, vector);
72 }
73 
unsigned int uint
Definition: BLI_sys_types.h:83
@ NODE_VECTOR_MATH_WRAP
@ NODE_VECTOR_MATH_FACEFORWARD
_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
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(float *stack, uint a)
ccl_device_inline uint4 read_node(KernelGlobals *kg, int *offset)
ccl_device_inline float stack_load_float(float *stack, uint a)
ccl_device_forceinline void svm_unpack_node_uchar3(uint i, uint *x, uint *y, uint *z)
ccl_device_inline void stack_store_float3(float *stack, uint a, float3 f)
ccl_device_inline void stack_store_float(float *stack, uint a, float f)
ccl_device_forceinline void svm_unpack_node_uchar2(uint i, uint *x, uint *y)
ccl_device_inline bool stack_valid(uint a)
#define ccl_device
#define CCL_NAMESPACE_END
#define make_float3(x, y, z)
ShaderData
static unsigned c
Definition: RandGen.cpp:97
static unsigned a[3]
Definition: RandGen.cpp:92
std::vector< ElementType, Eigen::aligned_allocator< ElementType > > vector
Definition: vector.h:39
CCL_NAMESPACE_BEGIN ccl_device void svm_node_math(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint inputs_stack_offsets, uint result_stack_offset, int *offset)
Definition: svm_math.h:19
ccl_device void svm_node_vector_math(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint inputs_stack_offsets, uint outputs_stack_offsets, int *offset)
Definition: svm_math.h:38
CCL_NAMESPACE_BEGIN ccl_device void svm_vector_math(float *value, float3 *vector, NodeVectorMathType type, float3 a, float3 b, float3 c, float param1)
Definition: svm_math_util.h:19
ccl_device float svm_math(NodeMathType type, float a, float b, float c)
NodeMathType
Definition: svm_types.h:271
NodeVectorMathType
Definition: svm_types.h:314