7#ifndef PXR_EXEC_VDF_TEST_UTILS_H
8#define PXR_EXEC_VDF_TEST_UTILS_H
14#include "pxr/exec/vdf/api.h"
29#include "pxr/base/tf/hashmap.h"
36PXR_NAMESPACE_OPEN_SCOPE
86 using ValueFunction = void(
const VdfContext &context);
92 ValueFunction *
const cb)
93 :
VdfNode(network, inputSpecs, outputSpecs),
110 ValueFunction *
const _cb;
141 using InputDependencyFunction = std::function<
145 using OutputDependencyFunction = std::function<
147 const VdfMask &inputDependencyMask,
154 ValueFunction *function,
155 const InputDependencyFunction &inputDependencyFunction,
156 const OutputDependencyFunction &outputDependencyFunction) :
157 CallbackNode(network, inputSpecs, outputSpecs, function),
158 _inputDependencyFunction(inputDependencyFunction),
159 _outputDependencyFunction(outputDependencyFunction) {
166 if (_inputDependencyFunction) {
167 return _inputDependencyFunction(
168 maskedOutput, inputConnection);
171 maskedOutput, inputConnection);
177 const VdfMask &inputDependencyMask,
179 if (_outputDependencyFunction) {
180 return _outputDependencyFunction(
181 inputConnection, inputDependencyMask, output);
184 inputConnection, inputDependencyMask, output);
189 InputDependencyFunction _inputDependencyFunction;
190 OutputDependencyFunction _outputDependencyFunction;
223 return new VdfInputVector<T>(net, _size);
244 _function(function) {
252 net, _inputSpecs, _outputSpecs,
253 _function, _inputDependencyFunction, _outputDependencyFunction);
258 template <
typename T>
285 const DependencyCallbackNode::InputDependencyFunction &function) {
286 _inputDependencyFunction = function;
294 const DependencyCallbackNode::OutputDependencyFunction &function) {
295 _outputDependencyFunction = function;
304 CallbackNode::ValueFunction *_function;
305 DependencyCallbackNode::InputDependencyFunction _inputDependencyFunction;
306 DependencyCallbackNode::OutputDependencyFunction _outputDependencyFunction;
337 Node &operator>>(
const _NodeInput &rhs);
368 dynamic_cast<VdfInputVector<T> *
>(_vdfNode)->
SetValue(index, val);
376 VdfNode *GetVdfNode() {
return _vdfNode; }
378 const VdfNode *GetVdfNode()
const {
return _vdfNode; }
386 void _Connect(
const _NodeInput &rhs,
VdfOutput *output);
388 friend class Network;
389 friend class _NodeOutput;
422 _EditMonitor(
Network *network) : _network(network) {}
434 void WillDelete(
const VdfNode *node)
override;
440 void WillClear()
override;
446 void DidAddNode(
const VdfNode *node)
override {}
458 Network() : _editMonitor(
this) {
486 template <
typename T>
534 typedef TfHashMap<std::string, Node, TfHash> _StringToNodeMap;
535 _StringToNodeMap _nodes;
542 _EditMonitor _editMonitor;
569 ExecutionStatsProcessor::ThreadId,
570 std::vector<VdfExecutionStats::Event>>
573 ThreadToEvents events;
574 std::vector<ExecutionStatsProcessor*> subStats;
581 VdfExecutionStatsProcessor::ThreadId threadId,
646 ~_ExecutionStats() {}
663 void AddSubStat(
VdfId nodeId);
670 std::unique_ptr<_ExecutionStats> _stats;
677inline std::unique_ptr<VdfSpeculationExecutorBase>
683 return std::unique_ptr<VdfSpeculationExecutorBase>(
687 speculationNode, parentExecutor));
691 return std::unique_ptr<VdfSpeculationExecutorBase>(
695 speculationNode, parentExecutor));
702PXR_NAMESPACE_CLOSE_SCOPE
Fast, compressed bit array which is capable of performing logical operations without first decompress...
Token for efficient comparison, assignment, and hashing of known strings.
A class that fully represents a connection between two VdfNodes.
A context is the parameter bundle passed to callbacks of computations.
This is a data manager for executors that uses data stored in a vector indexed by output ids.
Execution stats profiling event logger.
EventType
The upper 2 bits are reserved as a flag for the event type: Highest bit : time event flag 2nd high bi...
Abstract base class for classes that execute a VdfNetwork to compute a requested set of values.
Base class for libVdf iterators.
const VdfNode & _GetNode(const VdfContext &context) const
Returns the current node being run.
A VdfMask is placed on connections to specify the data flowing through them.
TfCompressedBits Bits
Typedef on the internal bitset implementation used.
Class to hold on to an externally owned output and a mask.
An abstract class to monitor network edit operations.
A VdfNetwork is a collection of VdfNodes and their connections.
VDF_API void UnregisterEditMonitor(EditMonitor *monitor)
Unregisters an edit monitor for this network.
VDF_API void RegisterEditMonitor(EditMonitor *monitor)
Registers an edit monitor for this network.
This is the base class for all nodes in a VdfNetwork.
virtual VDF_API VdfMask::Bits _ComputeInputDependencyMask(const VdfMaskedOutput &maskedOutput, const VdfConnection &inputConnection) const
Returns a mask that indicates which elements of the data that flows along inputConnection are needed ...
const VdfOutput * GetOutput(const TfToken &name) const
Returns the output object named name.
virtual VDF_API VdfMask _ComputeOutputDependencyMask(const VdfConnection &inputConnection, const VdfMask &inputDependencyMask, const VdfOutput &output) const
Returns a mask that indicates which elements of the data that flows along output depend on the elemen...
A VdfOutput represents an output on a node.
VdfOutputSpecs is a container for VdfOutputSpec objects.
VdfOutputSpecs & Connector(const TfToken &name)
Create an "Out" connector with the given name.
This is a data manager for executors that uses data stored in a vector indexed by output ids.
An executor engine used for parallel speculation node evaluation, deriving from VdfParallelExecutorEn...
This class provides an executor engine to the speculation executor.
Executor used in speculation.
A node that pulls on a vector of value that are downstream of the current execution position.
A helper class that implements a simple callback node.
virtual bool _IsDerivedEqual(const VdfNode &rhs) const override
Can be overridden by derived classes to facilitate equality comparision.
virtual void Compute(const VdfContext &context) const override
This is the method called to perform computation.
This class specifies a CallbackNode with a given callback function.
CallbackNodeType & ComputeInputDependencyMaskCallback(const DependencyCallbackNode::InputDependencyFunction &function)
Sets an input dependency mask computation callback for this node type.
CallbackNodeType(CallbackNode::ValueFunction *function)
Creates a callback node type with callback function function.
virtual VdfNode * NewNode(VdfNetwork *net) const
Creates a CallbackNode from this node type.
CallbackNodeType & ReadWrite(const TfToken &name, const TfToken &outName)
Adds a ReadWrite input and an associated Output to this node type.
CallbackNodeType & ComputeOutputDependencyMaskCallback(const DependencyCallbackNode::OutputDependencyFunction &function)
Sets an output dependency mask computation callback for this node type.
CallbackNodeType & Read(const TfToken &name)
Adds a ReadConnector to this node type.
CallbackNodeType & Out(const TfToken &name)
Adds an output to this node type.
A CallbackNode which allows for passing in a custom input / output dependency callback.
virtual VdfMask _ComputeOutputDependencyMask(const VdfConnection &inputConnection, const VdfMask &inputDependencyMask, const VdfOutput &output) const
Returns a mask that indicates which elements of the data that flows along output depend on the elemen...
virtual VdfMask::Bits _ComputeInputDependencyMask(const VdfMaskedOutput &maskedOutput, const VdfConnection &inputConnection) const
Returns a mask that indicates which elements of the data that flows along inputConnection are needed ...
Simple wrapper around ExecutionStats that allows for logging arbitrary data for testing.
VDF_API void LogBegin(VdfExecutionStats::EventType event, VdfId nodeId, uint64_t data)
Public log begin function.
VDF_API void LogEnd(VdfExecutionStats::EventType event, VdfId nodeId, uint64_t data)
Public log end function.
VDF_API void AddSubStat(VdfId nodeId)
Adds a sub stat to the internally held ExecutionStats.
ExecutionStats()
Constructor.
VDF_API void GetProcessedStats(VdfExecutionStatsProcessor *processor) const
Processes the processor using the internally held stats.
VDF_API void Log(VdfExecutionStats::EventType event, VdfId nodeId, uint64_t data)
Public log function.
~ExecutionStats()
Destructor.
Simple processor that processor ExecutionStats into a vector of vector of events and a vector of subs...
VDF_API void _ProcessSubStat(const VdfExecutionStats *stats) override
Virtual method implementing process sub stat for processing.
ExecutionStatsProcessor()
Constructor.
VDF_API void _ProcessEvent(VdfExecutionStatsProcessor::ThreadId threadId, const VdfExecutionStats::Event &event) override
Virtual method implementing process event for processing.
VDF_API ~ExecutionStatsProcessor()
Destructor.
This is a container class used to hold on to all the nodes and to facilitate their management.
VDF_API Node & operator[](const std::string &nodeName)
Returns a reference to a node named nodeName.
VDF_API void Add(const std::string &nodeName, VdfNode *customNode)
Takes ownership of a customNode that was created externally.
VDF_API const std::string GetNodeName(const VdfId nodeId)
Returns the node name for the VdfTestUtils::Node corresponding to a VdfNode with VdfId nodeId.
VDF_API VdfConnection * GetConnection(const std::string &connectionName)
Returns a pointer to a connection named connectionName.
VDF_API void Add(const std::string &nodeName, const NodeType &nodeType)
Creates a node named nodeName of type nodeType.
VdfNetwork & GetNetwork()
Returns a reference to the underlying VdfNetwork.
const VdfNetwork & GetNetwork() const
Returns a const reference to the underlying VdfNetwork.
VDF_API const Node & operator[](const std::string &nodeName) const
Returns a const reference to a node named nodeName.
void AddInputVector(const std::string &nodeName, size_t size=1)
Creates an input vector of type T named nodeName.
This class is a wrapper around a VdfNode.
Node & SetValue(int index, const T &val)
Set a value on this node.
VDF_API Node & operator>>(const _NodeInput &rhs)
Operator used to connect the default output of this node to the input described by rhs.
VDF_API _NodeInput In(const TfToken &inputName, const VdfMask &inputMask)
Returns an input to this node that can be connected to an output.
VDF_API _NodeOutput Output(const TfToken &outputName)
Returns an output to this node that can be connected to an input.
Base class for various kinds of nodes that can be created.
A helper class which enables access to a VdfOutput from a VdfContext.
uint64_t VdfId
The unique identifier type for Vdf objects.
VDF_API bool VdfIsParallelEvaluationEnabled()
Returns true if single-frame parallel evaluation is enabled.
This file contains classes to facilitate network creation in unit tests.
std::unique_ptr< VdfSpeculationExecutorBase > CreateSpeculationExecutor(const VdfSpeculationNode *speculationNode, const VdfExecutorInterface *parentExecutor)
Create a new test speculation executor.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...