106 bool is_single_value_ =
false;
121 int reference_count_ = 1;
128 int *data_reference_count_ =
nullptr;
133 std::variant<float, float2, float3, float4, int32_t, int2, bool> single_value_ = 0.0f;
140 bool is_external_ =
false;
144 bool is_from_pool_ =
false;
190 operator GPUTexture *()
const;
227 void bind_as_texture(GPUShader *shader,
const char *texture_name)
const;
232 void bind_as_image(GPUShader *shader,
const char *image_name,
bool read =
false)
const;
368 template<
typename T,
bool CouldBeSingleValue = false>
T load_pixel(
const int2 &texel)
const;
371 template<
typename T,
bool CouldBeSingleValue = false>
375 template<
typename T,
bool CouldBeSingleValue = false>
425 const float2 &y_gradient)
const;
430 const float2 &y_gradient)
const;
435 void allocate_data(
int2 size,
bool from_pool);
492 return std::get<T>(single_value_);
501 return default_value;
509 single_value_ = value;
513template<
typename T,
bool CouldBeSingleValue>
516 if constexpr (CouldBeSingleValue) {
517 if (is_single_value_) {
528template<
typename T,
bool CouldBeSingleValue>
531 if constexpr (CouldBeSingleValue) {
532 if (is_single_value_) {
541 return this->
cpu_data().
typed<
T>()[this->get_pixel_index(clamped_texel)];
544template<
typename T,
bool CouldBeSingleValue>
547 if constexpr (CouldBeSingleValue) {
548 if (is_single_value_) {
556 if (texel.x < 0 || texel.y < 0 || texel.x >= domain_.size.x || texel.y >= domain_.size.y) {
563template<
typename T,
bool CouldBeSingleValue>
572 if (is_single_value_) {
584 this->
cpu_data().
typed<
T>()[this->get_pixel_index(texel)] = pixel_value;
588 const float4 &pixel_value)
596 if (is_single_value_) {
604 const float *buffer =
static_cast<const float *
>(this->
cpu_data().
data());
609 this->channels_count(),
611 texel_coordinates.y);
620 if (is_single_value_) {
628 const float *buffer =
static_cast<const float *
>(this->
cpu_data().
data());
634 this->channels_count(),
647 if (is_single_value_) {
655 const float *buffer =
static_cast<const float *
>(this->
cpu_data().
data());
661 this->channels_count(),
674 if (is_single_value_) {
682 const float *buffer =
static_cast<const float *
>(this->
cpu_data().
data());
688 this->channels_count(),
699 if (is_single_value_) {
707 const float *buffer =
static_cast<const float *
>(this->
cpu_data().
data());
712 this->channels_count(),
714 texel_coordinates.y);
721 if (is_single_value_) {
729 const float *buffer =
static_cast<const float *
>(this->
cpu_data().
data());
734 this->channels_count(),
736 texel_coordinates.y);
743 if (is_single_value_) {
751 const float *buffer =
static_cast<const float *
>(this->
cpu_data().
data());
756 this->channels_count(),
758 texel_coordinates.y);
765 if (is_single_value_) {
773 const float *buffer =
static_cast<const float *
>(this->
cpu_data().
data());
778 this->channels_count(),
780 texel_coordinates.y);
797 const float2 &y_gradient)
const
802 if (is_single_value_) {
816 const_cast<Result *
>(
this),
834 const float2 &y_gradient)
const
839 if (is_single_value_) {
853 const_cast<Result *
>(
this),
862 BLI_assert(texel.x >= 0 && texel.y >= 0 && texel.x < domain_.
size.x && texel.y < domain_.
size.y);
863 return int64_t(texel.y) * domain_.
size.x + texel.x;
#define BLI_INLINE_METHOD
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])
MINLINE void copy_v4_v4(float r[4], const float a[4])
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void copy_assign(const void *src, void *dst) const
const void * data() const
float4 sample_nearest_extended(const float2 &coordinates) const
void decrement_reference_count(int count=1)
float4 sample_cubic_wrap(const float2 &coordinates, bool wrap_x, bool wrap_y) const
void share_data(const Result &source)
RealizationOptions & get_realization_options()
eGPUTextureFormat get_gpu_texture_format() const
float4 sample_nearest_wrap(const float2 &coordinates, bool wrap_x, bool wrap_y) const
const CPPType & get_cpp_type() const
T get_single_value_default(const T &default_value) const
void allocate_texture(Domain domain, bool from_pool=true)
void store_pixel(const int2 &texel, const T &pixel_value)
int reference_count() const
static ResultPrecision precision(eGPUTextureFormat format)
float4 sample_nearest_zero(const float2 &coordinates) const
void unbind_as_texture() const
static ResultType type(eGPUTextureFormat format)
void bind_as_texture(GPUShader *shader, const char *texture_name) const
static const char * type_name(const ResultType type)
float4 sample_ewa_extended(const float2 &coordinates, const float2 &x_gradient, const float2 &y_gradient) const
bool is_allocated() const
float4 sample_cubic_extended(const float2 &coordinates) const
void set_transformation(const float3x3 &transformation)
T load_pixel_zero(const int2 &texel) const
float4 sample_bilinear_zero(const float2 &coordinates) const
GPointer single_value() const
void set_single_value(const T &value)
ResultPrecision precision() const
float4 sample_bilinear_wrap(const float2 &coordinates, bool wrap_x, bool wrap_y) const
void update_single_value_data()
void store_pixel_generic_type(const int2 &texel, const float4 &pixel_value)
static eGPUTextureFormat gpu_texture_format(ResultType type, ResultPrecision precision)
T load_pixel_extended(const int2 &texel) const
static ResultType float_type(const int channels_count)
void set_precision(ResultPrecision precision)
void transform(const float3x3 &transformation)
void wrap_external(GPUTexture *texture)
GPUTexture * gpu_texture() const
void increment_reference_count(int count=1)
const Domain & domain() const
static const CPPType & cpp_type(const ResultType type)
T load_pixel(const int2 &texel) const
GPUTexture * gpu_texture_
int64_t channels_count() const
void bind_as_image(GPUShader *shader, const char *image_name, bool read=false) const
void unbind_as_image() const
T load_pixel_fallback(const int2 &texel, const T &fallback) const
void allocate_single_value()
float4 sample_ewa_zero(const float2 &coordinates, const float2 &x_gradient, const float2 &y_gradient) const
DerivedResources & derived_resources()
float4 sample_bilinear_extended(const float2 &coordinates) const
float4 load_pixel_generic_type(const int2 &texel) const
void set_reference_count(int count)
bool is_single_value() const
void steal_data(Result &source)
const T & get_single_value() const
void set_type(ResultType type)
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
static void sample_ewa_extended_read_callback(void *userdata, int x, int y, float result[4])
static void sample_ewa_zero_read_callback(void *userdata, int x, int y, float result[4])
T clamp(const T &a, const T &min, const T &max)
void interpolate_nearest_fl(const float *buffer, float *output, int width, int height, int components, float u, float v)
void interpolate_nearest_border_fl(const float *buffer, float *output, int width, int height, int components, float u, float v)
float4 interpolate_bilinear_border_fl(const float *buffer, int width, int height, float u, float v)
float4 interpolate_cubic_bspline_fl(const float *buffer, int width, int height, float u, float v)
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)
float4 interpolate_bilinear_fl(const float *buffer, int width, int height, float u, float v)
void interpolate_bilinear_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)
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
MatBase< float, 3, 3 > float3x3