2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2022-09-13 08:44:26 +02:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup fn
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "FN_lazy_function.hh"
|
|
|
|
|
|
|
|
|
|
namespace blender::fn::lazy_function {
|
|
|
|
|
|
|
|
|
|
std::string LazyFunction::name() const
|
|
|
|
|
{
|
|
|
|
|
return debug_name_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string LazyFunction::input_name(int index) const
|
|
|
|
|
{
|
|
|
|
|
return inputs_[index].debug_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string LazyFunction::output_name(int index) const
|
|
|
|
|
{
|
|
|
|
|
return outputs_[index].debug_name;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-03 17:37:25 -05:00
|
|
|
void *LazyFunction::init_storage(LinearAllocator<> & /*allocator*/) const
|
2022-09-13 08:44:26 +02:00
|
|
|
{
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LazyFunction::destruct_storage(void *storage) const
|
|
|
|
|
{
|
|
|
|
|
BLI_assert(storage == nullptr);
|
|
|
|
|
UNUSED_VARS_NDEBUG(storage);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-29 16:38:18 +01:00
|
|
|
void LazyFunction::possible_output_dependencies(const int /*output_index*/,
|
|
|
|
|
const FunctionRef<void(Span<int>)> fn) const
|
|
|
|
|
{
|
|
|
|
|
/* The output depends on all inputs by default. */
|
|
|
|
|
Vector<int, 16> indices(inputs_.size());
|
|
|
|
|
for (const int i : inputs_.index_range()) {
|
|
|
|
|
indices[i] = i;
|
|
|
|
|
}
|
|
|
|
|
fn(indices);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 08:44:26 +02:00
|
|
|
bool LazyFunction::always_used_inputs_available(const Params ¶ms) const
|
|
|
|
|
{
|
2022-12-29 16:38:18 +01:00
|
|
|
if (allow_missing_requested_inputs_) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-09-13 08:44:26 +02:00
|
|
|
for (const int i : inputs_.index_range()) {
|
|
|
|
|
const Input &fn_input = inputs_[i];
|
|
|
|
|
if (fn_input.usage == ValueUsage::Used) {
|
|
|
|
|
if (params.try_get_input_data_ptr(i) == nullptr) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-20 10:59:12 +02:00
|
|
|
bool Params::try_enable_multi_threading_impl()
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 08:44:26 +02:00
|
|
|
} // namespace blender::fn::lazy_function
|