7#ifndef PXR_EXEC_EXEC_TYPE_REGISTRY_H
8#define PXR_EXEC_EXEC_TYPE_REGISTRY_H
14#include "pxr/exec/exec/api.h"
15#include "pxr/exec/exec/valueExtractorFunction.h"
22#include "pxr/base/tf/type.h"
26#include "pxr/base/vt/value.h"
28#include <tbb/concurrent_unordered_map.h>
33PXR_NAMESPACE_OPEN_SCOPE
35class Exec_RegistrationBarrier;
36class Exec_ValueExtractor;
76 template <
typename ValueType>
80 "VtArray is not a supported execution value type.");
82 VdfIsEqualityComparable<ValueType>,
83 "Equality comparison is required for execution value types.");
84 _GetInstanceForRegistration()._RegisterType(fallback);
95 template <
typename ValueType>
97 return VdfExecutionTypeRegistry::CheckForRegistration<ValueType>();
124 template <
typename ValueType>
125 void _RegisterType(ValueType
const &fallback);
127 template <
typename T>
128 struct _CreateVector {
145 template <
typename T>
146 static auto _MakeExtractorFunction();
150 void _RegisterExtractor(
152 Exec_ValueExtractorFunction &extractor);
155 std::unique_ptr<Exec_RegistrationBarrier> _registrationBarrier;
173 tbb::concurrent_unordered_map<TfType, Exec_ValueExtractor, TfHash>
177template <
typename ValueType>
179ExecTypeRegistry::_RegisterType(ValueType
const &fallback)
185 if constexpr (!VtIsKnownValueType<ValueType>()) {
189 _RegisterExtractor(type, *+_MakeExtractorFunction<ValueType>());
194ExecTypeRegistry::_CreateVector<T>::Create(
const T &value)
202 using ElementType =
typename T::value_type;
204 const size_t size = value.size();
207 std::copy_n(value.cdata(), size, execValue.data());
210 v.
Set(std::move(execValue));
217ExecTypeRegistry::_MakeExtractorFunction()
233 const int offset = mask.GetFirstSet();
234 return VtValue(access[offset]);
239 using ElementType =
typename T::value_type;
241 if (!
TF_VERIFY(mask.AreContiguouslySet())) {
248 const int offset = mask.GetFirstSet();
249 const size_t numValues = access.
IsBoxed()
257PXR_NAMESPACE_CLOSE_SCOPE
Defines all the types "TYPED" for which Vt creates a VtTYPEDArray typedef.
Singleton used to register and access value types used by exec computations.
EXEC_API VdfVector CreateVector(const VtValue &value) const
Construct a VdfVector whose value is copied from value.
TfType CheckForRegistration() const
Confirms that ValueType has been registered.
static EXEC_API const ExecTypeRegistry & GetInstance()
Provides access to the singleton instance, first ensuring it is constructed.
EXEC_API Exec_ValueExtractor GetExtractor(TfType type) const
Returns an extractor that produces a VtValue from values held in execution.
static void RegisterType(const ValueType &fallback)
Registers ValueType as a value type that exec computations can use for input and output values,...
Fast, compressed bit array which is capable of performing logical operations without first decompress...
Manage a single instance of an object (see.
TfType represents a dynamic runtime type.
This simple container stores multiple values that flow through the network as a single data flow elem...
static TfType Define(const T &fallback)
Registers T with execution's runtime type dispatch system.
A VdfMask is placed on connections to specify the data flowing through them.
Dispatches calls to template instantiations based on a TfType that is determined at runtime.
bool RegisterType()
Register an additional type with the type dispatch table.
A VdfTypedVector implements a VdfVector with a specific type.
A read-only accessor for low-level acces to the contents of the VdfVector.
bool IsBoxed() const
Returns true if this accessor is providing element-wise access into a boxed container.
bool IsEmpty() const
Returns true if the vector is empty.
size_t GetNumValues() const
Returns the size of the vector, i.e.
This class is used to abstract away knowledge of the cache data used for each node.
void Set(TYPE &&data)
Forwards data into the vector.
VtArray< T > ExtractAsVtArray(const size_t size, const int offset) const
Extracts this vector's values into a VtArray<T>.
ReadAccessor< TYPE > GetReadAccessor() const
GetReadAccessor() allows low level read-only access to the content of of the VdfVector via the Vdf_Ve...
Provides a container which may hold any type, and provides introspection and iteration over array typ...
T const & UncheckedGet() const &
Returns a const reference to the held object if the held object is of type T.
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
Manage a single instance of an object.
A trait to detect instantiations of VtArray, specialized in array.h.