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"
31 #include "pxr/imaging/hd/bufferResource.h"
33 #include "pxr/base/vt/value.h"
39 PXR_NAMESPACE_OPEN_SCOPE
44 using HdBufferArraySharedPtr = std::shared_ptr<class HdBufferArray>;
45 using HdBufferArrayRangeSharedPtr = std::shared_ptr<HdBufferArrayRange>;
46 using HdBufferArrayRangePtr = std::weak_ptr<HdBufferArrayRange>;
72 uint32_t immutable : 1;
73 uint32_t sizeVarying : 1;
88 class HdBufferArray :
public std::enable_shared_from_this<HdBufferArray>
93 TfToken const garbageCollectionPerfToken,
97 virtual ~HdBufferArray();
127 std::vector<HdBufferArrayRangeSharedPtr>
const &ranges,
128 HdBufferArraySharedPtr
const &curRangeOwner) = 0;
135 virtual void DebugDump(std::ostream &out)
const = 0;
142 HdBufferArrayRangePtr
GetRange(
size_t idx)
const;
156 return _usageHint.bits.immutable;
175 void _SetRangeList(std::vector<HdBufferArrayRangeSharedPtr>
const &ranges);
180 HdBufferArray(
const HdBufferArray &) =
delete;
181 HdBufferArray &operator=(
const HdBufferArray &) =
delete;
184 typedef std::vector<HdBufferArrayRangePtr> _RangeList;
191 _RangeList _rangeList;
192 std::atomic_size_t _rangeCount;
193 std::mutex _rangeListLock;
196 const TfToken _garbageCollectionPerfToken;
200 size_t _maxNumRanges;
205 PXR_NAMESPACE_CLOSE_SCOPE
207 #endif //PXR_IMAGING_HD_BUFFER_ARRAY_H
The union provides a set of flags that provide hints to the memory management system about the proper...
HdBufferArrayUsageHint GetUsageHint() const
Returns the usage hints for this buffer array.
Similar to a VAO, this object is a bundle of coherent buffers.
virtual void Reallocate(std::vector< HdBufferArrayRangeSharedPtr > const &ranges, HdBufferArraySharedPtr const &curRangeOwner)=0
Performs reallocation.
HD_API void IncrementVersion()
Increments the version of this buffer array.
bool IsImmutable() const
Returns true if this buffer array is marked as immutable.
Interface class for representing range (subset) locator of HdBufferArray.
HD_API HdBufferArrayRangePtr GetRange(size_t idx) const
Get the attached range at the specified index.
void _SetMaxNumRanges(size_t max)
Limits the number of ranges that can be allocated to this buffer to max.
Token for efficient comparison, assignment, and hashing of known strings.
virtual bool GarbageCollect()=0
Performs compaction if necessary and returns true if it becomes empty.
TfToken const & GetRole() const
Returns the role of the GPU data in this bufferArray.
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.
virtual HD_API size_t GetMaxNumElements() const
Returns the maximum number of elements capacity.
HD_API void RemoveUnusedRanges()
Remove any ranges from the range list that have been deallocated Returns number of ranges after clean...
HD_API bool TryAssignRange(HdBufferArrayRangeSharedPtr &range)
Attempts to assign a range to this buffer array.
size_t GetVersion() const
Returns the version of this buffer array.
virtual void DebugDump(std::ostream &out) const =0
Debug output.
bool _needsReallocation
Dirty bit to set when the ranges attached to the buffer changes.
bool NeedsReallocation() const
Returns true if Reallocate() needs to be called on this buffer array.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...