24#ifndef PXR_IMAGING_HD_BUFFER_ARRAY_H
25#define PXR_IMAGING_HD_BUFFER_ARRAY_H
28#include "pxr/imaging/hd/api.h"
29#include "pxr/imaging/hd/version.h"
30#include "pxr/imaging/hd/bufferSpec.h"
32#include "pxr/base/vt/value.h"
38PXR_NAMESPACE_OPEN_SCOPE
43using HdBufferArraySharedPtr = std::shared_ptr<class HdBufferArray>;
44using HdBufferArrayRangeSharedPtr = std::shared_ptr<HdBufferArrayRange>;
45using HdBufferArrayRangePtr = std::weak_ptr<HdBufferArrayRange>;
68enum HdBufferArrayUsageHintBits : uint32_t
70 HdBufferArrayUsageHintBitsImmutable = 1 << 0,
71 HdBufferArrayUsageHintBitsSizeVarying = 1 << 1,
72 HdBufferArrayUsageHintBitsUniform = 1 << 2,
73 HdBufferArrayUsageHintBitsStorage = 1 << 3,
74 HdBufferArrayUsageHintBitsVertex = 1 << 4,
75 HdBufferArrayUsageHintBitsIndex = 1 << 5,
77using HdBufferArrayUsageHint = uint32_t;
90 TfToken const garbageCollectionPerfToken,
91 HdBufferArrayUsageHint usageHint);
124 std::vector<HdBufferArrayRangeSharedPtr>
const &ranges,
125 HdBufferArraySharedPtr
const &curRangeOwner) = 0;
153 return _usageHint & HdBufferArrayUsageHintBitsImmutable;
181 typedef std::vector<HdBufferArrayRangePtr> _RangeList;
188 _RangeList _rangeList;
189 std::atomic_size_t _rangeCount;
190 std::mutex _rangeListLock;
193 const TfToken _garbageCollectionPerfToken;
197 size_t _maxNumRanges;
198 HdBufferArrayUsageHint _usageHint;
202PXR_NAMESPACE_CLOSE_SCOPE
Similar to a VAO, this object is a bundle of coherent buffers.
virtual bool GarbageCollect()=0
Performs compaction if necessary and returns true if it becomes empty.
virtual void DebugDump(std::ostream &out) const =0
Debug output.
virtual void Reallocate(std::vector< HdBufferArrayRangeSharedPtr > const &ranges, HdBufferArraySharedPtr const &curRangeOwner)=0
Performs reallocation.
virtual HD_API size_t GetMaxNumElements() const
Returns the maximum number of elements capacity.
bool IsImmutable() const
Returns true if this buffer array is marked as immutable.
void _SetMaxNumRanges(size_t max)
Limits the number of ranges that can be allocated to this buffer to max.
bool NeedsReallocation() const
Returns true if Reallocate() needs to be called on this buffer array.
bool _needsReallocation
Dirty bit to set when the ranges attached to the buffer changes.
HD_API void IncrementVersion()
Increments the version of this buffer array.
HD_API void RemoveUnusedRanges()
Remove any ranges from the range list that have been deallocated Returns number of ranges after clean...
HdBufferArrayUsageHint GetUsageHint() const
Returns the usage hints for this buffer array.
HD_API HdBufferArrayRangePtr GetRange(size_t idx) const
Get the attached range at the specified index.
size_t GetVersion() const
Returns the version of this buffer array.
HD_API bool TryAssignRange(HdBufferArrayRangeSharedPtr &range)
Attempts to assign a range to this buffer array.
HD_API void _SetRangeList(std::vector< HdBufferArrayRangeSharedPtr > const &ranges)
Swap the rangelist with ranges.
size_t GetRangeCount() const
How many ranges are attached to the buffer array.
TfToken const & GetRole() const
Returns the role of the GPU data in this bufferArray.
Interface class for representing range (subset) locator of HdBufferArray.
Token for efficient comparison, assignment, and hashing of known strings.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...