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