This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
HdVtBufferSource Class Referencefinal

An implementation of HdBufferSource where the source data value is a VtValue. More...

#include <vtBufferSource.h>

+ Inheritance diagram for HdVtBufferSource:

Public Member Functions

HD_API HdVtBufferSource (TfToken const &name, VtValue const &value, int arraySize=1, bool allowDoubles=true)
 Constructs a new buffer from a VtValue.
 
HD_API HdVtBufferSource (TfToken const &name, GfMatrix4d const &matrix, bool allowDoubles=true)
 Constructs a new buffer from a matrix.
 
HD_API HdVtBufferSource (TfToken const &name, VtArray< GfMatrix4d > const &matrices, int arraySize=1, bool allowDoubles=true)
 Constructs a new buffer from a matrix.
 
HD_API ~HdVtBufferSource () override
 Destructor deletes the internal storage.
 
HD_API void Truncate (size_t numElements)
 Truncate the buffer to the given number of elements.
 
TfToken const & GetName () const override
 Return the name of this buffer source.
 
void const * GetData () const override
 Returns the raw pointer to the underlying data.
 
HdTupleType GetTupleType () const override
 Returns the data type and count of this buffer source.
 
HD_API size_t GetNumElements () const override
 Returns the number of elements (e.g.
 
void GetBufferSpecs (HdBufferSpecVector *specs) const override
 Add the buffer spec for this buffer source into given bufferspec vector.
 
bool Resolve () override
 Prepare the access of GetData().
 
- Public Member Functions inherited from HdBufferSource
virtual TfToken const & GetName () const =0
 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.
 
virtual HD_API size_t ComputeHash () const
 Computes and returns a hash value for the underlying data.
 
virtual bool Resolve ()=0
 Prepare the access of GetData().
 
virtual void const * GetData () const =0
 Following interfaces will be called after Resolve.
 
virtual HdTupleType GetTupleType () const =0
 Returns the data type and count (array size) for this buffer source.
 
virtual size_t GetNumElements () const =0
 Returns the number of elements (e.g.
 
bool IsResolved () const
 Returns true it this computation has already been resolved.
 
bool HasResolveError () const
 Returns true if an error occurred during resolve.
 
HD_API bool IsValid () const
 Checks the validity of the source buffer.
 
virtual HD_API bool HasPreChainedBuffer () const
 Returns true if this buffer has a pre-chained buffer.
 
virtual HD_API HdBufferSourceSharedPtr GetPreChainedBuffer () const
 Returns the pre-chained buffer.
 
virtual HD_API bool HasChainedBuffer () const
 Returns true if this buffer has any chained buffer(s)
 
virtual HD_API HdBufferSourceSharedPtrVector GetChainedBuffers () const
 Returns the vector of chained buffers.
 

Static Public Member Functions

static HD_API HdType GetDefaultMatrixType ()
 Returns the default matrix type.
 

Protected Member Functions

HD_API bool _CheckValid () const override
 Checks the validity of the source buffer.
 
- Protected Member Functions inherited from HdBufferSource
void _SetResolved ()
 Marks this buffer source as resolved.
 
void _SetResolveError ()
 Called during Resolve() to indicate an unrecoverable failure occurred and the results of the computation can not be used.
 
bool _TryLock ()
 Non-blocking lock acquisition.
 
virtual bool _CheckValid () const =0
 Checks the validity of the source buffer.
 

Detailed Description

An implementation of HdBufferSource where the source data value is a VtValue.

Definition at line 32 of file vtBufferSource.h.

Constructor & Destructor Documentation

◆ HdVtBufferSource() [1/3]

HD_API HdVtBufferSource ( TfToken const &  name,
VtValue const &  value,
int  arraySize = 1,
bool  allowDoubles = true 
)

Constructs a new buffer from a VtValue.

Parameters
arraySizeindicates how many values are provided per element.
allowDoublesindicates if double types can be used, or if they must be converted to floats.

◆ HdVtBufferSource() [2/3]

HD_API HdVtBufferSource ( TfToken const &  name,
GfMatrix4d const &  matrix,
bool  allowDoubles = true 
)

Constructs a new buffer from a matrix.

The data is convert to the default type (see GetDefaultMatrixType()).

Note that if we use above VtValue taking constructor, we can use either float or double matrix regardless the default type.

Parameters
allowDoublesindicates if double types can be used, or if they must be converted to floats regardless of the default type.

◆ HdVtBufferSource() [3/3]

HD_API HdVtBufferSource ( TfToken const &  name,
VtArray< GfMatrix4d > const &  matrices,
int  arraySize = 1,
bool  allowDoubles = true 
)

Constructs a new buffer from a matrix.

The data is convert to the default type (see GetDefaultMatrixType()).

Note that if we use above VtValue taking constructor, we can use either float or double matrix regardless the default type.

Parameters
arraySizeindicates how many values are provided per element.
allowDoublesindicates if double types can be used, or if they must be converted to floats regardless of the default type.

◆ ~HdVtBufferSource()

HD_API ~HdVtBufferSource ( )
override

Destructor deletes the internal storage.

Member Function Documentation

◆ _CheckValid()

HD_API bool _CheckValid ( ) const
overrideprotectedvirtual

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

Implements HdBufferSource.

◆ GetBufferSpecs()

void GetBufferSpecs ( HdBufferSpecVector *  specs) const
inlineoverridevirtual

Add the buffer spec for this buffer source into given bufferspec vector.

Implements HdBufferSource.

Definition at line 107 of file vtBufferSource.h.

◆ GetData()

void const * GetData ( ) const
inlineoverridevirtual

Returns the raw pointer to the underlying data.

Implements HdBufferSource.

Definition at line 92 of file vtBufferSource.h.

◆ GetDefaultMatrixType()

static HD_API HdType GetDefaultMatrixType ( )
static

Returns the default matrix type.

The default is HdTypeFloatMat4, but if HD_ENABLE_DOUBLEMATRIX is true, then HdTypeDoubleMat4 is used instead.

◆ GetName()

TfToken const & GetName ( ) const
inlineoverridevirtual

Return the name of this buffer source.

Implements HdBufferSource.

Definition at line 87 of file vtBufferSource.h.

◆ GetNumElements()

HD_API size_t GetNumElements ( ) const
overridevirtual

Returns the number of elements (e.g.

VtVec3dArray().GetLength()) from the source array.

Implements HdBufferSource.

◆ GetTupleType()

HdTupleType GetTupleType ( ) const
inlineoverridevirtual

Returns the data type and count of this buffer source.

Implements HdBufferSource.

Definition at line 97 of file vtBufferSource.h.

◆ Resolve()

bool Resolve ( )
inlineoverridevirtual

Prepare the access of GetData().

Implements HdBufferSource.

Definition at line 112 of file vtBufferSource.h.

◆ Truncate()

HD_API void Truncate ( size_t  numElements)

Truncate the buffer to the given number of elements.

If the VtValue contains too much data, this is a way to only forward part of the data to the hydra buffer system. numElements must be less than or equal to the current result of GetNumElements().


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