24 #ifndef PXR_IMAGING_HD_ST_VBO_MEMORY_MANAGER_H 25 #define PXR_IMAGING_HD_ST_VBO_MEMORY_MANAGER_H 28 #include "pxr/imaging/hdSt/api.h" 29 #include "pxr/imaging/hd/version.h" 30 #include "pxr/imaging/hd/bufferArray.h" 31 #include "pxr/imaging/hdSt/bufferArrayRange.h" 32 #include "pxr/imaging/hd/bufferSpec.h" 33 #include "pxr/imaging/hd/bufferSource.h" 34 #include "pxr/imaging/hd/strategyBase.h" 42 PXR_NAMESPACE_OPEN_SCOPE
55 , _resourceRegistry(resourceRegistry) {}
62 HdBufferSpecVector
const &bufferSpecs,
73 HdBufferSpecVector
const &bufferSpecs,
78 HdBufferArraySharedPtr
const &bufferArray)
const;
82 HdBufferArraySharedPtr
const &bufferArray,
95 _stripedBufferArray(nullptr),
108 return (
bool)_stripedBufferArray;
124 bool Resize(
int numElements)
override;
128 void CopyData(HdBufferSourceSharedPtr
const &bufferSource)
override;
136 return _elementOffset;
169 HdStBufferResourceSharedPtr
GetResource()
const override;
177 HdStBufferResourceNamedList
const&
GetResources()
const override;
185 void DebugDump(std::ostream &out)
const override;
189 _elementOffset = offset;
194 _numElements = numElements;
204 _capacity = capacity;
209 _stripedBufferArray = NULL;
219 size_t _GetByteOffset(HdStBufferResourceSharedPtr
const& resource)
231 using _StripedBufferArraySharedPtr =
232 std::shared_ptr<_StripedBufferArray>;
233 using _StripedBufferArrayRangeSharedPtr =
234 std::shared_ptr<_StripedBufferArrayRange>;
235 using _StripedBufferArrayRangePtr =
236 std::weak_ptr<_StripedBufferArrayRange>;
246 HdBufferSpecVector
const &bufferSpecs,
260 void DebugDump(std::ostream &out)
const override;
266 std::vector<HdBufferArrayRangeSharedPtr>
const &ranges,
267 HdBufferArraySharedPtr
const &curRangeOwner)
override;
280 _needsCompaction =
true;
302 {
return _resourceList;}
310 void _DeallocateResources();
322 bool _needsCompaction;
324 size_t _maxBytesPerElement;
326 HdStBufferResourceNamedList _resourceList;
329 _StripedBufferArrayRangeSharedPtr _GetRangeSharedPtr(
size_t idx)
const {
330 return std::static_pointer_cast<_StripedBufferArrayRange>(
GetRange(idx).lock());
337 PXR_NAMESPACE_CLOSE_SCOPE
339 #endif // PXR_IMAGING_HD_ST_VBO_MEMORY_MANAGER_H size_t AggregationId
Aggregation ID.
The union provides a set of flags that provide hints to the memory management system about the proper...
HDST_API _StripedBufferArray(HdStResourceRegistry *resourceRegistry, TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
Constructor.
HDST_API void DebugDump(std::ostream &out) const override
Debug dump.
HDST_API HdBufferSpecVector GetBufferSpecs() const
Reconstructs the bufferspecs and returns it (for buffer splitting)
HDST_API HdStBufferResourceNamedList const & GetResources() const override
Returns the list of all named GPU resources for this bufferArrayRange.
HDST_API size_t GetMaxNumElements() const override
Returns the max number of elements.
void SetElementOffset(int offset)
Set the relative offset for this range.
HDST_API void SetBufferArray(HdBufferArray *bufferArray) override
Sets the buffer array associated with this buffer;.
int GetCapacity() const
Returns the capacity of allocated area.
Similar to a VAO, this object is a bundle of coherent buffers.
HDST_API bool Resize(int numElements) override
Resize memory area for this range.
Aggregation strategy base class.
HD_API void IncrementVersion()
Increments the version of this buffer array.
HDST_API bool GarbageCollect() override
perform compaction if necessary.
Interface class for representing range (subset) locator of HdBufferArray.
virtual HDST_API HdBufferArraySharedPtr CreateBufferArray(TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
Factory for creating HdBufferArray managed by HdStVBOMemoryManager aggregation.
HdTupleType represents zero, one, or more values of the same HdType.
A map with string keys and VtValue values.
bool IsImmutable() const override
Returns true if this bar is marked as immutable.
HDST_API HdStBufferResourceSharedPtr GetResource() const override
Returns the GPU resource.
virtual size_t GetResourceAllocation(HdBufferArraySharedPtr const &bufferArray, VtDictionary &result) const
Returns the size of the GPU memory used by the passed buffer array.
HDST_API void DebugDump(std::ostream &out) const override
Debug output.
bool IsValid() const override
Returns true if this range is valid.
HdStBufferResourceNamedList const & GetResources() const
Returns the list of all named GPU resources for this bufferArray.
Token for efficient comparison, assignment, and hashing of known strings.
HDST_API HdBufferArrayUsageHint GetUsageHint() const override
Returns the usage hint from the underlying buffer array.
void SetCapacity(int capacity)
Set the capacity of allocated area for this range.
HDST_API ~_StripedBufferArray() override
Destructor. It invalidates _rangeList.
void SetNumElements(int numElements)
Set the number of elements for this range.
virtual HdBufferSpecVector GetBufferSpecs(HdBufferArraySharedPtr const &bufferArray) const
Returns the buffer specs from a given buffer array.
A central registry of all GPU resources.
HDST_API HdStBufferResourceSharedPtr _AddResource(TfToken const &name, HdTupleType tupleType, int offset, int stride)
Adds a new, named GPU resource and returns it.
int GetByteOffset(TfToken const &resourceName) const override
Returns the byte offset at which this range begins in the underlying buffer array for the given resou...
void Invalidate()
Make this range invalid.
void SetNeedsReallocation()
Mark to perform reallocation on Reallocate()
HDST_API size_t GetMaxNumElements() const override
Returns the maximum number of elements capacity.
HDST_API HdStBufferResourceSharedPtr GetResource() const
TODO: We need to distinguish between the primvar types here, we should tag each HdBufferSource and Hd...
HDST_API void Reallocate(std::vector< HdBufferArrayRangeSharedPtr > const &ranges, HdBufferArraySharedPtr const &curRangeOwner) override
Performs reallocation.
virtual HDST_API AggregationId ComputeAggregationId(HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint) const
Returns id for given bufferSpecs to be used for aggregation.
_StripedBufferArrayRange(HdStResourceRegistry *resourceRegistry)
Constructor.
void IncrementVersion() override
Increment the version of the buffer array.
void SetNeedsCompaction()
Mark to perform compaction on GarbageCollect()
HDST_API const void * _GetAggregation() const override
Returns the aggregation container.
HDST_API VtValue ReadData(TfToken const &name) const override
Read back the buffer content.
HD_API HdBufferArrayRangePtr GetRange(size_t idx) const
Get the attached range at the specified index.
virtual HDST_API HdBufferArrayRangeSharedPtr CreateBufferArrayRange()
Factory for creating HdBufferArrayRange managed by HdStVBOMemoryManager aggregation.
HDST_API void CopyData(HdBufferSourceSharedPtr const &bufferSource) override
Copy source data into buffer.
size_t GetVersion() const override
Returns the version of the buffer array.
specialized buffer array range
bool _needsReallocation
Dirty bit to set when the ranges attached to the buffer changes.
bool RequiresStaging() const override
Returns true if this needs a staging buffer for CPU to GPU copies.
HDST_API bool IsAssigned() const override
Returns true is the range has been assigned to a buffer.
HDST_API ~_StripedBufferArrayRange() override
Destructor.
int GetElementOffset() const override
Returns the relative element offset in aggregated buffer.
size_t GetNumElements() const override
Returns the number of elements.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
size_t GetVersion() const
Returns the version of this buffer array.