50 Result weights_cpu = this->compute_weights(context, radius);
51 Result falloffs_cpu = this->compute_distance_falloffs(context, type, radius);
53 if (context.use_gpu()) {
77Result MorphologicalDistanceFeatherWeights::compute_weights(
Context &context,
int radius)
84 const int size = radius + 1;
97 const float scale = radius > 0.0f ? 1.0f / radius : 0.0f;
98 for (
const int i :
IndexRange(size).drop_front(1)) {
101 sum += weight * 2.0f;
121 return 3.0f *
x *
x - 2.0f *
x *
x *
x;
123 return std::sqrt(2.0f *
x -
x *
x);
129 return x * (2.0f -
x);
138Result MorphologicalDistanceFeatherWeights::compute_distance_falloffs(
Context &context,
147 const int size = radius + 1;
152 const float scale = radius > 0.0f ? 1.0f / radius : 0.0f;
167 map_.remove_if([](
auto item) {
return !item.value->needed; });
171 for (
auto &value : map_.values()) {
172 value->needed =
false;
177 Context &context,
int type,
int radius)
181 auto &weights = *map_.lookup_or_add_cb(key, [&]() {
182 return std::make_unique<MorphologicalDistanceFeatherWeights>(context, type, radius);
185 weights.needed =
true;
#define BLI_assert_unreachable()
constexpr IndexRange()=default
MorphologicalDistanceFeatherWeights & get(Context &context, int type, int radius)
MorphologicalDistanceFeatherWeightsKey(int type, float radius)
MorphologicalDistanceFeatherWeights(Context &context, int type, int radius)
~MorphologicalDistanceFeatherWeights()
void share_data(const Result &source)
Result upload_to_gpu(const bool from_pool) const
void store_pixel(const int2 &texel, const T &pixel_value)
void allocate_texture(const Domain domain, const bool from_pool=true, const std::optional< ResultStorageType > storage_type=std::nullopt)
T load_pixel(const int2 &texel) const
float3x3 scale(float3x3 mat, float2 scale)
bool operator==(const BokehKernelKey &a, const BokehKernelKey &b)
static float compute_distance_falloff(int type, float x)
float filter_kernel_value(FilterKernel kernel, float x)
unsigned __int64 uint64_t
VecBase< int32_t, 2 > int2
constexpr uint64_t get_default_hash(const T &v, const Args &...args)