HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HdBufferSource Class Referenceabstract

#include <bufferSource.h>

+ Inheritance diagram for HdBufferSource:

Public Member Functions

 HdBufferSource ()
 
virtual HD_API ~HdBufferSource ()
 
virtual TfToken constGetName () const =0
 Return the name of this buffer source. More...
 
virtual void GetBufferSpecs (HdBufferSpecVector *specs) const =0
 
virtual HD_API size_t ComputeHash () const
 Computes and returns a hash value for the underlying data. More...
 
virtual bool Resolve ()=0
 
virtual void constGetData () const =0
 Following interfaces will be called after Resolve. More...
 
virtual HdTupleType GetTupleType () const =0
 Returns the data type and count (array size) for this buffer source. More...
 
virtual size_t GetNumElements () const =0
 
bool IsResolved () const
 Returns true it this computation has already been resolved. More...
 
bool HasResolveError () const
 Returns true if an error occurred during resolve. More...
 
HD_API bool IsValid () const
 
Chained Buffers

Buffer sources may be daisy-chained together.

Pre-chained buffer sources typically represent sources that are inputs to computed buffer sources (e.g. coarse vertex privmar data needing to be quadrangulated or refined) and will be scheduled to be resolved along with their owning buffer sources.

Post-chained buffer sources typically represent additional results produced by a computation (e.g. primitive param data computed along with index buffer data) and will be scheduled to be committed along with their owning buffer sources.

virtual HD_API bool HasPreChainedBuffer () const
 Returns true if this buffer has a pre-chained buffer. More...
 
virtual HD_API
HdBufferSourceSharedPtr 
GetPreChainedBuffer () const
 Returns the pre-chained buffer. More...
 
virtual HD_API bool HasChainedBuffer () const
 Returns true if this buffer has any chained buffer(s) More...
 
virtual HD_API
HdBufferSourceSharedPtrVector 
GetChainedBuffers () const
 Returns the vector of chained buffers. More...
 

Protected Member Functions

void _SetResolved ()
 
void _SetResolveError ()
 
bool _TryLock ()
 
virtual bool _CheckValid () const =0
 

Detailed Description

A transient buffer of data that has not yet been committed.

HdBufferSource is an abstract interface class, to be registered to the resource registry with the buffer array range that specifies the destination resource.

Definition at line 55 of file bufferSource.h.

Constructor & Destructor Documentation

HdBufferSource::HdBufferSource ( )
inline

Definition at line 58 of file bufferSource.h.

virtual HD_API HdBufferSource::~HdBufferSource ( )
virtual

Member Function Documentation

virtual bool HdBufferSource::_CheckValid ( ) const
protectedpure virtual

Checks the validity of the source buffer. This function is called by IsValid() to do the real checking.

Should only be implemented in classes at leafs of the class hierarchy (Please place common validation code in a new non-virtual method)

This code should return false:

  • If the buffer would produce an invalid BufferSpec
  • If a required dependent buffer is invalid For example, return false when: The data type is invalid, causing an invalid BufferSpec.

The resolve step requires a 'source' buffer and that buffer is invalid.

If returning false, the buffer will not be registered with the resource registry. AddBufferSpec and Resolve will not be called

Implemented in Hd_AdjacencyBufferSource, Hd_AdjacencyBuilderComputation, HdVtBufferSource, HdExtCompCpuComputation, Hd_SmoothNormalsComputation, Hd_FlatNormalsComputation, HdExtCompPrimvarBufferSource, HdStExtCompGpuPrimvarBufferSource, Hd_CompExtCompInputSource, and Hd_SceneExtCompInputSource.

void HdBufferSource::_SetResolved ( )
inlineprotected

Marks this buffer source as resolved. It has to be called at the end of Resolve on concrete implementations.

Definition at line 149 of file bufferSource.h.

void HdBufferSource::_SetResolveError ( )
inlineprotected

Called during Resolve() to indicate an unrecoverable failure occurred and the results of the computation can not be used. Further calls to Resolve() will not lead to success.

This is different from Resolve() returning false, which indicates that additional calls to Resolve() will eventually lead to success.

This is also later in the pipeline than IsValid, which checks that the buffer is setup such that Resolve() can be successful.

Definition at line 163 of file bufferSource.h.

bool HdBufferSource::_TryLock ( )
inlineprotected

Non-blocking lock acquisition. If no one else is resolving this buffer source, returns true. In that case the caller needs to call _SetResolved at the end of computation. It returns false if anyone else has already acquired lock.

Definition at line 173 of file bufferSource.h.

virtual HD_API size_t HdBufferSource::ComputeHash ( ) const
virtual

Computes and returns a hash value for the underlying data.

Reimplemented in HdNullBufferSource, HdComputedBufferSource, HdExtCompPrimvarBufferSource, and HdStExtCompGpuPrimvarBufferSource.

virtual void HdBufferSource::GetBufferSpecs ( HdBufferSpecVector specs) const
pure virtual

Add the buffer spec for this buffer source into given bufferspec vector. note: buffer specs has to be determined before the source resolution.

Implemented in HdNullBufferSource, Hd_AdjacencyBufferSource, HdVtBufferSource, Hd_SmoothNormalsComputation, Hd_FlatNormalsComputation, HdExtCompPrimvarBufferSource, and HdStExtCompGpuPrimvarBufferSource.

virtual HD_API HdBufferSourceSharedPtrVector HdBufferSource::GetChainedBuffers ( ) const
virtual

Returns the vector of chained buffers.

virtual void const* HdBufferSource::GetData ( ) const
pure virtual

Following interfaces will be called after Resolve.

Returns the raw pointer to the underlying data.

Implemented in HdNullBufferSource, HdComputedBufferSource, HdVtBufferSource, and HdExtCompPrimvarBufferSource.

virtual size_t HdBufferSource::GetNumElements ( ) const
pure virtual

Returns the number of elements (e.g. VtVec3dArray().GetLength()) from the source array.

Implemented in HdNullBufferSource, HdComputedBufferSource, HdVtBufferSource, HdExtCompCpuComputation, HdExtCompPrimvarBufferSource, and HdStExtCompGpuPrimvarBufferSource.

virtual HD_API HdBufferSourceSharedPtr HdBufferSource::GetPreChainedBuffer ( ) const
virtual

Returns the pre-chained buffer.

virtual HdTupleType HdBufferSource::GetTupleType ( ) const
pure virtual

Returns the data type and count (array size) for this buffer source.

Implemented in HdNullBufferSource, HdComputedBufferSource, HdVtBufferSource, HdExtCompPrimvarBufferSource, and HdStExtCompGpuPrimvarBufferSource.

virtual HD_API bool HdBufferSource::HasChainedBuffer ( ) const
virtual

Returns true if this buffer has any chained buffer(s)

virtual HD_API bool HdBufferSource::HasPreChainedBuffer ( ) const
virtual

Returns true if this buffer has a pre-chained buffer.

bool HdBufferSource::HasResolveError ( ) const
inline

Returns true if an error occurred during resolve.

Definition at line 102 of file bufferSource.h.

bool HdBufferSource::IsResolved ( ) const
inline

Returns true it this computation has already been resolved.

Definition at line 97 of file bufferSource.h.

HD_API bool HdBufferSource::IsValid ( ) const

Checks the validity of the source buffer. The function should be called to determine if AddBufferSpec() and Resolve() would return valid results.

virtual bool HdBufferSource::Resolve ( )
pure virtual

Prepare the access of GetData(). This process may include some computations (e.g. cpu smooth normals). Note: Resolve may be called in parallel from multiple threads across buffer sources, so be careful if it uses static/shared states among objects. Returns true if it resolved. If the buffer source has to wait some results of other buffer sources, or the buffer source is being resolved by other threads, it returns false.

Implemented in Hd_AdjacencyBufferSource, Hd_AdjacencyBuilderComputation, HdVtBufferSource, HdExtCompCpuComputation, Hd_SmoothNormalsComputation, Hd_FlatNormalsComputation, HdExtCompPrimvarBufferSource, Hd_CompExtCompInputSource, HdStExtCompGpuPrimvarBufferSource, and Hd_SceneExtCompInputSource.


The documentation for this class was generated from the following file: