HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
types.h File Reference
#include "pxr/pxr.h"
#include "pxr/imaging/hd/api.h"
#include "pxr/imaging/hd/version.h"
#include "pxr/base/vt/value.h"
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstdint>
+ Include dependency graph for types.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  HdVec4f_2_10_10_10_REV
 
struct  HdTupleType
 

Enumerations

enum  HdType {
  HdTypeInvalid =-1, HdTypeBool =0, HdTypeUInt8, HdTypeUInt16,
  HdTypeInt8, HdTypeInt16, HdTypeInt32, HdTypeInt32Vec2,
  HdTypeInt32Vec3, HdTypeInt32Vec4, HdTypeUInt32, HdTypeUInt32Vec2,
  HdTypeUInt32Vec3, HdTypeUInt32Vec4, HdTypeFloat, HdTypeFloatVec2,
  HdTypeFloatVec3, HdTypeFloatVec4, HdTypeFloatMat3, HdTypeFloatMat4,
  HdTypeDouble, HdTypeDoubleVec2, HdTypeDoubleVec3, HdTypeDoubleVec4,
  HdTypeDoubleMat3, HdTypeDoubleMat4, HdTypeHalfFloat, HdTypeHalfFloatVec2,
  HdTypeHalfFloatVec3, HdTypeHalfFloatVec4, HdTypeInt32_2_10_10_10_REV
}
 
enum  HdFormat {
  HdFormatInvalid =-1, HdFormatUNorm8 =0, HdFormatUNorm8Vec2, HdFormatUNorm8Vec3,
  HdFormatUNorm8Vec4, HdFormatSNorm8, HdFormatSNorm8Vec2, HdFormatSNorm8Vec3,
  HdFormatSNorm8Vec4, HdFormatFloat16, HdFormatFloat16Vec2, HdFormatFloat16Vec3,
  HdFormatFloat16Vec4, HdFormatFloat32, HdFormatFloat32Vec2, HdFormatFloat32Vec3,
  HdFormatFloat32Vec4, HdFormatInt32, HdFormatInt32Vec2, HdFormatInt32Vec3,
  HdFormatInt32Vec4, HdFormatCount
}
 

Functions

int HdConvertFloatToFixed (float v, int b)
 
float HdConvertFixedToFloat (int v, int b)
 
HD_API const voidHdGetValueData (const VtValue &)
 
HD_API HdTupleType HdGetValueTupleType (const VtValue &)
 
HD_API HdType HdGetComponentType (HdType)
 
HD_API size_t HdGetComponentCount (HdType t)
 
HD_API size_t HdDataSizeOfType (HdType)
 Return the size, in bytes, of a single value of the given type. More...
 
HD_API size_t HdDataSizeOfTupleType (HdTupleType)
 Return the size, in bytes, of a value with HdTupleType. More...
 
HD_API HdFormat HdGetComponentFormat (HdFormat f)
 Return the single-channel version of a given format. More...
 
HD_API size_t HdGetComponentCount (HdFormat f)
 Return the count of components in the given format. More...
 
HD_API size_t HdDataSizeOfFormat (HdFormat f)
 

Variables

PXR_NAMESPACE_OPEN_SCOPE
typedef uint32_t 
HdDirtyBits
 

Enumeration Type Documentation

enum HdFormat

HdFormat describes the memory format of image buffers used in Hd. It's similar to HdType but with more specific associated semantics.

The list of supported formats is modelled after Vulkan and DXGI, though Hydra only supports a subset. Endian-ness is explicitly not captured; color data is assumed to always be RGBA.

For reference, see: https://www.khronos.org/registry/vulkan/specs/1.1/html/vkspec.html#VkFormat

Enumerator
HdFormatInvalid 
HdFormatUNorm8 
HdFormatUNorm8Vec2 
HdFormatUNorm8Vec3 
HdFormatUNorm8Vec4 
HdFormatSNorm8 
HdFormatSNorm8Vec2 
HdFormatSNorm8Vec3 
HdFormatSNorm8Vec4 
HdFormatFloat16 
HdFormatFloat16Vec2 
HdFormatFloat16Vec3 
HdFormatFloat16Vec4 
HdFormatFloat32 
HdFormatFloat32Vec2 
HdFormatFloat32Vec3 
HdFormatFloat32Vec4 
HdFormatInt32 
HdFormatInt32Vec2 
HdFormatInt32Vec3 
HdFormatInt32Vec4 
HdFormatCount 

Definition at line 296 of file types.h.

enum HdType

HdType describes the type of an attribute value used in Hd.

HdType values have a specific machine representation and size. See HdDataSizeOfType().

HdType specifies a scalar, vector, or matrix type. Vector and matrix types can be unpacked into the underlying "component" type; see HdGetComponentType().

HdType is intended to span the common set of attribute types used in shading languages such as GLSL. However, it currently does not include non-4x4 matrix types, nor struct types.

Fixed-size array types are represented by the related class HdTupleType. HdTupleType is used anywhere there is a possibility of an array of values.

Value arrays and attribute buffers

Attribute data is often stored in linear buffers. These buffers have multiple dimensions and it is important to distinguish them:

  • "Components" refer to the scalar components that comprise a vector or matrix. For example, a vec3 has 3 components, a mat4 has 16 components, and a float has a single component.
  • "Elements" refer to external concepts that entries in a buffer associate with. Typically these are pieces of geometry, such as faces or vertices.
  • "Arrays" refer to the idea that each element may associate with a fixed-size array of values. For example, one approach to motion blur might store a size-2 array of HdFloatMat4 values for each element of geometry, holding the transforms at the beginning and ending of the camera shutter interval.

Combining these concepts in an example, a primvar buffer might hold data for 10 vertices (the elements) with each vertex having a 2 entries (an array) of 4x4 matrices (with 16 components each). As a packed linear buffer, this would occupy 10*2*16==320 floats.

It is important to distinguish components from array entries, and arrays from elements. HdType and HdTupleType only addresses components and arrays; elements are tracked by buffers. See for example HdBufferSource::GetNumElements().

In other words, HdType and HdTupleType describe values. Buffers describe elements and all other details regarding buffer layout, such as offset/stride used to interleave attribute data.

For more background, see the OpenGL discussion on data types:

Enumerator
HdTypeInvalid 
HdTypeBool 

Corresponds to GL_BOOL.

HdTypeUInt8 
HdTypeUInt16 
HdTypeInt8 
HdTypeInt16 
HdTypeInt32 

Corresponds to GL_INT.

HdTypeInt32Vec2 

A 2-component vector with Int32-valued components.

HdTypeInt32Vec3 

A 3-component vector with Int32-valued components.

HdTypeInt32Vec4 

A 4-component vector with Int32-valued components.

HdTypeUInt32 

An unsigned 32-bit integer. Corresponds to GL_UNSIGNED_INT.

HdTypeUInt32Vec2 

A 2-component vector with UInt32-valued components.

HdTypeUInt32Vec3 

A 3-component vector with UInt32-valued components.

HdTypeUInt32Vec4 

A 4-component vector with UInt32-valued components.

HdTypeFloat 

Corresponds to GL_FLOAT.

HdTypeFloatVec2 

Corresponds to GL_FLOAT_VEC2.

HdTypeFloatVec3 

Corresponds to GL_FLOAT_VEC3.

HdTypeFloatVec4 

Corresponds to GL_FLOAT_VEC4.

HdTypeFloatMat3 

Corresponds to GL_FLOAT_MAT3.

HdTypeFloatMat4 

Corresponds to GL_FLOAT_MAT4.

HdTypeDouble 

Corresponds to GL_DOUBLE.

HdTypeDoubleVec2 

Corresponds to GL_DOUBLE_VEC2.

HdTypeDoubleVec3 

Corresponds to GL_DOUBLE_VEC3.

HdTypeDoubleVec4 

Corresponds to GL_DOUBLE_VEC4.

HdTypeDoubleMat3 

Corresponds to GL_DOUBLE_MAT3.

HdTypeDoubleMat4 

Corresponds to GL_DOUBLE_MAT4.

HdTypeHalfFloat 
HdTypeHalfFloatVec2 
HdTypeHalfFloatVec3 
HdTypeHalfFloatVec4 
HdTypeInt32_2_10_10_10_REV 

Packed, reverse-order encoding of a 4-component vector into Int32. Corresponds to GL_INT_2_10_10_10_REV.

See Also
HdVec4f_2_10_10_10_REV

Definition at line 170 of file types.h.

Function Documentation

float HdConvertFixedToFloat ( int  v,
int  b 
)
inline

Definition at line 52 of file types.h.

int HdConvertFloatToFixed ( float  v,
int  b 
)
inline

Definition at line 44 of file types.h.

HD_API size_t HdDataSizeOfFormat ( HdFormat  f)

Return the size of a single element of the given format. For block formats, this will return 0.

HD_API size_t HdDataSizeOfTupleType ( HdTupleType  )

Return the size, in bytes, of a value with HdTupleType.

HD_API size_t HdDataSizeOfType ( HdType  )

Return the size, in bytes, of a single value of the given type.

HD_API size_t HdGetComponentCount ( HdType  t)

Return the count of components in the given value type. For example, HdTypeFloatVec3 has 3 components.

HD_API size_t HdGetComponentCount ( HdFormat  f)

Return the count of components in the given format.

HD_API HdFormat HdGetComponentFormat ( HdFormat  f)

Return the single-channel version of a given format.

HD_API HdType HdGetComponentType ( HdType  )

Return the component type for the given value type. For vectors and matrices, this is the scalar type of their components. For scalars, this is the type itself. As an example, the component type of HdTypeFloatMat4 is HdTypeFloat.

HD_API const void* HdGetValueData ( const VtValue )

Returns a direct pointer to the data held by a VtValue. Returns nullptr if the VtValue is empty or holds a type unknown to Hd.

HD_API HdTupleType HdGetValueTupleType ( const VtValue )

Returns the HdTupleType that describes the given VtValue. For scalar, vector, and matrix types, the count is 1. For any VtArray type, the count is the number of array members.

Variable Documentation

PXR_NAMESPACE_OPEN_SCOPE typedef uint32_t HdDirtyBits

Type representing a set of dirty bits.

Definition at line 41 of file types.h.