7 #ifndef PXR_EXEC_VDF_EXECUTOR_BUFFER_DATA_H 8 #define PXR_EXEC_VDF_EXECUTOR_BUFFER_DATA_H 14 #include "pxr/exec/vdf/api.h" 20 PXR_NAMESPACE_OPEN_SCOPE
132 static constexpr uintptr_t _IsOwnedFlag = 1 << 0;
135 static constexpr uintptr_t _IsOccupiedFlag = 1 << 1;
138 static constexpr uintptr_t _FlagsMask = _IsOwnedFlag | _IsOccupiedFlag;
141 static VdfVector *_CastToPointer(uintptr_t v) {
142 return reinterpret_cast<VdfVector *>(reinterpret_cast<void *>(v));
146 static uintptr_t _CastToInteger(
VdfVector *v) {
147 return reinterpret_cast<uintptr_t>(reinterpret_cast<void *>(v));
152 return _CastToPointer(_CastToInteger(cacheAndFlags) & ~_FlagsMask);
156 static uintptr_t _GetFlags(
VdfVector *cacheAndFlags) {
157 return _CastToInteger(cacheAndFlags) & _FlagsMask;
162 VdfVector *cacheAndFlags, uintptr_t flags) {
163 return _CastToPointer(_CastToInteger(cacheAndFlags) | flags);
168 VdfVector *cacheAndFlags, uintptr_t flags) {
169 return _CastToPointer(_CastToInteger(cacheAndFlags) & ~flags);
184 std::atomic<VdfVector *> _cacheAndFlags;
196 VdfVector *cacheAndFlags = _cacheAndFlags.load(std::memory_order_acquire);
200 if (_GetCache(cacheAndFlags) && _GetFlags(cacheAndFlags) & _IsOwnedFlag) {
201 _cacheAndFlags.store(
202 _SetFlags(cacheAndFlags, _IsOccupiedFlag),
203 std::memory_order_release);
204 return _GetCache(cacheAndFlags);
211 _cacheAndFlags.store(
212 _SetFlags(newCache, _IsOwnedFlag | _IsOccupiedFlag),
213 std::memory_order_release);
232 VdfVector *cacheAndFlags = _cacheAndFlags.load(std::memory_order_acquire);
234 rhs->_cacheAndFlags.load(std::memory_order_acquire);
236 _cacheAndFlags.store(rhsCacheAndFlags, std::memory_order_release);
237 rhs->_cacheAndFlags.store(cacheAndFlags, std::memory_order_release);
239 return _GetCache(rhsCacheAndFlags);
245 VdfVector *cacheAndFlags = _cacheAndFlags.load(std::memory_order_acquire);
246 return (_GetFlags(cacheAndFlags) & _IsOccupiedFlag)
247 ? _GetCache(cacheAndFlags)
262 VdfVector *cacheAndFlags = _cacheAndFlags.load(std::memory_order_acquire);
263 if (_GetFlags(cacheAndFlags) & _IsOccupiedFlag) {
264 _cacheAndFlags.store(
265 _UnsetFlags(cacheAndFlags, _IsOccupiedFlag),
266 std::memory_order_release);
290 VdfVector *cacheAndFlags = _cacheAndFlags.load(std::memory_order_relaxed);
291 return (_GetFlags(cacheAndFlags) & _IsOwnedFlag) != 0;
297 VdfVector *cacheAndFlags = _cacheAndFlags.load(std::memory_order_acquire);
298 _cacheAndFlags.store(
299 _UnsetFlags(cacheAndFlags, _IsOwnedFlag), std::memory_order_release);
310 _cacheAndFlags.store(
311 _SetFlags(v, _IsOccupiedFlag), std::memory_order_release);
322 _cacheAndFlags.store(
323 _SetFlags(v, _IsOccupiedFlag | _IsOwnedFlag),
324 std::memory_order_release);
327 PXR_NAMESPACE_CLOSE_SCOPE
#define TF_DEV_AXIOM(cond)
The same as TF_AXIOM, but compiled only in dev builds.
void TakeOwnership(VdfVector *v)
Assumes ownership of the given vector.
VDF_API VdfVector * AllocateCache() const
Allocate a new VdfVector with this spec's type.
VDF_API ~VdfExecutorBufferData()
Destructor.
A VdfMask is placed on connections to specify the data flowing through them.
Fast, compressed bit array which is capable of performing logical operations without first decompress...
This class is used to abstract away knowledge of the cache data used for each node.
const VdfMask & GetExecutorCacheMask() const
Get the available mask.
void ResetExecutorCache()
Reset the executor cache without releasing any memory.
VdfVector * GetExecutorCache() const
Returns the executor cache stored at this buffer data instance.
VDF_API VdfMask ReleaseExecutorCache(VdfSMBLData *smblData)
Merges the executor cache previously retained in smblData into this cache and releases the SMBL data.
VdfSMBLData holds per-output data that is meant to be consumed by the executor.
VDF_API void RetainExecutorCache(const VdfOutputSpec &spec, VdfSMBLData *smblData)
Takes the existing executor cache and retains it within the existing VdfSMBLData object.
This object is responsible for storing the executor buffer data, comprised of the executor cache vect...
void YieldOwnership()
Yields ownership of the internal vector, i.e.
VdfVector * SwapExecutorCache(VdfExecutorBufferData *rhs)
Swaps the executor cache at this buffer, with that of another buffer.
void SetExecutorCacheMask(const VdfMask &mask)
Sets the available mask.
VDF_API void Clone(VdfExecutorBufferData *dest) const
Clones this VdfExecutorBufferData instance to dest.
VdfVector * CreateExecutorCache(const VdfOutputSpec &spec)
Creates a new executor cache for this buffer.
bool HasOwnership() const
Returns true if the buffer owns the executor cache.
VDF_API void ResizeCache(VdfVector *vector, const VdfMask::Bits &bits) const
Resize an existing VdfVector to accomodate all the data set in the bits.
A VdfOuptutSpec describes an output connector.
VDF_API void Reset()
Reset the instance to its original, newly constructed state.
VdfExecutorBufferData()
Constructor.