Blender V5.3
kernel/svm/math.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
9#include "kernel/svm/util.h"
10
12
15{
16 const float a = stack_load(stack, node.value1);
17 const float b = stack_load(stack, node.value2);
18 const float c = stack_load(stack, node.value3);
19 const float result = svm_math(node.math_type, a, b, c);
20
21 stack_store_float(stack, node.result_offset, result);
22}
23
24template<typename Float3Type>
27{
28 using FloatType = dual_scalar_t<Float3Type>;
29
30 const Float3Type a = stack_load<Float3Type>(stack, node.a);
31 const Float3Type b = stack_load<Float3Type>(stack, node.b);
32 const Float3Type c = stack_load<Float3Type>(stack, node.c);
33 const FloatType param1 = stack_load<FloatType>(stack, node.param1);
34
35 FloatType value = make_zero<FloatType>();
36 Float3Type vector = make_zero<Float3Type>();
37 svm_vector_math(&value, &vector, node.math_type, a, b, c, param1);
38
39 if (stack_valid(node.value_offset)) {
40 stack_store(stack, node.value_offset, value);
41 }
42 if (stack_valid(node.vector_offset)) {
43 stack_store(stack, node.vector_offset, vector);
44 }
45}
46
ccl_device_inline void stack_store_float(ccl_private float *stack, const uint a, const float f)
ccl_device_inline void stack_store(ccl_private float *stack, const uint a, const float f)
ccl_device_inline bool stack_valid(const uint a)
ccl_device_inline T stack_load(const ccl_private float *stack, const uint a)
#define ccl_restrict
#define ccl_private
#define ccl_global
#define ccl_device_noinline
#define CCL_NAMESPACE_END
ccl_device_noinline void svm_node_vector_math(ccl_private float *ccl_restrict stack, const ccl_global SVMNodeVectorMath &ccl_restrict node)
CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_math(ccl_private float *ccl_restrict stack, const ccl_global SVMNodeMath &ccl_restrict node)
ccl_device_inline T make_zero()
Definition math_dual.h:20
ccl_device float svm_math(NodeMathType type, const float a, float b, const float c)
Definition math_util.h:121
CCL_NAMESPACE_BEGIN ccl_device void svm_vector_math(ccl_private FloatType *value, ccl_private Float3Type *vector, NodeVectorMathType type, const Float3Type a, const Float3Type b, const Float3Type c, const FloatType param1)
Definition math_util.h:16
typename dual_scalar_type< T >::type dual_scalar_t
Definition types_dual.h:141