160 int reference_count_ = 1;
163 std::variant<std::monostate,
186 single_value_ = std::monostate{};
269 const bool from_pool =
true,
270 const std::optional<ResultStorageType> storage_type = std::nullopt);
302 const char *texture_name)
const;
434 template<
typename T,
bool CouldBeSingleValue = false>
T load_pixel(
const int2 &texel)
const;
437 template<
typename T,
bool CouldBeSingleValue = false>
440 const Extension &extension_mode_y)
const;
443 template<
typename T,
bool CouldBeSingleValue = false>
447 template<
typename T,
bool CouldBeSingleValue = false>
464 template<
typename T,
bool CouldBeSingleValue = false>
469 std::optional<float2x2> jacobian = std::nullopt)
const;
472 template<
typename T,
bool CouldBeSingleValue = false>
476 template<
typename T,
bool CouldBeSingleValue = false>
515 return sharing_info_;
526 BLI_assert(sharing_info_ && sharing_info_->is_mutable());
527 return GMutableSpan(cpu_data_.type(),
const_cast<void *
>(cpu_data_.data()), cpu_data_.size());
535 return std::get<T>(single_value_);
551 single_value_ = value;
554template<
typename T,
bool CouldBeSingleValue>
557 if constexpr (CouldBeSingleValue) {
583template<
typename T,
bool CouldBeSingleValue>
588 if constexpr (CouldBeSingleValue) {
599 const int x = wrap_coord(texel.x, domain_.data_size.x, wrap_mode_x);
600 const int y = wrap_coord(texel.y, domain_.data_size.y, wrap_mode_y);
601 if (
x < 0 ||
y < 0) {
607template<
typename T,
bool CouldBeSingleValue>
610 if constexpr (CouldBeSingleValue) {
620 return this->
cpu_data().
typed<
T>()[this->get_pixel_index(clamped_texel)];
623template<
typename T,
bool CouldBeSingleValue>
626 if constexpr (CouldBeSingleValue) {
635 if (texel.x < 0 || texel.y < 0 || texel.x >= domain_.data_size.x ||
636 texel.y >= domain_.data_size.y)
644template<
typename T,
bool CouldBeSingleValue>
673template<
typename T,
bool CouldBeSingleValue>
678 std::optional<float2x2> jacobian)
const
680 if constexpr (CouldBeSingleValue) {
686 const int2 size = domain_.data_size;
687 const float2 texel_coordinates = coordinates *
float2(size);
693 const float *buffer =
static_cast<const float *
>(this->
cpu_data().
data());
695 if constexpr (std::is_same_v<T, float>) {
702 switch (interpolation) {
708 sizeof(
T) /
sizeof(
float),
719 sizeof(
T) /
sizeof(
float),
720 texel_coordinates.x - 0.5f,
721 texel_coordinates.y - 0.5f,
730 sizeof(
T) /
sizeof(
float),
731 texel_coordinates.x - 0.5f,
732 texel_coordinates.y - 0.5f,
738 if (jacobian.has_value()) {
740 *
this, extension_mode_x, extension_mode_y};
759 sizeof(
T) /
sizeof(
float),
760 texel_coordinates.x - 0.5f,
761 texel_coordinates.y - 0.5f,
771 const int wrapped_x = wrap_coord(texel_coordinates.x, size.x, wrap_mode_x);
772 const int wrapped_y = wrap_coord(texel_coordinates.y, size.y, wrap_mode_y);
774 if (wrapped_x < 0 || wrapped_y < 0) {
781template<
typename T,
bool CouldBeSingleValue>
788template<
typename T,
bool CouldBeSingleValue>
#define BLI_assert_unreachable()
#define BLI_INLINE_METHOD
const void * default_value() const
MutableSpan< T > typed() const
const void * data() const
void decrement_reference_count(int count=1)
void share_data(const Result &source)
RealizationOptions & get_realization_options()
Result upload_to_gpu(const bool from_pool) const
T sample(const float2 &coordinates, const Interpolation &interpolation, const Extension &extension_mode_x, const Extension &extension_mode_y, std::optional< float2x2 > jacobian=std::nullopt) const
bool is_single_value() const
T sample_bilinear_extended(const float2 &coordinates) const
void unbind_as_texture_or_single_value(gpu::Texture *single_value_texture) const
const CPPType & get_cpp_type() const
void store_pixel(const int2 &texel, const T &pixel_value)
bool should_compute() const
int reference_count() const
void allocate_texture(const Domain domain, const bool from_pool=true, const std::optional< ResultStorageType > storage_type=std::nullopt)
static eGPUDataFormat gpu_data_format(const ResultType type)
int64_t size_in_bytes() const
void unbind_as_texture() const
int64_t channels_count() const
static gpu::TextureFormat gpu_texture_format(ResultType type, ResultPrecision precision)
Result download_to_cpu() const
static const char * type_name(const ResultType type)
bool is_allocated() const
void set_transformation(const float3x3 &transformation)
T load_pixel_zero(const int2 &texel) const
static bool is_single_value_only_type(ResultType type)
GPointer single_value() const
const ImplicitSharingPtr & sharing_info() const
eGPUDataFormat get_gpu_data_format() const
void set_single_value(const T &value)
gpu::Texture * gpu_texture() const
GMutableSpan cpu_data_for_write()
static ResultType type(gpu::TextureFormat format)
void bind_as_texture(gpu::Shader *shader, const char *texture_name) const
gpu::TextureFormat get_gpu_texture_format() const
T sample_bilinear_zero(const float2 &coordinates) const
T get_single_value_default() const
T load_pixel_extended(const int2 &texel) const
void set_precision(ResultPrecision precision)
void transform(const float3x3 &transformation)
static const CPPType & cpp_type(const ResultType type)
T load_pixel(const int2 &texel) const
void unbind_as_image() const
T load_pixel_fallback(const int2 &texel, const T &fallback) const
void allocate_single_value()
static ResultPrecision precision(gpu::TextureFormat format)
DerivedResources & derived_resources()
void bind_as_image(gpu::Shader *shader, const char *image_name, bool read=false) const
void set_reference_count(int count)
gpu::Texture * bind_as_texture_or_single_value(gpu::Shader *shader, const char *texture_name) const
const T & get_single_value() const
T load_pixel(const int2 &texel, const Extension &extension_mode_x, const Extension &extension_mode_y) const
void set_type(ResultType type)
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
StringRefNull to_string(const Interpolation &interpolation)
static void sample_ewa_read_callback(void *userdata, int x, int y, float result[4])
ColorSceneLinear4f< eAlpha::Premultiplied > Color
ImplicitSharingPtr< Closure > ClosurePtr
BLI_INLINE math::InterpWrapMode map_extension_mode_to_wrap_mode(const Extension &mode)
QuaternionBase< float > Quaternion
T clamp(const T &a, const T &min, const T &max)
BLI_INLINE void interpolate_bilinear_wrapmode_fl(const float *buffer, float *output, int width, int height, int components, float u, float v, InterpWrapMode wrap_x, InterpWrapMode wrap_y)
BLI_INLINE void interpolate_nearest_wrapmode_fl(const float *buffer, float *output, int width, int height, int components, float u, float v, InterpWrapMode wrap_u, InterpWrapMode wrap_v)
void interpolate_cubic_bspline_wrapmode_fl(const float *buffer, float *output, int width, int height, int components, float u, float v, InterpWrapMode wrap_u, InterpWrapMode wrap_v)
ImplicitSharingPtr< Bundle > BundlePtr
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BLI_ewa_filter(int width, int height, bool intpol, bool use_alpha, const float uv[2], const float du[2], const float dv[2], ewa_filter_read_pixel_cb read_pixel_cb, void *userdata, float result[4], bool clip=true)
constexpr bool is_same_any_v
BMesh const char void * data
MINLINE void copy_v4_v4(float r[4], const float a[4])
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
const Extension extension_mode_x
const Extension extension_mode_y