7#ifndef PXR_EXEC_VDF_EXECUTOR_DATA_VECTOR_H
8#define PXR_EXEC_VDF_EXECUTOR_DATA_VECTOR_H
14#include "pxr/exec/vdf/api.h"
21#include <tbb/concurrent_vector.h>
25PXR_NAMESPACE_OPEN_SCOPE
81 return &_bufferData[handle];
91 return &_invalidationData[handle];
102 return _outputData[handle].invalidationTimestamp;
113 _outputData[handle].invalidationTimestamp = ts;
124 return _smblData[handle].get();
134 if (!_smblData[handle]) {
137 return _smblData[handle].get();
147 return _outputData[handle].touched;
157 _outputData[handle].touched =
true;
167 const bool wasTouched = _outputData[handle].touched;
168 _outputData[handle].touched =
false;
175 return _locations.size();
181 return _bufferData.size();
199 _OutputData(
const VdfId oid) :
201 invalidationTimestamp(
202 VdfExecutorInvalidationData::InitialInvalidationTimestamp),
206 void Reset(
const VdfId oid) {
208 invalidationTimestamp =
209 VdfExecutorInvalidationData::InitialInvalidationTimestamp;
219 using _LocationsSegment = uint32_t *;
224 _LocationsSegment _CreateSegment(
size_t segmentIndex);
228 inline void _CreateData(
const VdfId outputId);
231 constexpr static size_t _InitialExecutorDataNum = 1000;
235 constexpr static size_t _SegmentSize = 4096;
238 std::vector<_LocationsSegment> _locations;
244 tbb::concurrent_vector<_OutputData> _outputData;
245 tbb::concurrent_vector<VdfExecutorBufferData> _bufferData;
246 tbb::concurrent_vector<VdfExecutorInvalidationData> _invalidationData;
247 tbb::concurrent_vector<std::unique_ptr<VdfSMBLData>> _smblData;
260 const size_t segmentIndex = outputIndex / _SegmentSize;
264 _LocationsSegment segment = _locations[segmentIndex];
266 segment = _CreateSegment(segmentIndex);
270 const size_t segmentOffset = outputIndex & (_SegmentSize - 1);
271 uint32_t *
const location = &segment[segmentOffset];
279 if (*location >= numData ||
281 _outputData[*location].outputId)) {
283 _CreateData(outputId);
290 else if (outputId != _outputData[*location].outputId) {
291 Reset(*location, outputId);
305 const size_t segmentIndex = outputIndex / _SegmentSize;
309 if (segmentIndex >= _locations.size() || !_locations[segmentIndex]) {
317 const size_t segmentOffset = outputIndex & (_SegmentSize - 1);
318 const uint32_t location = _locations[segmentIndex][segmentOffset];
320 location <
GetNumData() && outputId == _outputData[location].outputId
328 _outputData[handle].Reset(outputId);
329 _bufferData[handle].Reset();
330 _invalidationData[handle].Reset();
331 _smblData[handle].reset();
335Vdf_ExecutorDataVector::_CreateData(
const VdfId outputId)
337 _outputData.emplace_back(outputId);
338 _bufferData.emplace_back();
339 _invalidationData.emplace_back();
340 _smblData.emplace_back();
343PXR_NAMESPACE_CLOSE_SCOPE
A vector-like container for executor data used by the VdfDataManagerVector.
size_t GetSize() const
Returns the size of the container.
size_t GetNumData() const
Returns the number of outputs that have data associated with them.
VDF_API void Resize(const VdfNetwork &network)
Resize the vector to be able to accommodate all outputs in the given network.
VdfExecutorBufferData * GetBufferData(const DataHandle handle)
Returns the VdfExecutorBufferData associated with the given handle.
VdfInvalidationTimestamp GetInvalidationTimestamp(const DataHandle handle) const
Returns the VdfInvalidationTimestamp associated with the given handle.
VdfExecutorInvalidationData * GetInvalidationData(const DataHandle handle)
Returns the VdfExecutorInvalidationData associated with the given handle.
VdfSMBLData * GetOrCreateSMBLData(const DataHandle handle)
Returns an existing VdfSMBLData associated with the given handle or creates a new one of none exists.
size_t DataHandle
The data handle type is an index into the internal data vectors.
static const size_t InvalidHandle
This sentinel index denotes an invalid handle.
VdfSMBLData * GetSMBLData(const DataHandle handle) const
Returns an existing VdfSMBLData associated with the given handle.
void Touch(const DataHandle handle)
Marks the data at the given handle as having been touched by evaluation.
VDF_API ~Vdf_ExecutorDataVector()
Destructor.
void Reset(const DataHandle handle, const VdfId outputId)
Resets the output data at the given data handle to a newly constructed state.
bool Untouch(const DataHandle handle)
Marks the data at the given handle as not having been touched by evaluation.
DataHandle GetDataHandle(const VdfId outputId) const
Returns an existing data handle for the given output.
void SetInvalidationTimestamp(const DataHandle &handle, VdfInvalidationTimestamp ts)
Sets the invalidation timestamp for the give data handle.
VDF_API void Clear()
Clears all the data in the container.
bool IsTouched(const DataHandle handle)
Returns true if the data at the given handle has been touched by evaluation.
DataHandle GetOrCreateDataHandle(const VdfId outputId)
Returns an existing data handle, or creates a new one for the given output.
This object is responsible for storing the executor buffer data, comprised of the executor cache vect...
A VdfNetwork is a collection of VdfNodes and their connections.
static VdfIndex GetIndexFromId(const VdfId id)
Get the output index from the output id.
VdfSMBLData holds per-output data that is meant to be consumed by the executor.
uint64_t VdfId
The unique identifier type for Vdf objects.
unsigned int VdfInvalidationTimestamp
Type of the timestamp that identifies the most recent round of invalidation.
uint32_t VdfIndex
The index type for Vdf objects.
#define TF_DEV_AXIOM(cond)
The same as TF_AXIOM, but compiled only in dev builds.