24template<
typename From,
typename To, To (*ConversionF)(const From &)>
29 static const std::string conversion_name = from_type.
name() +
" to " +
to_type.name();
31 static auto multi_function = mf::build::SI1_SO<From, To>(
32 conversion_name.c_str(),
35 [](
const From &a) { return ConversionF(a); },
36 mf::build::exec_presets::AllSpanOrSingle());
37 static auto convert_single_to_initialized = [](
const void *src,
void *dst) {
38 *
static_cast<To *
>(dst) = ConversionF(*
static_cast<const From *
>(src));
40 static auto convert_single_to_uninitialized = [](
const void *src,
void *dst) {
41 new (dst) To(ConversionF(*
static_cast<const From *
>(src)));
43 conversions.
add(mf::DataType::ForSingle<From>(),
44 mf::DataType::ForSingle<To>(),
46 convert_single_to_initialized,
47 convert_single_to_uninitialized);
85 a,
float(std::numeric_limits<int8_t>::min()),
float(std::numeric_limits<int8_t>::max()));
102 return float3(a.x, a.y, 0.0f);
106 return float4(a.x, a.y, 0.0f, 0.0f);
110 return (a.x + a.y) / 2.0f;
114 return int32_t((a.x + a.y) / 2.0f);
122 return int2(a.x, a.y);
126 return int3(a.x, a.y, 0);
159 return (a.x + a.y + a.z) / 3.0f;
163 return int((a.x + a.y + a.z) / 3.0f);
171 return int2(a.x, a.y);
175 return int3(a.x, a.y, a.z);
208 return (a.x + a.y + a.z + a.w) / 4.0f;
212 return int((a.x + a.y + a.z + a.w) / 4.0f);
220 return int2(a.x, a.y);
224 return int3(a.x, a.y, a.z);
254 a,
int(std::numeric_limits<int8_t>::min()),
int(std::numeric_limits<int8_t>::max()));
307 return int2(a.x, a.y);
311 return int3(a.x, a.y, 0);
323 return float3(
float(a.x),
float(a.y), 0.0f);
327 return float4(
float(a.x),
float(a.y), 0.0f, 0.0f);
368 return float3(
float(a.x),
float(a.y), 0.0f);
372 return float4(
float(a.x),
float(a.y), 0.0f, 0.0f);
413 return float3(
float(a.x),
float(a.y),
float(a.z));
417 return float4(
float(a.x),
float(a.y),
float(a.z), 0.0f);
565 return a.
r > 0 || a.
g > 0 || a.
b > 0;
800 const void *from_value,
801 void *to_value)
const
809 DataType::ForSingle(from_type), DataType::ForSingle(
to_type));
816 const mf::MultiFunction &
fn,
820 mf::ParamsBuilder params{
fn, &
mask};
821 params.add_readonly_single_input(from);
822 params.add_uninitialized_single_output(to);
823 mf::ContextBuilder context;
824 fn.call_auto(
mask, params, context);
828 const mf::MultiFunction &
fn,
865 void get(
const int64_t index,
void *r_value)
const override
873 void get_to_uninitialized(
const int64_t index,
void *r_value)
const override
881 void materialize(
const IndexMask &
mask,
883 const bool dst_is_uninitialized)
const override
885 if (!dst_is_uninitialized) {
889 *old_to_new_conversions_.multi_function,
891 {this->type(), dst, mask.min_array_size()});
894 void materialize_compressed(
const IndexMask &mask,
896 const bool dst_is_uninitialized)
const override
898 const CPPType &dst_type = this->
type();
899 mask.foreach_range([&](
const IndexRange range,
const int64_t segment_pos) {
900 void *segment_dst =
POINTER_OFFSET(dst, dst_type.size * segment_pos);
901 if (!dst_is_uninitialized) {
905 *old_to_new_conversions_.multi_function,
907 {dst_type, segment_dst, range.size()});
924 varray_(std::move(varray)),
925 from_type_(varray_.
type())
932 void get(
const int64_t index,
void *r_value)
const override
940 void get_to_uninitialized(
const int64_t index,
void *r_value)
const override
948 void set_by_move(
const int64_t index,
void *value)
override
955 void materialize(
const IndexMask &mask,
957 const bool dst_is_uninitialized)
const override
959 if (!dst_is_uninitialized) {
963 *old_to_new_conversions_.multi_function,
965 {this->type(), dst, mask.min_array_size()});
992 std::move(varray),
to_type, *
this);
1003 return std::nullopt;
1006 mf::DataType::ForSingle(from_type), mf::DataType::ForSingle(
to_type));
#define BUFFER_FOR_CPP_TYPE_VALUE(type, variable_name)
#define POINTER_OFFSET(v, ofs)
static const CPPType & get()
void destruct_n(void *ptr, int64_t n) const
StringRefNull name() const
void copy_construct(const void *src, void *dst) const
void destruct(void *ptr) const
const CPPType & type() const
const CPPType & type() const
const CPPType & type() const
void get(int64_t index, void *r_value) const
GVArrayImpl(const CPPType &type, int64_t size)
const CPPType & type() const
static GVArray from(Args &&...args)
static GVArray from_span(GSpan span)
GVMutableArrayImpl(const CPPType &type, int64_t size)
static GVMutableArray from(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 FieldOperationPtr from(std::shared_ptr< const mf::MultiFunction > fn, Vector< GField > inputs)
const CPPType & cpp_type() const
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
static float4 float_to_float4(const float &a)
static ColorGeometry4f int3_to_color(const int3 &a)
static int2 bool_to_int2(const bool &a)
static float3 quaternion_to_float3(const math::Quaternion &a)
static float2 short2_to_float2(const short2 &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 short2 float_to_short2(const float &a)
static short2 bool_to_short2(const bool &a)
static short2 float4_to_short2(const float4 &a)
static ColorGeometry4b float_to_byte_color(const float &a)
static ColorGeometry4f float_to_color(const float &a)
static int short2_to_int(const short2 &a)
static ColorGeometry4f byte_color_to_color(const ColorGeometry4b &a)
static int8_t float_to_int8(const float &a)
static float2 float4_to_float2(const float4 &a)
static float color_to_float(const ColorGeometry4f &a)
static ColorGeometry4b float4_to_byte_color(const float4 &a)
static int2 int8_to_int2(const int8_t &a)
static int float4_to_int(const float4 &a)
static float2 float_to_float2(const float &a)
static float int2_to_float(const int2 &a)
static int3 float2_to_int3(const float2 &a)
static ColorGeometry4b int_to_byte_color(const int32_t &a)
static int2 float_to_int2(const float &a)
static int3 short2_to_int3(const short2 &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 ColorGeometry4f float4_to_color(const float4 &a)
static float4 float2_to_float4(const float2 &a)
static float4 int3_to_float4(const int3 &a)
static int8_t float4_to_int8(const float4 &a)
static float4 float3_to_float4(const float3 &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 short2 int2_to_short2(const int2 &a)
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 float3 float4_to_float3(const float4 &a)
static math::Quaternion float_to_quaternion(const float &a)
static int3 int8_to_int3(const int8_t &a)
static float2 bool_to_float2(const bool &a)
static int8_t bool_to_int8(const bool &a)
static short2 color_to_short2(const ColorGeometry4f &a)
static ColorGeometry4b float3_to_byte_color(const float3 &a)
static float4 color_to_float4(const ColorGeometry4f &a)
static float short2_to_float(const short2 &a)
static float3 int8_to_float3(const int8_t &a)
static ColorGeometry4f short2_to_color(const short2 &a)
static int32_t color_to_int(const ColorGeometry4f &a)
static float3 float_to_float3(const float &a)
static float4 byte_color_to_float4(const ColorGeometry4b &a)
static ColorGeometry4f float3_to_color(const float3 &a)
static int2 byte_color_to_int2(const ColorGeometry4b &a)
static math::Quaternion float4_to_quaternion(const float4 &a)
static math::Quaternion float2_to_quaternion(const float2 &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 float3 short2_to_float3(const short2 &a)
static short2 int_to_short2(const int32_t &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 int3 int2_to_int3(const int2 &a)
static int2 color_to_int2(const ColorGeometry4f &a)
static bool short2_to_bool(const short2 &a)
static int3 float_to_int3(const float &a)
static short2 int8_to_short2(const int8_t &a)
static float4 bool_to_float4(const bool &a)
static DataTypeConversions create_implicit_conversions()
static bool float3_to_bool(const float3 &a)
static ColorGeometry4b short2_to_byte_color(const short2 &a)
static float4 int8_to_float4(const int8_t &a)
static int8_t int3_to_int8(const int3 &a)
static float4 int_to_float4(const int32_t &a)
static float2 int8_to_float2(const int8_t &a)
static float2 int3_to_float2(const int3 &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 float4_to_float(const float4 &a)
static bool int3_to_bool(const int3 &a)
static float4 short2_to_float4(const short2 &a)
static int3 float4_to_int3(const float4 &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 int3 float3_to_int3(const float3 &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 int2 short2_to_int2(const short2 &a)
static float int_to_float(const int32_t &a)
static short2 float3_to_short2(const float3 &a)
static math::Quaternion float3_to_quaternion(const float3 &a)
static int3 byte_color_to_int3(const ColorGeometry4b &a)
static int3 bool_to_int3(const bool &a)
static float2 quaternion_to_float2(const math::Quaternion &a)
static ColorGeometry4b int3_to_byte_color(const int3 &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 short2 byte_color_to_short2(const ColorGeometry4b &a)
static ColorGeometry4f int8_to_color(const int8_t &a)
static int8_t byte_color_to_int8(const ColorGeometry4b &a)
static bool float4_to_bool(const float4 &a)
static float int3_to_float(const int3 &a)
static float2 float3_to_float2(const float3 &a)
static int2 float4_to_int2(const float4 &a)
static short2 float2_to_short2(const float2 &a)
static float3 int3_to_float3(const int3 &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 short2 int3_to_short2(const int3 &a)
static ColorGeometry4b color_to_byte_color(const ColorGeometry4f &a)
static float2 color_to_float2(const ColorGeometry4f &a)
static int3 color_to_int3(const ColorGeometry4f &a)
static float4 quaternion_to_float4(const math::Quaternion &a)
static int int8_to_int(const int8_t &a)
static int8_t color_to_int8(const ColorGeometry4f &a)
static int3 int_to_int3(const int32_t &a)
static void call_convert_to_uninitialized_fn(const GVArray &from, const mf::MultiFunction &fn, const IndexMask &mask, GMutableSpan to)
static int int3_to_int(const int3 &a)
static int2 int3_to_int2(const int3 &a)
static ColorGeometry4f bool_to_color(const bool &a)
static int8_t short2_to_int8(const short2 &a)
static float3 byte_color_to_float3(const ColorGeometry4b &a)
static float4 int2_to_float4(const int2 &a)
static float3 bool_to_float3(const bool &a)
BLI_INLINE ColorSceneLinear4f< Alpha > decode(const ColorSceneLinearByteEncoded4b< Alpha > &color)
BLI_INLINE ColorSceneLinearByteEncoded4b< Alpha > encode(const ColorSceneLinear4f< Alpha > &color)
QuaternionBase< float > Quaternion
QuaternionBase< T > to_quaternion(const AxisAngleBase< T, AngleT > &axis_angle)
EulerXYZBase< float > EulerXYZ
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)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
MatBase< float, 3, 3 > float3x3
BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3])
VecBase< int16_t, 2 > short2
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
ColorSceneLinearByteEncoded4b< eAlpha::Premultiplied > ColorGeometry4b
void mask(PageMask &srt, TileMaps &tilemaps, const uint3 global_id, const uint local_tile_index)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
void(*) convert_single_to_initialized(const void *src, void *dst)
void(*) convert_single_to_uninitialized(const void *src, void *dst)