Loading...
Searching...
No Matches
computationBuilders.h
Go to the documentation of this file.
1//
2// Copyright 2025 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_EXEC_EXEC_COMPUTATION_BUILDERS_H
8#define PXR_EXEC_EXEC_COMPUTATION_BUILDERS_H
9
18
19#include "pxr/pxr.h"
20
21#include "pxr/exec/exec/api.h"
22#include "pxr/exec/exec/builtinComputations.h"
25#include "pxr/exec/exec/types.h"
26
27#include "pxr/base/tf/token.h"
28#include "pxr/base/tf/type.h"
29#include "pxr/base/vt/traits.h"
30#include "pxr/base/vt/value.h"
32#include "pxr/exec/vdf/traits.h"
33#include "pxr/usd/sdf/path.h"
34
35#include <memory>
36#include <type_traits>
37#include <utility>
38
39PXR_NAMESPACE_OPEN_SCOPE
40
41struct Exec_InputKey;
42
43
113
122
143
160
174
184
193
194
199{
200 Prim = 1 << 0,
201 Attribute = 1 << 1,
202 Any = 0xff
203};
204
205constexpr bool operator&(
208{
209 return static_cast<unsigned char>(a) & static_cast<unsigned char>(b);
210}
211
212template <Exec_ComputationBuilderProviderTypes allowed>
213struct Exec_ComputationBuilderComputationValueSpecifier;
214
215// Common base class for value specifiers and object accessors.
216class Exec_ComputationBuilderCommonBase
217{
218protected:
219 // Returns a value specifier for computing a metadata value.
220 template <Exec_ComputationBuilderProviderTypes allowed>
221 EXEC_API
222 static Exec_ComputationBuilderComputationValueSpecifier<allowed>
223 _GetMetadataValueSpecifier(
224 const TfType resultType,
225 const SdfPath &localTraversal,
226 const TfToken &metadataKey);
227};
228
229// Untemplated value specifier base class.
230//
231// This class builds up an Exec_InputKey that specifies how to source an input
232// value at exec compilation time.
233//
234class Exec_ComputationBuilderValueSpecifierBase
235 : public Exec_ComputationBuilderCommonBase
236{
237public:
238 EXEC_API
239 Exec_ComputationBuilderValueSpecifierBase(
240 const TfToken &computationName,
241 TfType resultType,
242 ExecProviderResolution &&providerResolution,
243 const TfToken &inputName,
244 const TfToken &disambiguatingId);
245
246 EXEC_API
247 Exec_ComputationBuilderValueSpecifierBase(
248 const Exec_ComputationBuilderValueSpecifierBase&);
249
250 EXEC_API
251 ~Exec_ComputationBuilderValueSpecifierBase();
252
253protected:
254 EXEC_API
255 void _SetInputName(const TfToken &inputName);
256
257 EXEC_API
258 void _SetOptional (const bool optional);
259
260 EXEC_API
261 void _SetFallsBackToDispatched(bool fallsBackToDispatched);
262
263private:
264 // Only computation builders can get the input key.
265 friend class Exec_ComputationBuilderBase;
266
267 EXEC_API
268 void _GetInputKey(Exec_InputKey *inputKey) const;
269
270private:
271 // We PIMPL the data for this class to avoid exposing more private details
272 // in this public header.
273 struct _Data;
274 const std::unique_ptr<_Data> _data;
275};
276
277// A value specifier that requests a constant value, valid on a prim or
278// attribute computation
279//
280struct Exec_ComputationBuilderConstantValueSpecifier final
281 : public Exec_ComputationBuilderValueSpecifierBase
282{
283 static constexpr Exec_ComputationBuilderProviderTypes allowedProviders =
284 Exec_ComputationBuilderProviderTypes::Any;
285
286 EXEC_API
287 Exec_ComputationBuilderConstantValueSpecifier(
288 const TfType resultType,
289 const SdfPath &localTraversal,
290 const TfToken &inputName,
291 VtValue &&constantValue);
292};
293
294// A value specifier that requests the value of a computation.
295//
296// The template parameter determines which types of providers the input
297// registration is allowed to be used on.
298//
299template <Exec_ComputationBuilderProviderTypes allowed>
300struct Exec_ComputationBuilderComputationValueSpecifier
301 : public Exec_ComputationBuilderValueSpecifierBase
302{
303 Exec_ComputationBuilderComputationValueSpecifier(
304 const TfToken &computationName,
305 const TfType resultType,
306 ExecProviderResolution &&providerResolution,
307 const TfToken &disambiguatingId = TfToken())
308 : Exec_ComputationBuilderValueSpecifierBase(
309 computationName, resultType,
310 std::move(providerResolution),
311 computationName /* inputName */,
312 disambiguatingId)
313 {
314 }
315
316 using This = Exec_ComputationBuilderComputationValueSpecifier<allowed>;
317
318 static constexpr Exec_ComputationBuilderProviderTypes allowedProviders =
319 allowed;
320
323
345 This&
346 InputName(const TfToken &inputName)
347 {
348 _SetInputName(inputName);
349 return *this;
350 }
351
374 This&
376 {
377 _SetOptional(false);
378 return *this;
379 }
380
413 This&
415 {
416 _SetFallsBackToDispatched(true);
417 return *this;
418 }
419
421};
422
423
424// Untemplated object accessor base class.
425struct Exec_ComputationBuilderAccessorBase
426 : public Exec_ComputationBuilderCommonBase
427{
428
429 Exec_ComputationBuilderAccessorBase(const SdfPath &localTraversal)
430 : _localTraversal(localTraversal)
431 {
432 }
433
434protected:
435 const SdfPath &_GetLocalTraversal() const {
436 return _localTraversal;
437 }
438
439private:
440 // The relative path used for the first phase of provider resolution.
441 SdfPath _localTraversal;
442};
443
444// Untemplated base class for accessors used to provide constant values as
445// computation inputs.
446//
447struct Exec_ComputationBuilderConstantAccessorBase
448 : public Exec_ComputationBuilderAccessorBase
449{
450 // We specialize the InputName() accessor because it is required for
451 // constant values. I.e., Constant() returns an accessor, and the
452 // InputName() option must be used to generate a value specifier.
453 //
454 Exec_ComputationBuilderConstantValueSpecifier
455 InputName(const TfToken &inputName) &&
456 {
457 return Exec_ComputationBuilderConstantValueSpecifier(
458 _valueType,
459 _GetLocalTraversal(),
460 inputName,
461 std::move(_constantValue));
462 }
463
464protected:
465 EXEC_API
466 Exec_ComputationBuilderConstantAccessorBase(
467 VtValue &&constantValue,
468 TfType valueType);
469
470private:
471 VtValue _constantValue;
472 const TfType _valueType;
473};
474
481template <Exec_ComputationBuilderProviderTypes allowed>
483 : public Exec_ComputationBuilderAccessorBase
484{
485 Exec_ComputationBuilderAccessor(const SdfPath &localTraversal)
486 : Exec_ComputationBuilderAccessorBase(localTraversal)
487 {
488 }
489
490 using ValueSpecifier =
491 Exec_ComputationBuilderComputationValueSpecifier<allowed>;
492
495
497 template <typename ResultType>
498 ValueSpecifier
499 Computation(const TfToken &computationName)
500 {
501 static_assert(!VtIsArray<ResultType>::value,
502 "VtArray is not a supported result type");
503
504 return ValueSpecifier(
505 computationName,
506 ExecTypeRegistry::GetInstance().CheckForRegistration<ResultType>(),
507 {_GetLocalTraversal(),
509 }
510
512 template <typename ResultType>
513 ValueSpecifier
514 Metadata(const TfToken &metadataKey)
515 {
516 static_assert(!VtIsArray<ResultType>::value,
517 "VtArray is not a supported result type");
518
519 return _GetMetadataValueSpecifier<allowed>(
520 ExecTypeRegistry::GetInstance().CheckForRegistration<ResultType>(),
521 _GetLocalTraversal(),
522 metadataKey);
523 }
524
526};
527
529template <Exec_ComputationBuilderProviderTypes allowed>
531 : public Exec_ComputationBuilderAccessor<allowed>
532{
535 {
536 }
537};
538
540template <Exec_ComputationBuilderProviderTypes allowed>
543{
546 {
547 }
548
549 using ValueSpecifier =
550 Exec_ComputationBuilderComputationValueSpecifier<allowed>;
551
554
557 template <typename ResultType>
558 ValueSpecifier
559 ConnectionTargetedObjects(const TfToken &computationName)
560 {
561 return ValueSpecifier(
562 computationName,
563 ExecTypeRegistry::GetInstance().CheckForRegistration<ResultType>(),
564 {Exec_ComputationBuilderAccessorBase::_GetLocalTraversal(),
565 ExecProviderResolution::DynamicTraversal::
566 ConnectionTargetedObjects});
567 }
568
570
571 // XXX:TODO
572 // Accessors for AnimSpline, IncomingConnections
573};
574
576template <Exec_ComputationBuilderProviderTypes allowed>
579{
582 {
583 }
584
585 using ValueSpecifier =
586 Exec_ComputationBuilderComputationValueSpecifier<allowed>;
587
590
621 template <typename ResultType>
622 ValueSpecifier
623 TargetedObjects(const TfToken &computationName)
624 {
625 return ValueSpecifier(
626 computationName,
627 ExecTypeRegistry::GetInstance().CheckForRegistration<ResultType>(),
628 {Exec_ComputationBuilderAccessorBase::_GetLocalTraversal(),
629 ExecProviderResolution::DynamicTraversal::
630 RelationshipTargetedObjects});
631 }
632
634};
635
636
637// The following registrations are in the exec_registration namespace so that
638// the registration macro can make them available (without the namespace) as
639// arguments to registrations methods (i.e., Inputs()).
640namespace exec_registration {
641
642
644struct Attribute final
646 Exec_ComputationBuilderProviderTypes::Prim>
647{
650
673 Attribute(const TfToken &attributeName)
676 SdfPath::ReflexiveRelativePath().AppendProperty(attributeName))
677 {
678 }
679
681};
682
683
685struct Relationship final
687 Exec_ComputationBuilderProviderTypes::Prim>
688{
691
698 Relationship(const TfToken &relationshipName)
701 SdfPath::ReflexiveRelativePath().AppendProperty(
702 relationshipName))
703 {
704 }
705
707};
708
709
711struct Prim final
713 Exec_ComputationBuilderProviderTypes::Attribute>
714{
717
742 SdfPath(".."))
743 {
744 }
745
748 Exec_ComputationBuilderProviderTypes::Attribute>
749 Attribute(const TfToken &attributeName)
750 {
752 Exec_ComputationBuilderProviderTypes::Attribute>(
753 SdfPath("..").AppendProperty(attributeName));
754 }
755
758 Exec_ComputationBuilderProviderTypes::Attribute>
759 Relationship(const TfToken &relationshipName)
760 {
762 Exec_ComputationBuilderProviderTypes::Attribute>(
763 SdfPath("..").AppendProperty(relationshipName));
764 }
765
767
770
772 template <typename ValueType>
773 auto
774 AttributeValue(const TfToken &attributeName)
775 {
776 return Attribute(attributeName)
777 .Computation<ValueType>(ExecBuiltinComputations->computeValue)
778 .InputName(attributeName);
779 }
780
782};
783
784
786struct Stage final
788 Exec_ComputationBuilderProviderTypes::Any>
789{
792
820 SdfPath::AbsoluteRootPath())
821 {
822 }
823
825};
826
827// XXX:TODO
828// Property, NamespaceParent, NamespaceChildren, etc.
829
830
832template <typename ResultType>
833struct Computation final
834 : public Exec_ComputationBuilderComputationValueSpecifier<
835 Exec_ComputationBuilderProviderTypes::Any>
836{
839
864 Computation(const TfToken &computationName)
865 : Exec_ComputationBuilderComputationValueSpecifier<
867 computationName,
868 ExecTypeRegistry::GetInstance().
869 CheckForRegistration<ResultType>(),
872 {
873 }
874
876};
877
879template <typename ValueType>
880struct Metadata final
881 : public Exec_ComputationBuilderComputationValueSpecifier<
882 Exec_ComputationBuilderProviderTypes::Any>
883{
886
906 Metadata(const TfToken &metadataKey)
907 : Exec_ComputationBuilderComputationValueSpecifier<
909 _GetMetadataValueSpecifier<allowedProviders>(
910 ExecTypeRegistry::GetInstance()
911 .CheckForRegistration<ValueType>(),
912 SdfPath::ReflexiveRelativePath(),
913 metadataKey))
914 {
915 static_assert(!VtIsArray<ValueType>::value,
916 "VtArray is not a supported result type");
917
918 InputName(metadataKey);
919 }
920
922};
923
924// Constant accessor
925template <typename ValueType>
926struct Constant final
927 : public Exec_ComputationBuilderConstantAccessorBase
928{
931
1019 ValueType &&constantValue)
1020 : Exec_ComputationBuilderConstantAccessorBase(
1021 VtValue(std::move(constantValue)),
1022 ExecTypeRegistry::GetInstance().
1023 CheckForRegistration<ValueType>())
1024 {
1025 static_assert(
1026 !std::is_same_v<std::decay_t<ValueType>, char*> &&
1027 !std::is_same_v<std::decay_t<ValueType>, const char*>,
1028 "Must use std::string to represent string literal types.");
1029 static_assert(
1030 VtIsHashable<ValueType>(),
1031 "Types used to provide constant input values must be hashable.");
1032 }
1033
1034 Constant(
1035 const ValueType &constantValue)
1036 : Exec_ComputationBuilderConstantAccessorBase(
1037 VtValue(constantValue),
1038 ExecTypeRegistry::GetInstance().
1039 CheckForRegistration<ValueType>())
1040 {
1041 static_assert(
1042 !std::is_same_v<std::decay_t<ValueType>, char*> &&
1043 !std::is_same_v<std::decay_t<ValueType>, const char*>,
1044 "Must use std::string to represent string literal types.");
1045 static_assert(
1046 VtIsHashable<ValueType>(),
1047 "Types used to provide constant input values must be hashable.");
1048 }
1049
1051};
1052
1053// Deduction guides that ensure std::string is the value type used to store
1054// character string literals.
1055Constant(const char *) -> Constant<std::string>;
1056Constant(char *) -> Constant<std::string>;
1057
1058
1059// XXX:TODO
1060// This should be implemented as an alias for an accessor that takes a predicate
1061// plus .Compute(), but that requires implementing predicates plus having a way
1062// to express the computation name and result type as computation parameters.
1063// Therefore, for now, this is implemented as a value specifier.
1064template <typename ResultType>
1065struct NamespaceAncestor final
1066 : public Exec_ComputationBuilderComputationValueSpecifier<
1067 Exec_ComputationBuilderProviderTypes::Prim>
1068{
1071
1099 NamespaceAncestor(const TfToken &computationName)
1100 : Exec_ComputationBuilderComputationValueSpecifier<
1102 computationName,
1103 ExecTypeRegistry::GetInstance().
1104 CheckForRegistration<ResultType>(),
1107 {
1108 }
1109
1111};
1112
1113// XXX:TODO
1114// AnimSpline
1115
1116
1119
1120// Note:
1121// Aliases are implemented as generator functions, rather than as structs,
1122// because that way they can simply be expressed as registrations.
1123
1158template <typename ValueType>
1159auto
1160AttributeValue(const TfToken &attributeName)
1161{
1162 return Attribute(attributeName)
1163 .Computation<ValueType>(ExecBuiltinComputations->computeValue)
1164 .InputName(attributeName);
1165}
1166
1168
1171
1204template <typename ResultType>
1205auto
1206ConnectionTargetedObjects(const TfToken &computationName)
1207{
1208 return Exec_ComputationBuilderComputationValueSpecifier<
1209 Exec_ComputationBuilderProviderTypes::Attribute>(
1210 computationName,
1213 ExecProviderResolution::DynamicTraversal::
1214 ConnectionTargetedObjects});
1215}
1216
1218
1219} // namespace exec_registration
1220
1221
1222// We forward declare these classes so the generated documentation for
1223// PrimComputation() and AttributeComputation() comes before the Callback() and
1224// Inputs() docs.
1225//
1228
1233{
1234 EXEC_API
1235 Exec_ComputationBuilder(TfType schemaType);
1236
1237public:
1238 EXEC_API
1240
1241 // Allows access to the constructor.
1242 //
1243 // Only schema computation registration functions should create computation
1244 // builders.
1245 struct ConstructionAccess {
1247 Construct(TfType schemaType) {
1248 return Exec_ComputationBuilder(schemaType);
1249 }
1250 };
1251
1254
1268 EXEC_API
1270 PrimComputation(const TfToken &computationName);
1271
1288 EXEC_API
1291 const TfToken &attributeName,
1292 const TfToken &computationName);
1293
1343 template <class... DispatchedOntoSchemaTypes>
1346 const TfToken &computationName,
1347 DispatchedOntoSchemaTypes &&...schemaTypes);
1348
1349 // overload that takes a vector of TfTypes
1350 EXEC_API
1353 const TfToken &computationName,
1354 ExecDispatchesOntoSchemas &&ontoSchemas);
1355
1388 template <class... DispatchedOntoSchemaTypes>
1391 const TfToken &computationName,
1392 DispatchedOntoSchemaTypes &&...schemaTypes);
1393
1394 // overload that takes a vector of TfTypes
1395 EXEC_API
1398 const TfToken &computationName,
1399 ExecDispatchesOntoSchemas &&ontoSchemas);
1400
1402
1403private:
1404 // The type of the schema for which this builder defines computations.
1405 TfType _schemaType;
1406};
1407
1408
1409// Untemplated base class for classes used to build computation definitions.
1410class Exec_ComputationBuilderBase
1411{
1412protected:
1413 EXEC_API
1414 Exec_ComputationBuilderBase(
1415 const TfToken &attributeName,
1416 TfType schemaType,
1417 const TfToken &computationName,
1418 bool dispatched,
1419 ExecDispatchesOntoSchemas &&dispatchesOntoSchemas);
1420
1421 ~Exec_ComputationBuilderBase();
1422
1423 // Adds the callback with result type.
1424 EXEC_API
1425 void _AddCallback(ExecCallbackFn &&calback, TfType resultType);
1426
1427 // Validates that all inputs are allowed to be registered on computations of
1428 // the \p allowed provider types.
1429 //
1430 template <Exec_ComputationBuilderProviderTypes allowed, typename T>
1431 static void _ValidateInputs();
1432
1433 // Adds an input key from the given value specifier.
1434 //
1435 // This extra level of indirection helps keep Exec_InputKey out of the
1436 // header so that type can remain private.
1437 //
1438 EXEC_API
1439 void _AddInputKey(
1440 const Exec_ComputationBuilderValueSpecifierBase *valueSpecifier);
1441
1442 // Returns a pointer to the dispatches-onto schemas if the computation is
1443 // dispatched, or a null pointer, otherwise.
1444 //
1445 std::unique_ptr<ExecDispatchesOntoSchemas>
1446 _GetDispatchesOntoSchemas();
1447
1448 // We PIMPL the data for this class to avoid exposing more private details
1449 // in this public header.
1450 //
1451 struct _Data;
1452 _Data &_GetData();
1453
1454private:
1455 const std::unique_ptr<_Data> _data;
1456};
1457
1458
1459// CRTP base class for classes used to build computation definitions.
1460template <typename Derived>
1461class Exec_ComputationBuilderCRTPBase : public Exec_ComputationBuilderBase
1462{
1463 // Type used as a default template parameter type for metaprogramming.
1464 struct _UnspecifiedType {};
1465
1466protected:
1467 EXEC_API
1468 Exec_ComputationBuilderCRTPBase(
1469 const TfToken &attributeName,
1470 TfType schemaType,
1471 const TfToken &computationName,
1472 bool dispatched,
1473 ExecDispatchesOntoSchemas &&dispatchesOntoSchemas);
1474
1475 EXEC_API
1476 ~Exec_ComputationBuilderCRTPBase();
1477
1478public:
1525 template<
1526 typename ResultType = _UnspecifiedType,
1527 typename ReturnType = _UnspecifiedType>
1528 Derived&
1529 Callback(ReturnType (*callback)(const VdfContext &));
1530};
1531
1532
1535 : public Exec_ComputationBuilderCRTPBase<Exec_PrimComputationBuilder>
1536{
1537 // Only Exec_ComputationBuilder can create instances.
1538 friend class Exec_ComputationBuilder;
1539
1540 EXEC_API
1542 TfType schemaType,
1543 const TfToken &computationName,
1544 bool dispatched = false,
1545 ExecDispatchesOntoSchemas &&dispatchesOntoSchemas = {});
1546
1547public:
1548 EXEC_API
1550
1573 template <typename... Args>
1575 Inputs(Args && ... args);
1576};
1577
1578
1581 : public Exec_ComputationBuilderCRTPBase<Exec_AttributeComputationBuilder>
1582{
1583 // Only Exec_ComputationBuilder can create instances.
1584 friend class Exec_ComputationBuilder;
1585
1586 EXEC_API
1588 const TfToken &attributeName,
1589 TfType schemaType,
1590 const TfToken &computationName,
1591 bool dispatched = false,
1592 ExecDispatchesOntoSchemas &&dispatchesOntoSchemas = {});
1593
1594public:
1595 EXEC_API
1597
1621 template <typename... Args>
1623 Inputs(Args && ... args);
1624};
1625
1626//
1627// Exec_ComputationBuilderBase
1628//
1629
1630template <Exec_ComputationBuilderProviderTypes allowed, typename T>
1631void
1632Exec_ComputationBuilderBase::_ValidateInputs() {
1633 using regType = std::decay_t<T>;
1634 static_assert(
1635 !std::is_base_of_v<Exec_ComputationBuilderAccessorBase, regType>,
1636 "Accessor can't provide an input value.");
1637 static_assert(
1638 !std::is_same_v<Exec_ComputationBuilderConstantAccessorBase, regType>,
1639 "Constant(value) must be followed by .InputName(inputNameToken)");
1640 static_assert(
1641 std::is_base_of_v<Exec_ComputationBuilderValueSpecifierBase, regType>,
1642 "Invalid type used as an input registration.");
1643 static_assert(
1644 regType::allowedProviders & allowed,
1645 "Input is not allowed on a provider of this type.");
1646}
1647
1648//
1649// Exec_ComputationBuilderCRTPBase
1650//
1651
1652template <typename Derived>
1653template <typename InputResultType, typename ReturnType>
1654Derived&
1656 ReturnType (*callback)(const VdfContext &))
1657{
1658 // In order to allow the return type of the callback to be different from
1659 // the computation result type in some cases AND be able to deduce the
1660 // result type from the return type in others, we have to default both
1661 // template parameters to _UnspecifiedType and use metaprogramming to get
1662 // the actual result type.
1663 using ResultType =
1664 std::conditional_t<
1665 std::is_same_v<InputResultType, _UnspecifiedType>,
1666 ReturnType,
1667 InputResultType>;
1668
1669 static_assert(
1670 !std::is_void_v<ResultType> ||
1671 std::is_convertible_v<ReturnType, ResultType>,
1672 "Callback return type must be convertible to the computation result "
1673 "type");
1674 static_assert(
1675 !std::is_reference_v<ResultType>,
1676 "Callback functions must return by value");
1677 static_assert(
1679 "VtArray is not a supported result type");
1680
1681 const TfType resultType =
1683
1684 // If the return type is void, the callback is on the hook to call
1685 // VdfContext::SetOutput; otherwise, we wrap it in a lambda that passes
1686 // the callback return value to SetOutput.
1687 if constexpr (std::is_void_v<ReturnType>) {
1688 _AddCallback(callback, resultType);
1689 } else {
1690 _AddCallback(
1691 [callback](const VdfContext& ctx) {
1692 ctx.SetOutput<ResultType>(callback(ctx));
1693 },
1694 resultType);
1695 }
1696
1697 return *static_cast<Derived*>(this);
1698}
1699
1700//
1701// Exec_PrimComputationBuilder
1702//
1703
1704template <typename... Args>
1707 Args && ... args)
1708{
1709 // Validate inputs
1710 (_ValidateInputs<
1711 Exec_ComputationBuilderProviderTypes::Prim, Args>(), ...);
1712
1713 // Add inputs
1714 (_AddInputKey(&args), ...);
1715
1716 return *this;
1717}
1718
1719//
1720// Exec_AttributeComputationBuilder
1721//
1722
1723template <typename... Args>
1726 Args && ... args)
1727{
1728 // Validate inputs
1729 (_ValidateInputs<
1730 Exec_ComputationBuilderProviderTypes::Attribute, Args>(), ...);
1731
1732 // Add inputs
1733 (_AddInputKey(&args), ...);
1734
1735 return *this;
1736}
1737
1738//
1739// Exec_ComputationBuilder
1740//
1741
1742template <class... DispatchedOntoSchemaTypes>
1745 const TfToken &computationName,
1746 DispatchedOntoSchemaTypes &&...schemaTypes)
1747{
1748 static_assert(
1749 (std::is_same_v<
1750 std::decay_t<DispatchedOntoSchemaTypes>, TfType> && ...));
1751
1753 computationName,
1754 {std::forward<DispatchedOntoSchemaTypes>(schemaTypes)...});
1755}
1756
1757template <class... DispatchedOntoSchemaTypes>
1760 const TfToken &computationName,
1761 DispatchedOntoSchemaTypes &&...schemaTypes)
1762{
1763 static_assert(
1764 (std::is_same_v<
1765 std::decay_t<DispatchedOntoSchemaTypes>, TfType> && ...));
1766
1768 computationName,
1769 {std::forward<DispatchedOntoSchemaTypes>(schemaTypes)...});
1770}
1771
1772PXR_NAMESPACE_CLOSE_SCOPE
1773
1774#endif
Class used to build attribute computation definitions.
The top-level builder object (aka, the 'self' variable generated by EXEC_REGISTER_COMPUTATIONS_FOR_SC...
Class used to build prim computation definitions.
Singleton used to register and access value types used by exec computations.
Definition: typeRegistry.h:48
TfType CheckForRegistration() const
Confirms that ValueType has been registered.
Definition: typeRegistry.h:96
static EXEC_API const ExecTypeRegistry & GetInstance()
Provides access to the singleton instance, first ensuring it is constructed.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
static SDF_API const SdfPath & ReflexiveRelativePath()
The relative path representing "self".
SDF_API SdfPath AppendProperty(TfToken const &propName) const
Creates a path by appending an element for propName to this path.
This is a small-vector class with local storage optimization, the local storage can be specified via ...
Definition: smallVector.h:157
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
TfType represents a dynamic runtime type.
Definition: type.h:48
A context is the parameter bundle passed to callbacks of computations.
Definition: context.h:40
void SetOutput(const TfToken &outputName, const T &value) const
Sets the value of the output named outputName to value.
Definition: context.h:394
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:90
Exec_ComputationBuilderProviderTypes
An enum that is used as a template parameter to specify which kinds of providers a given input regist...
This file contains definitions for trivial types, including type aliases, so that source files that r...
std::function< void(const class VdfContext &context)> ExecCallbackFn
Function type used for computation callbacks.
Definition: types.h:28
Exec_ComputationBuilderRelationshipAccessor< Exec_ComputationBuilderProviderTypes::Attribute > Relationship(const TfToken &relationshipName)
See Relationship().
Stage()
On any computation, provides access to the stage.
Attribute(const TfToken &attributeName)
On a prim computation, provides access to the attribute named attributeName.
Prim()
On an attribute computation, provides access to the owning prim.
Relationship(const TfToken &relationshipName)
On a prim computation, provides access to the relationship named relationshipName.
Exec_ComputationBuilderAttributeAccessor< Exec_ComputationBuilderProviderTypes::Attribute > Attribute(const TfToken &attributeName)
See Attribute().
auto AttributeValue(const TfToken &attributeName)
See AttributeValue().
EXEC_API Exec_AttributeComputationBuilder AttributeComputation(const TfToken &attributeName, const TfToken &computationName)
Registers an attribute computation named computationName on attributes named attributeName.
Derived & Callback(ReturnType(*callback)(const VdfContext &))
Registers a callback function that implements the evaluation logic for a computation.
EXEC_API Exec_PrimComputationBuilder PrimComputation(const TfToken &computationName)
Registers a prim computation named computationName.
Exec_AttributeComputationBuilder DispatchedAttributeComputation(const TfToken &computationName, DispatchedOntoSchemaTypes &&...schemaTypes)
Registers a dispatched attribute computation named computationName.
Exec_PrimComputationBuilder & Inputs(Args &&... args)
Takes one or more input registrations that specify how to source input values for a prim computation.
Exec_AttributeComputationBuilder & Inputs(Args &&... args)
Takes one or more input registrations that specify how to source input values for an attribute comput...
Exec_PrimComputationBuilder DispatchedPrimComputation(const TfToken &computationName, DispatchedOntoSchemaTypes &&...schemaTypes)
Registers a dispatched prim computation named computationName.
This & InputName(const TfToken &inputName)
Overrides the default input name, setting it to inputName.
This & FallsBackToDispatched()
Declares the input can find dispatched computations if the requested computation name doesn't match a...
This & Required()
Declares the input is required, i.e., that the computation expects an input value always to be provid...
auto ConnectionTargetedObjects(const TfToken &computationName)
As a direct input to an attribute computation or after an Attribute() accessor, requests input values...
ValueSpecifier Metadata(const TfToken &metadataKey)
See Metadata().
ValueSpecifier ConnectionTargetedObjects(const TfToken &computationName)
See ConnectionTargetedObjects().
Metadata(const TfToken &metadataKey)
Requests an input value from the metadata field indicated by metadataKey, of type ResultType.
Constant(ValueType &&constantValue)
Requests a constant input value of type ValueType.
NamespaceAncestor(const TfToken &computationName)
On a prim computation, requests an input value from the computation computationName of type ResultTyp...
ValueSpecifier TargetedObjects(const TfToken &computationName)
After a Relationship() accessor, requests input values from the computation computationName of type R...
Computation(const TfToken &computationName)
Requests an input value from the computation computationName of type ResultType.
ValueSpecifier Computation(const TfToken &computationName)
See Computation().
STL namespace.
Accessor common to all scene object types that support requesting computations on the object.
Data used to find computation providers during exec compilation.
@ Local
The localTraversal path directly indicates the computation provider.
@ NamespaceAncestor
Find the provider by traversing upward in namespace.
A trait to detect instantiations of VtArray, specialized in array.h.
Definition: traits.h:22
Attribute accessor, valid for providing input to a prim computation.
Computation value specifier, valid for providing input to any computation.
Metadata value specifier, valid on a prim or attribute computation.
Prim accessor, valid for providing input to an attribute computation.
Relationship accessor, valid for providing input to a prim computation.
Provides access to the stage, valid for providing input to any computation.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...