24 #ifndef PXR_IMAGING_HD_ST_INTERLEAVED_MEMORY_MANAGER_H
25 #define PXR_IMAGING_HD_ST_INTERLEAVED_MEMORY_MANAGER_H
38 #include "pxr/base/tf/mallocTag.h"
43 #include <unordered_map>
65 , _stripedBuffer(nullptr)
66 , _index(NOT_ALLOCATED)
77 return (
bool)_stripedBuffer;
93 bool Resize(
int numElements)
override;
113 if (!TF_VERIFY(_stripedBuffer) ||
114 !TF_VERIFY(_index != NOT_ALLOCATED))
return 0;
115 return _stripedBuffer->
GetStride() * _index;
164 void DebugDump(std::ostream &out)
const override;
173 _stripedBuffer =
nullptr;
183 _capacity = capacity;
192 enum { NOT_ALLOCATED = -1 };
193 _StripedInterleavedBuffer *_stripedBuffer;
200 std::shared_ptr<_StripedInterleavedBuffer>;
202 std::shared_ptr<_StripedInterleavedBufferRange>;
204 std::weak_ptr<_StripedInterleavedBufferRange>;
216 int bufferOffsetAlignment,
219 TfToken const &garbageCollectionPerfToken);
231 virtual void DebugDump(std::ostream &out)
const;
237 std::vector<HdBufferArrayRangeSharedPtr>
const &ranges,
247 _needsCompaction =
true;
256 return _elementStride;
297 bool _needsCompaction;
299 int _bufferOffsetAlignment;
312 size_t _elementStride;
382 #endif // PXR_IMAGING_HD_ST_INTERLEAVED_MEMORY_MANAGER_H
void SetCapacity(int capacity)
Set the capacity of allocated area for this range.
HDST_API bool Resize(int numElements) override
HDST_API HdStBufferResourceNamedList const & GetResources() const override
Returns the list of all named GPU resources for this bufferArrayRange.
void SetNeedsCompaction()
Mark to perform compaction on GarbageCollect()
std::weak_ptr< _StripedInterleavedBufferRange > _StripedInterleavedBufferRangePtr
size_t GetVersion() const override
Returns the version of the buffer array.
HDST_API HdBufferSpecVector GetBufferSpecs() const
Reconstructs the bufferspecs and returns it (for buffer splitting)
size_t GetStride() const
Returns the stride.
HDST_API HdBufferArrayUsageHint GetUsageHint() const override
Returns the usage hint from the underlying buffer array.
HDST_API ~_StripedInterleavedBufferRange() override
Destructor.
std::shared_ptr< class HdBufferArray > HdBufferArraySharedPtr
HDST_API size_t GetMaxNumElements() const override
Returns the max number of elements.
HdStInterleavedMemoryManager(HdStResourceRegistry *resourceRegistry)
std::vector< std::pair< TfToken, HdStBufferResourceSharedPtr > > HdStBufferResourceNamedList
bool IsImmutable() const override
Returns true if this range is marked as immutable.
HdStInterleavedSSBOMemoryManager(HdStResourceRegistry *resourceRegistry)
virtual HDST_API ~_StripedInterleavedBuffer()
Destructor. It invalidates _rangeList.
virtual HDST_API bool GarbageCollect()
perform compaction if necessary, returns true if it becomes empty.
HdStBufferResourceNamedList const & GetResources() const
Returns the list of all named GPU resources for this bufferArray.
**But if you need a result
specialized buffer array range
int GetElementStride() const override
HdStInterleavedUBOMemoryManager(HdStResourceRegistry *resourceRegistry)
int GetElementOffset() const override
virtual HDST_API void Reallocate(std::vector< HdBufferArrayRangeSharedPtr > const &ranges, HdBufferArraySharedPtr const &curRangeOwner)
HDST_API void SetBufferArray(HdBufferArray *bufferArray) override
Sets the buffer array associated with this buffer;.
HD_API HdBufferArrayRangePtr GetRange(size_t idx) const
Get the attached range at the specified index.
size_t AggregationId
Aggregation ID.
HDST_API void DebugDump(std::ostream &out) const override
Debug dump.
virtual HDST_API HdBufferArraySharedPtr CreateBufferArray(TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
bool IsValid() const override
Returns true if this range is valid.
HD_API void IncrementVersion()
Increments the version of this buffer array.
std::shared_ptr< _StripedInterleavedBuffer > _StripedInterleavedBufferSharedPtr
virtual HDST_API void DebugDump(std::ostream &out) const
Debug output.
_StripedInterleavedBufferRange(HdStResourceRegistry *resourceRegistry)
Constructor.
std::shared_ptr< _StripedInterleavedBufferRange > _StripedInterleavedBufferRangeSharedPtr
bool RequiresStaging() const override
Returns true if this needs a staging buffer for CPU to GPU copies.
GLint GLenum GLboolean GLsizei stride
HDST_API VtValue ReadData(TfToken const &name) const override
Read back the buffer content.
HDST_API bool IsAssigned() const override
Returns true is the range has been assigned to a buffer.
HdStInterleavedMemoryManager * GetManager() const
HdBufferArrayRangeSharedPtr CreateBufferArrayRange() override
Factory for creating HdBufferArrayRange.
void Invalidate()
Make this range invalid.
GLuint const GLchar * name
std::vector< struct HdBufferSpec > HdBufferSpecVector
size_t GetResourceAllocation(HdBufferArraySharedPtr const &bufferArray, VtDictionary &result) const override
Returns the size of the GPU memory used by the passed buffer array.
HDST_API void CopyData(HdBufferSourceSharedPtr const &bufferSource) override
Copy source data into buffer.
std::shared_ptr< class HdStBufferResource > HdStBufferResourceSharedPtr
HDST_API HdStBufferResourceSharedPtr GetResource() const override
size_t GetVersion() const
HDST_API const void * _GetAggregation() const override
Returns the aggregation container.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
virtual HDST_API HdBufferArraySharedPtr CreateBufferArray(TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
HDST_API HdStBufferResourceSharedPtr GetResource() const
void SetIndex(int index)
Set the relative offset for this range.
size_t GetElementStride() const
#define PXR_NAMESPACE_CLOSE_SCOPE
std::shared_ptr< HdBufferArrayRange > HdBufferArrayRangeSharedPtr
int GetCapacity() const
Returns the capacity of allocated area.
void SetNeedsReallocation()
Mark to perform reallocation on Reallocate()
size_t GetNumElements() const override
Returns the number of elements.
virtual HDST_API AggregationId ComputeAggregationId(HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint) const
Returns id for given bufferSpecs to be used for aggregation.
HDST_API void _DeallocateResources()
std::shared_ptr< class HdBufferSource > HdBufferSourceSharedPtr
void IncrementVersion() override
Increment the version of the buffer array.
int GetByteOffset(TfToken const &resourceName) const override
HdStResourceRegistry *const _resourceRegistry
HDST_API HdStBufferResourceSharedPtr _AddResource(TfToken const &name, HdTupleType tupleType, int offset, int stride)
Adds a new, named GPU resource and returns it.
virtual HDST_API AggregationId ComputeAggregationId(HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint) const
Returns id for given bufferSpecs to be used for aggregation.
HDST_API _StripedInterleavedBuffer(HdStInterleavedMemoryManager *mgr, HdStResourceRegistry *resourceRegistry, TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint, int bufferOffsetAlignment, int structAlignment, size_t maxSize, TfToken const &garbageCollectionPerfToken)
Constructor.
HdBufferSpecVector GetBufferSpecs(HdBufferArraySharedPtr const &bufferArray) const override
Returns the buffer specs from a given buffer array.