24 #ifndef PXR_IMAGING_HD_BUFFER_SOURCE_H 25 #define PXR_IMAGING_HD_BUFFER_SOURCE_H 28 #include "pxr/imaging/hd/api.h" 29 #include "pxr/imaging/hd/version.h" 30 #include "pxr/imaging/hd/bufferSpec.h" 39 PXR_NAMESPACE_OPEN_SCOPE
42 using HdBufferSourceSharedPtr = std::shared_ptr<HdBufferSource>;
43 using HdBufferSourceConstSharedPtr = std::shared_ptr<HdBufferSource const>;
44 using HdBufferSourceSharedPtrVector = std::vector<HdBufferSourceSharedPtr>;
45 using HdBufferSourceWeakPtr = std::weak_ptr<HdBufferSource>;
87 virtual void const*
GetData()
const = 0;
98 return _state >= RESOLVED;
103 return _state == RESOLVE_ERROR;
165 _state = RESOLVE_ERROR;
174 State oldState = UNRESOLVED;
175 return _state.compare_exchange_strong(oldState, BEING_RESOLVED);
201 enum State { UNRESOLVED=0, BEING_RESOLVED, RESOLVED, RESOLVE_ERROR};
202 std::atomic<State> _state;
220 virtual void const*
GetData()
const override;
227 void _SetResult(HdBufferSourceSharedPtr
const &result) {
232 HdBufferSourceSharedPtr _result;
243 virtual void const*
GetData()
const override;
251 virtual void GetBufferSpecs(HdBufferSpecVector *specs)
const override;
255 PXR_NAMESPACE_CLOSE_SCOPE
257 #endif //PXR_IMAGING_HD_BUFFER_SOURCE_H virtual HD_API void const * GetData() const override
Following interfaces will be called after Resolve.
void _SetResolveError()
Called during Resolve() to indicate an unrecoverable failure occurred and the results of the computat...
virtual HD_API bool HasChainedBuffer() const
Returns true if this buffer has any chained buffer(s)
virtual HD_API size_t ComputeHash() const override
Computes and returns a hash value for the underlying data.
void _SetResolved()
Marks this buffer source as resolved.
virtual HD_API void GetBufferSpecs(HdBufferSpecVector *specs) const override
Add the buffer spec for this buffer source into given bufferspec vector.
virtual HD_API HdBufferSourceSharedPtrVector GetChainedBuffers() const
Returns the vector of chained buffers.
virtual HD_API bool HasPreChainedBuffer() const
Returns true if this buffer has a pre-chained buffer.
virtual HD_API size_t ComputeHash() const
Computes and returns a hash value for the underlying data.
virtual HD_API TfToken const & GetName() const override
Return the name of this buffer source.
virtual void GetBufferSpecs(HdBufferSpecVector *specs) const =0
Add the buffer spec for this buffer source into given bufferspec vector.
HdTupleType represents zero, one, or more values of the same HdType.
bool IsResolved() const
Returns true it this computation has already been resolved.
Low-level utilities for informing users of various internal and external diagnostic conditions.
virtual void const * GetData() const =0
Following interfaces will be called after Resolve.
virtual HD_API size_t GetNumElements() const override
Returns the number of elements (e.g.
Token for efficient comparison, assignment, and hashing of known strings.
A abstract base class for pure cpu computation.
A transient buffer of data that has not yet been committed.
virtual HdTupleType GetTupleType() const =0
Returns the data type and count (array size) for this buffer source.
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
virtual bool _CheckValid() const =0
Checks the validity of the source buffer.
HD_API bool IsValid() const
Checks the validity of the source buffer.
virtual HD_API TfToken const & GetName() const override
Return the name of this buffer source.
virtual size_t GetNumElements() const =0
Returns the number of elements (e.g.
virtual HD_API HdTupleType GetTupleType() const override
Returns the data type and count (array size) for this buffer source.
bool _TryLock()
Non-blocking lock acquisition.
virtual HD_API HdBufferSourceSharedPtr GetPreChainedBuffer() const
Returns the pre-chained buffer.
virtual HD_API void const * GetData() const override
Following interfaces will be called after Resolve.
bool HasResolveError() const
Returns true if an error occurred during resolve.
virtual TfToken const & GetName() const =0
Return the name of this buffer source.
virtual HD_API size_t ComputeHash() const override
Computes and returns a hash value for the underlying data.
virtual HD_API HdTupleType GetTupleType() const override
Returns the data type and count (array size) for this buffer source.
virtual HD_API size_t GetNumElements() const override
Returns the number of elements (e.g.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
virtual bool Resolve()=0
Prepare the access of GetData().
A abstract base class for cpu computation followed by buffer transfer to the GPU.