18template<
typename From,
typename To, To (*ConversionF)(const From &)>
23 static const std::string conversion_name = from_type.
name() +
" to " + to_type.
name();
25 static auto multi_function = mf::build::SI1_SO<From, To>(
26 conversion_name.c_str(),
29 [](
const From &a) { return ConversionF(a); },
30 mf::build::exec_presets::AllSpanOrSingle());
31 static auto convert_single_to_initialized = [](
const void *src,
void *dst) {
32 *(To *)dst = ConversionF(*(
const From *)src);
34 static auto convert_single_to_uninitialized = [](
const void *src,
void *dst) {
35 new (dst) To(ConversionF(*(
const From *)src));
37 conversions.
add(mf::DataType::ForSingle<From>(),
38 mf::DataType::ForSingle<To>(),
40 convert_single_to_initialized,
41 convert_single_to_uninitialized);
67 a,
float(std::numeric_limits<int8_t>::min()),
float(std::numeric_limits<int8_t>::max()));
84 return float3(a.x, a.y, 0.0f);
88 return (a.x + a.y) / 2.0f;
92 return int32_t((a.x + a.y) / 2.0f);
96 return int2(a.x, a.y);
125 return (a.x + a.y + a.z) / 3.0f;
129 return int((a.x + a.y + a.z) / 3.0f);
133 return int2(a.x, a.y);
155 a,
int(std::numeric_limits<int8_t>::min()),
int(std::numeric_limits<int8_t>::max()));
204 return float3(
float(a.x),
float(a.y), 0.0f);
300 return int2(a.r, a.g);
312 return float3(a.r, a.g, a.b);
321 return a.
r > 0 || a.g > 0 || a.b > 0;
333 return int2(a.r, a.g);
470 const void *from_value,
471 void *to_value)
const
473 if (from_type == to_type) {
491 params.add_readonly_single_input(from);
492 params.add_uninitialized_single_output(to);
529 :
GVArrayImpl(to_type, varray.size()), varray_(std::move(varray)), from_type_(varray_.type())
535 void get(
const int64_t index,
void *r_value)
const override
538 varray_.
get(index, buffer);
543 void get_to_uninitialized(
const int64_t index,
void *r_value)
const override
546 varray_.
get(index, buffer);
551 void materialize(
const IndexMask &mask,
void *dst)
const override
554 this->materialize_to_uninitialized(mask, dst);
557 void materialize_to_uninitialized(
const IndexMask &mask,
void *dst)
const override
562 {this->type(), dst, mask.min_array_size()});
578 varray_(std::move(varray)),
579 from_type_(varray_.type())
586 void get(
const int64_t index,
void *r_value)
const override
589 varray_.
get(index, buffer);
594 void get_to_uninitialized(
const int64_t index,
void *r_value)
const override
597 varray_.
get(index, buffer);
602 void set_by_move(
const int64_t index,
void *value)
override
609 void materialize(
const IndexMask &mask,
void *dst)
const override
612 this->materialize_to_uninitialized(mask, dst);
615 void materialize_to_uninitialized(
const IndexMask &mask,
void *dst)
const override
620 {this->type(), dst, mask.min_array_size()});
627 if (from_type == to_type) {
640 if (from_type == to_type) {
647 std::move(varray), to_type, *
this);
652 const CPPType &from_type = field.cpp_type();
653 if (from_type == to_type) {
660 mf::DataType::ForSingle(from_type), mf::DataType::ForSingle(to_type));
#define BUFFER_FOR_CPP_TYPE_VALUE(type, variable_name)
MINLINE float rgb_to_grayscale(const float rgb[3])
void destruct_n(void *ptr, int64_t n) const
StringRefNull name() const
static const CPPType & get()
void copy_construct(const void *src, void *dst) const
void destruct(void *ptr) const
ColorSceneLinearByteEncoded4b< Alpha > encode() const
const CPPType & type() const
const CPPType & type() const
const CPPType & type() const
void get(int64_t index, void *r_value) const
static GVArray For(Args &&...args)
static GVArray ForSpan(GSpan span)
static GVMutableArray For(Args &&...args)
void set_by_relocate(int64_t index, void *value)
void convert_to_uninitialized(const CPPType &from_type, const CPPType &to_type, const void *from_value, void *to_value) const
void add(mf::DataType from_type, mf::DataType to_type, const mf::MultiFunction &fn, void(*convert_single_to_initialized)(const void *src, void *dst), void(*convert_single_to_uninitialized)(const void *src, void *dst))
void convert_to_initialized_n(GSpan from_span, GMutableSpan to_span) const
const ConversionFunctions * get_conversion_functions(mf::DataType from, mf::DataType to) const
bool is_convertible(const CPPType &from_type, const CPPType &to_type) const
GVArray try_convert(GVArray varray, const CPPType &to_type) const
const mf::MultiFunction * get_conversion_multi_function(mf::DataType from, mf::DataType to) const
GVArray_For_ConvertedGVArray(GVArray varray, const CPPType &to_type, const DataTypeConversions &conversions)
GVMutableArray_For_ConvertedGVMutableArray(GVMutableArray varray, const CPPType &to_type, const DataTypeConversions &conversions)
static std::shared_ptr< FieldOperation > Create(std::shared_ptr< const mf::MultiFunction > function, Vector< GField > inputs={})
static DataType ForSingle()
void call_auto(const IndexMask &mask, Params params, Context context) const
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
static int2 bool_to_int2(const bool &a)
static float3 quaternion_to_float3(const math::Quaternion &a)
static float3 color_to_float3(const ColorGeometry4f &a)
static float bool_to_float(const bool &a)
static int2 int_to_int2(const int32_t &a)
static ColorGeometry4b float_to_byte_color(const float &a)
static ColorGeometry4f float_to_color(const float &a)
static ColorGeometry4f byte_color_to_color(const ColorGeometry4b &a)
static int8_t float_to_int8(const float &a)
static float color_to_float(const ColorGeometry4f &a)
static int2 int8_to_int2(const int8_t &a)
static float2 float_to_float2(const float &a)
static float int2_to_float(const int2 &a)
static ColorGeometry4b int_to_byte_color(const int32_t &a)
static int2 float_to_int2(const float &a)
static float2 int2_to_float2(const int2 &a)
static bool float_to_bool(const float &a)
static void add_implicit_conversion(DataTypeConversions &conversions)
static int8_t int2_to_int8(const int2 &a)
static bool int2_to_bool(const int2 &a)
static int8_t float2_to_int8(const float2 &a)
static ColorGeometry4b int2_to_byte_color(const int2 &a)
const DataTypeConversions & get_implicit_type_conversions()
static float float3_to_float(const float3 &a)
static float3 float2_to_float3(const float2 &a)
static float float2_to_float(const float2 &a)
static math::Quaternion float_to_quaternion(const float &a)
static float2 bool_to_float2(const bool &a)
static int8_t bool_to_int8(const bool &a)
static ColorGeometry4b float3_to_byte_color(const float3 &a)
static float3 int8_to_float3(const int8_t &a)
static int32_t color_to_int(const ColorGeometry4f &a)
static float3 float_to_float3(const float &a)
static ColorGeometry4f float3_to_color(const float3 &a)
static int2 byte_color_to_int2(const ColorGeometry4b &a)
static int2 float3_to_int2(const float3 &a)
static int float2_to_int(const float2 &a)
static bool byte_color_to_bool(const ColorGeometry4b &a)
static bool float2_to_bool(const float2 &a)
static bool color_to_bool(const ColorGeometry4f &a)
static ColorGeometry4f float2_to_color(const float2 &a)
static float2 int_to_float2(const int32_t &a)
static float int8_to_float(const int8_t &a)
static int2 color_to_int2(const ColorGeometry4f &a)
static DataTypeConversions create_implicit_conversions()
static bool float3_to_bool(const float3 &a)
static float2 int8_to_float2(const int8_t &a)
static bool int8_to_bool(const int8_t &a)
static float4x4 quaternion_to_float4x4(const math::Quaternion &a)
static int int2_to_int(const int2 &a)
static float3 int_to_float3(const int32_t &a)
static float byte_color_to_float(const ColorGeometry4b &a)
static float3 int2_to_float3(const int2 &a)
static ColorGeometry4b float2_to_byte_color(const float2 &a)
static int32_t byte_color_to_int(const ColorGeometry4b &a)
static int32_t bool_to_int(const bool &a)
static int float3_to_int(const float3 &a)
static float int_to_float(const int32_t &a)
static math::Quaternion float3_to_quaternion(const float3 &a)
static ColorGeometry4f int_to_color(const int32_t &a)
static ColorGeometry4b bool_to_byte_color(const bool &a)
static ColorGeometry4f int2_to_color(const int2 &a)
static int32_t float_to_int(const float &a)
static bool int_to_bool(const int32_t &a)
static math::Quaternion float4x4_to_quaternion(const float4x4 &a)
static ColorGeometry4f int8_to_color(const int8_t &a)
static int8_t byte_color_to_int8(const ColorGeometry4b &a)
static float2 float3_to_float2(const float3 &a)
static int8_t int_to_int8(const int32_t &a)
static float2 byte_color_to_float2(const ColorGeometry4b &a)
static int2 float2_to_int2(const float2 &a)
static int8_t float3_to_int8(const float3 &a)
static ColorGeometry4b int8_to_byte_color(const int8_t &a)
static ColorGeometry4b color_to_byte_color(const ColorGeometry4f &a)
static float2 color_to_float2(const ColorGeometry4f &a)
static int int8_to_int(const int8_t &a)
static int8_t color_to_int8(const ColorGeometry4f &a)
static void call_convert_to_uninitialized_fn(const GVArray &from, const mf::MultiFunction &fn, const IndexMask &mask, GMutableSpan to)
static ColorGeometry4f bool_to_color(const bool &a)
static float3 byte_color_to_float3(const ColorGeometry4b &a)
static float3 bool_to_float3(const bool &a)
QuaternionBase< T > to_quaternion(const AxisAngleBase< T, AngleT > &axis_angle)
T midpoint(const T &a, const T &b)
QuaternionBase< T > normalized_to_quaternion_safe(const MatBase< T, 3, 3 > &mat)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
MatT from_rotation(const RotationT &rotation)
Euler3Base< T > to_euler(const AxisAngleBase< T, AngleT > &axis_angle, EulerOrder order)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
MatBase< float, 3, 3 > float3x3
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
const mf::MultiFunction * multi_function
void(* convert_single_to_uninitialized)(const void *src, void *dst)
void(* convert_single_to_initialized)(const void *src, void *dst)