52template<
typename Callback>
56 if (info ==
nullptr) {
60 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
61 static auto exec_preset_slow = mf::build::exec_presets::Materialized();
64 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
65 callback(exec_preset, math_function, *info);
71 return dispatch(exec_preset_slow, [](
float a) {
return expf(a); });
73 return dispatch(exec_preset_fast, [](
float a) {
return safe_sqrtf(a); });
77 return dispatch(exec_preset_fast, [](
float a) {
return fabs(a); });
79 return dispatch(exec_preset_fast, [](
float a) {
return (
float)
DEG2RAD(a); });
81 return dispatch(exec_preset_fast, [](
float a) {
return (
float)
RAD2DEG(a); });
83 return dispatch(exec_preset_fast, [](
float a) {
return compatible_signf(a); });
85 return dispatch(exec_preset_fast, [](
float a) {
return floorf(a + 0.5f); });
87 return dispatch(exec_preset_fast, [](
float a) {
return floorf(a); });
89 return dispatch(exec_preset_fast, [](
float a) {
return ceilf(a); });
91 return dispatch(exec_preset_fast, [](
float a) {
return a -
floorf(a); });
93 return dispatch(exec_preset_fast, [](
float a) {
return a >= 0.0f ?
floorf(a) :
ceilf(a); });
95 return dispatch(exec_preset_slow, [](
float a) {
return sinf(a); });
97 return dispatch(exec_preset_slow, [](
float a) {
return cosf(a); });
99 return dispatch(exec_preset_slow, [](
float a) {
return tanf(a); });
101 return dispatch(exec_preset_slow, [](
float a) {
return sinhf(a); });
103 return dispatch(exec_preset_slow, [](
float a) {
return coshf(a); });
105 return dispatch(exec_preset_slow, [](
float a) {
return tanhf(a); });
107 return dispatch(exec_preset_slow, [](
float a) {
return safe_asinf(a); });
109 return dispatch(exec_preset_slow, [](
float a) {
return safe_acosf(a); });
111 return dispatch(exec_preset_slow, [](
float a) {
return atanf(a); });
119template<
typename Callback>
123 if (info ==
nullptr) {
127 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
128 static auto exec_preset_slow = mf::build::exec_presets::Materialized();
131 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
132 callback(exec_preset, math_function, *info);
138 return dispatch(exec_preset_fast, [](
float a,
float b) {
return a +
b; });
140 return dispatch(exec_preset_fast, [](
float a,
float b) {
return a -
b; });
142 return dispatch(exec_preset_fast, [](
float a,
float b) {
return a *
b; });
144 return dispatch(exec_preset_fast, [](
float a,
float b) {
return safe_divide(a,
b); });
146 return dispatch(exec_preset_slow, [](
float a,
float b) {
return safe_powf(a,
b); });
148 return dispatch(exec_preset_slow, [](
float a,
float b) {
return safe_logf(a,
b); });
150 return dispatch(exec_preset_fast, [](
float a,
float b) {
return std::min(a,
b); });
152 return dispatch(exec_preset_fast, [](
float a,
float b) {
return std::max(a,
b); });
154 return dispatch(exec_preset_fast, [](
float a,
float b) {
return (
float)(a <
b); });
156 return dispatch(exec_preset_fast, [](
float a,
float b) {
return (
float)(a >
b); });
158 return dispatch(exec_preset_fast, [](
float a,
float b) {
return safe_modf(a,
b); });
160 return dispatch(exec_preset_fast, [](
float a,
float b) {
return safe_floored_modf(a,
b); });
162 return dispatch(exec_preset_fast,
165 return dispatch(exec_preset_slow, [](
float a,
float b) {
return atan2f(a,
b); });
167 return dispatch(exec_preset_fast, [](
float a,
float b) {
return pingpongf(a,
b); });
175template<
typename Callback>
179 if (info ==
nullptr) {
184 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
185 callback(exec_preset, math_function, *info);
191 return dispatch(mf::build::exec_presets::AllSpanOrSingle(),
192 [](
float a,
float b,
float c) {
return a *
b + c; });
194 return dispatch(mf::build::exec_presets::SomeSpanOrSingle<0, 1>(),
195 [](
float a,
float b,
float c) ->
float {
196 return ((a ==
b) || (
fabsf(a -
b) <=
fmaxf(c, FLT_EPSILON))) ? 1.0f : 0.0f;
199 return dispatch(mf::build::exec_presets::SomeSpanOrSingle<0, 1>(),
200 [](
float a,
float b,
float c) {
return smoothminf(a,
b, c); });
202 return dispatch(mf::build::exec_presets::SomeSpanOrSingle<0, 1>(),
203 [](
float a,
float b,
float c) {
return -
smoothminf(-a, -
b, c); });
205 return dispatch(mf::build::exec_presets::SomeSpanOrSingle<0>(),
206 [](
float a,
float b,
float c) {
return wrapf(a,
b, c); });
214template<
typename Callback>
221 if (info ==
nullptr) {
225 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
226 static auto exec_preset_slow = mf::build::exec_presets::Materialized();
229 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
230 callback(exec_preset, math_function, *info);
236 return dispatch(exec_preset_fast, [](
float3 a,
float3 b) {
return a +
b; });
238 return dispatch(exec_preset_fast, [](
float3 a,
float3 b) {
return a -
b; });
240 return dispatch(exec_preset_fast, [](
float3 a,
float3 b) {
return a *
b; });
244 return dispatch(exec_preset_fast,
249 return dispatch(exec_preset_fast,
252 return dispatch(exec_preset_fast,
273template<
typename Callback>
280 if (info ==
nullptr) {
284 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
287 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
288 callback(exec_preset, math_function, *info);
306template<
typename Callback>
313 if (info ==
nullptr) {
317 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
318 static auto exec_preset_slow = mf::build::exec_presets::Materialized();
321 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
322 callback(exec_preset, math_function, *info);
334 return dispatch(exec_preset_fast,
345template<
typename Callback>
352 if (info ==
nullptr) {
356 static auto exec_preset_slow = mf::build::exec_presets::Materialized();
359 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
360 callback(exec_preset, math_function, *info);
366 return dispatch(exec_preset_slow,
377template<
typename Callback>
384 if (info ==
nullptr) {
388 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
391 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
392 callback(exec_preset, math_function, *info);
408template<
typename Callback>
413 if (info ==
nullptr) {
417 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
420 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
421 callback(exec_preset, math_function, *info);
427 return dispatch(exec_preset_fast, [](
float3 a,
float b) {
return a *
b; });
437template<
typename Callback>
444 if (info ==
nullptr) {
448 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
449 static auto exec_preset_slow = mf::build::exec_presets::Materialized();
452 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
453 callback(exec_preset, math_function, *info);
462 return dispatch(exec_preset_fast, [](
float3 in) {
return floor(
in); });
464 return dispatch(exec_preset_fast, [](
float3 in) {
return ceil(
in); });
466 return dispatch(exec_preset_fast, [](
float3 in) {
return fract(
in); });
468 return dispatch(exec_preset_fast, [](
float3 in) {
return abs(
in); });
470 return dispatch(exec_preset_fast, [](
float3 in) {
return sign(
in); });
472 return dispatch(exec_preset_slow,
475 return dispatch(exec_preset_slow,
478 return dispatch(exec_preset_slow,
MINLINE float safe_sqrtf(float a)
MINLINE float safe_logf(float a, float base)
MINLINE float safe_acosf(float a)
MINLINE float safe_modf(float a, float b)
MINLINE float safe_powf(float base, float exponent)
MINLINE float safe_divide(float a, float b)
MINLINE float safe_asinf(float a)
MINLINE float safe_inverse_sqrtf(float a)
@ NODE_VECTOR_MATH_NORMALIZE
@ NODE_VECTOR_MATH_LENGTH
@ NODE_VECTOR_MATH_CROSS_PRODUCT
@ NODE_VECTOR_MATH_MODULO
@ NODE_VECTOR_MATH_COSINE
@ NODE_VECTOR_MATH_REFLECT
@ NODE_VECTOR_MATH_REFRACT
@ NODE_VECTOR_MATH_DOT_PRODUCT
@ NODE_VECTOR_MATH_ABSOLUTE
@ NODE_VECTOR_MATH_DIVIDE
@ NODE_VECTOR_MATH_TANGENT
@ NODE_VECTOR_MATH_DISTANCE
@ NODE_VECTOR_MATH_FRACTION
@ NODE_VECTOR_MATH_PROJECT
@ NODE_VECTOR_MATH_MULTIPLY
@ NODE_VECTOR_MATH_MAXIMUM
@ NODE_VECTOR_MATH_FACEFORWARD
@ NODE_VECTOR_MATH_SUBTRACT
@ NODE_VECTOR_MATH_MULTIPLY_ADD
@ NODE_VECTOR_MATH_MINIMUM
@ NODE_MATH_FLOORED_MODULO
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
dot(value.rgb, luminance_coefficients)") DEFINE_VALUE("REDUCE(lhs
VecBase< T, D > refract(VecOp< T, D >, VecOp< T, D >, float) RET
VecBase< T, D > reflect(VecOp< T, D >, VecOp< T, D >) RET
VecBase< float, D > normalize(VecOp< float, D >) RET
VecBase< T, D > faceforward(VecOp< T, D >, VecOp< T, D >, VecOp< T, D >) RET
VecBase< float, D > constexpr mod(VecOp< float, D >, VecOp< float, D >) RET
float distance(VecOp< float, D >, VecOp< float, D >) RET
MINLINE float smoothminf(float a, float b, float c)
MINLINE float pingpongf(float value, float scale)
MINLINE float compatible_signf(float f)
MINLINE float wrapf(float value, float max, float min)
MINLINE float safe_floored_modf(float a, float b)
ccl_device_inline float2 fabs(const float2 a)
VecBase< float, 3 > cross_high_precision(const VecBase< float, 3 > &a, const VecBase< float, 3 > &b)
void node_math_build_multi_function(NodeMultiFunctionBuilder &builder)
bool try_dispatch_float_math_fl_fl_to_fl(const int operation, Callback &&callback)
bool try_dispatch_float_math_fl3_fl3_to_fl3(const NodeVectorMathOperation operation, Callback &&callback)
bool try_dispatch_float_math_fl3_to_fl(const NodeVectorMathOperation operation, Callback &&callback)
const FloatMathOperationInfo * get_float3_math_operation_info(const int operation)
bool try_dispatch_float_math_fl3_fl3_to_fl(const NodeVectorMathOperation operation, Callback &&callback)
bool try_dispatch_float_math_fl_to_fl(const int operation, Callback &&callback)
const FloatMathOperationInfo * get_float_compare_operation_info(const int operation)
const FloatMathOperationInfo * get_float_math_operation_info(const int operation)
bool try_dispatch_float_math_fl3_fl_to_fl3(const NodeVectorMathOperation operation, Callback &&callback)
bool try_dispatch_float_math_fl3_fl3_fl_to_fl3(const NodeVectorMathOperation operation, Callback &&callback)
bool try_dispatch_float_math_fl3_to_fl3(const NodeVectorMathOperation operation, Callback &&callback)
bool try_dispatch_float_math_fl_fl_fl_to_fl(const int operation, Callback &&callback)
bool try_dispatch_float_math_fl3_fl3_fl3_to_fl3(const NodeVectorMathOperation operation, Callback &&callback)
VecBase< float, 3 > float3
vector project(vector v, vector v_proj)
StringRefNull shader_name
StringRefNull title_case_name
FloatMathOperationInfo()=delete
FloatMathOperationInfo(StringRefNull title_case_name, StringRefNull shader_name)