24 #ifndef PXR_IMAGING_HD_ST_VBO_SIMPLE_MEMORY_MANAGER_H
25 #define PXR_IMAGING_HD_ST_VBO_SIMPLE_MEMORY_MANAGER_H
28 #include "pxr/imaging/hdSt/api.h"
29 #include "pxr/imaging/hdSt/bufferArrayRange.h"
30 #include "pxr/imaging/hdSt/resourceRegistry.h"
31 #include "pxr/imaging/hd/version.h"
32 #include "pxr/imaging/hd/strategyBase.h"
33 #include "pxr/imaging/hd/bufferArray.h"
34 #include "pxr/imaging/hd/bufferSpec.h"
35 #include "pxr/imaging/hd/bufferSource.h"
37 PXR_NAMESPACE_OPEN_SCOPE
51 : _resourceRegistry(resourceRegistry) {}
58 HdBufferSpecVector
const &bufferSpecs,
68 HdBufferSpecVector
const &bufferSpecs,
73 HdBufferArraySharedPtr
const &bufferArray)
const;
77 HdBufferArraySharedPtr
const &bufferArray,
93 , _bufferArray(nullptr)
99 return (
bool)_bufferArray;
112 _numElements = numElements;
113 return _bufferArray->
Resize(numElements);
118 void CopyData(HdBufferSourceSharedPtr
const &bufferSource)
override;
168 HdStBufferResourceSharedPtr
GetResource()
const override;
176 HdStBufferResourceNamedList
const&
GetResources()
const override;
184 void DebugDump(std::ostream &out)
const override;
208 using _SimpleBufferArraySharedPtr =
209 std::shared_ptr<_SimpleBufferArray>;
210 using _SimpleBufferArrayRangeSharedPtr =
211 std::shared_ptr<_SimpleBufferArrayRange>;
212 using _SimpleBufferArrayRangePtr =
213 std::weak_ptr<_SimpleBufferArrayRange>;
226 HdBufferSpecVector
const &bufferSpecs,
239 void DebugDump(std::ostream &out)
const override;
243 bool Resize(
int numElements);
249 std::vector<HdBufferArrayRangeSharedPtr>
const &ranges,
250 HdBufferArraySharedPtr
const &curRangeOwner)
override;
279 HdStBufferResourceNamedList
const&
GetResources()
const {
return _resourceList;}
287 void _DeallocateResources();
298 size_t _maxBytesPerElement;
300 HdStBufferResourceNamedList _resourceList;
302 _SimpleBufferArrayRangeSharedPtr _GetRangeSharedPtr()
const {
305 : _SimpleBufferArrayRangeSharedPtr();
312 PXR_NAMESPACE_CLOSE_SCOPE
314 #endif // PXR_IMAGING_HD_ST_VBO_SIMPLE_MEMORY_MANAGER_H
HDST_API const void * _GetAggregation() const override
Returns the aggregation container.
HDST_API void Reallocate(std::vector< HdBufferArrayRangeSharedPtr > const &ranges, HdBufferArraySharedPtr const &curRangeOwner) override
Performs reallocation.
size_t AggregationId
Aggregation ID.
The union provides a set of flags that provide hints to the memory management system about the proper...
bool IsValid() const override
Returns true if this range is valid.
virtual HDST_API HdBufferArrayRangeSharedPtr CreateBufferArrayRange()
Factory for creating HdBufferArrayRange.
virtual size_t GetResourceAllocation(HdBufferArraySharedPtr const &bufferArray, VtDictionary &result) const
Returns the size of the GPU memory used by the passed buffer array.
Similar to a VAO, this object is a bundle of coherent buffers.
HDST_API HdStBufferResourceSharedPtr GetResource() const override
Returns the GPU resource.
VBO simple memory manager.
Aggregation strategy base class.
HDST_API HdStBufferResourceSharedPtr _AddResource(TfToken const &name, HdTupleType tupleType, int offset, int stride)
Adds a new, named GPU resource and returns it.
HD_API void IncrementVersion()
Increments the version of this buffer array.
_SimpleBufferArrayRange(HdStResourceRegistry *resourceRegistry)
Constructor.
Interface class for representing range (subset) locator of HdBufferArray.
HdTupleType represents zero, one, or more values of the same HdType.
A map with string keys and VtValue values.
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...
virtual HDST_API HdBufferArraySharedPtr CreateBufferArray(TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
Factory for creating HdBufferArray managed by HdStVBOSimpleMemoryManager.
bool IsImmutable() const override
Returns true if this range is marked as immutable.
HD_API HdBufferArrayRangePtr GetRange(size_t idx) const
Get the attached range at the specified index.
HDST_API size_t GetMaxNumElements() const override
Returns the max number of elements.
#define TF_UNUSED(x)
Stops compiler from producing unused argument or variable warnings.
HDST_API _SimpleBufferArray(HdStResourceRegistry *resourceRegistry, TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
Constructor.
size_t GetNumElements() const override
Returns the number of elements allocated.
HDST_API void DebugDump(std::ostream &out) const override
Debug output.
HDST_API size_t GetMaxNumElements() const override
Returns the maximum number of elements capacity.
void IncrementVersion() override
Increment the version of the buffer array.
HDST_API bool IsAssigned() const override
Returns true is the range has been assigned to a buffer.
Token for efficient comparison, assignment, and hashing of known strings.
HDST_API HdStBufferResourceNamedList const & GetResources() const override
Returns the list of all named GPU resources for this bufferArrayRange.
HdStBufferResourceNamedList const & GetResources() const
Returns the list of all named GPU resources for this bufferArray.
virtual HdBufferSpecVector GetBufferSpecs(HdBufferArraySharedPtr const &bufferArray) const
Returns the buffer specs from a given buffer array.
HDST_API void CopyData(HdBufferSourceSharedPtr const &bufferSource) override
Copy source data into buffer.
A central registry of all GPU resources.
size_t GetRangeCount() const
How many ranges are attached to the buffer array.
HDST_API void SetBufferArray(HdBufferArray *bufferArray) override
Sets the buffer array associated with this buffer;.
HDST_API HdBufferSpecVector GetBufferSpecs() const
Reconstructs the bufferspecs and returns it (for buffer splitting)
HDST_API bool GarbageCollect() override
perform compaction if necessary, returns true if it becomes empty.
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 HdAggregationStrategy::AggregationId ComputeAggregationId(HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint) const
Returns id for given bufferSpecs to be used for aggregation.
HDST_API bool Resize(int numElements)
Set to resize buffers. Actual reallocation happens on Reallocate()
HDST_API void DebugDump(std::ostream &out) const override
Debug dump.
int GetCapacity() const
Returns the capacity of allocated area for this range.
HDST_API ~_SimpleBufferArray() override
Destructor. It invalidates _range.
size_t GetVersion() const
Returns the version of this buffer array.
void Invalidate()
Make this range invalid.
HDST_API HdStBufferResourceSharedPtr GetResource() const
TODO: We need to distinguish between the primvar types here, we should tag each HdBufferSource and Hd...
bool Resize(int numElements) override
Resize memory area for this range.
size_t GetVersion() const override
Returns the version of the buffer array.
int GetCapacity() const
Returns current capacity. It could be different from numElements.
int GetElementOffset() const override
Returns the offset at which this range begins in the underlying buffer array in terms of elements...
HDST_API VtValue ReadData(TfToken const &name) const override
Read back the buffer content.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Simple buffer array (non-aggregated).
HDST_API HdBufferArrayUsageHint GetUsageHint() const override
Returns the usage hint from the underlying buffer array.
Specialized buffer array range for SimpleBufferArray.