7#ifndef PXR_IMAGING_HD_BUFFER_ARRAY_H
8#define PXR_IMAGING_HD_BUFFER_ARRAY_H
11#include "pxr/imaging/hd/api.h"
12#include "pxr/imaging/hd/version.h"
13#include "pxr/imaging/hd/bufferSpec.h"
15#include "pxr/base/vt/value.h"
21PXR_NAMESPACE_OPEN_SCOPE
26using HdBufferArraySharedPtr = std::shared_ptr<class HdBufferArray>;
27using HdBufferArrayRangeSharedPtr = std::shared_ptr<HdBufferArrayRange>;
28using HdBufferArrayRangePtr = std::weak_ptr<HdBufferArrayRange>;
51enum HdBufferArrayUsageHintBits : uint32_t
53 HdBufferArrayUsageHintBitsImmutable = 1 << 0,
54 HdBufferArrayUsageHintBitsSizeVarying = 1 << 1,
55 HdBufferArrayUsageHintBitsUniform = 1 << 2,
56 HdBufferArrayUsageHintBitsStorage = 1 << 3,
57 HdBufferArrayUsageHintBitsVertex = 1 << 4,
58 HdBufferArrayUsageHintBitsIndex = 1 << 5,
60using HdBufferArrayUsageHint = uint32_t;
73 TfToken const garbageCollectionPerfToken,
74 HdBufferArrayUsageHint usageHint);
107 std::vector<HdBufferArrayRangeSharedPtr>
const &ranges,
108 HdBufferArraySharedPtr
const &curRangeOwner) = 0;
136 return _usageHint & HdBufferArrayUsageHintBitsImmutable;
164 typedef std::vector<HdBufferArrayRangePtr> _RangeList;
171 _RangeList _rangeList;
172 std::atomic_size_t _rangeCount;
173 std::mutex _rangeListLock;
176 const TfToken _garbageCollectionPerfToken;
180 size_t _maxNumRanges;
181 HdBufferArrayUsageHint _usageHint;
185PXR_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...