VTK-m  2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
vtkm::interop::BufferState Class Reference

Manages the state for transferring an ArrayHandle to opengl. More...

#include <BufferState.h>

Public Member Functions

 BufferState (GLuint &gLHandle)
 Construct a BufferState using an existing GLHandle. More...
 
 BufferState (GLuint &gLHandle, GLenum type)
 Construct a BufferState using an existing GLHandle and type. More...
 
 BufferState ()
 
 ~BufferState ()
 
GLuint * GetHandle () const
 get the OpenGL buffer handle More...
 
bool HasType () const
 return if this buffer has a valid OpenGL buffer type More...
 
GLenum GetType () const
 return what OpenGL buffer type we are bound to More...
 
void SetType (GLenum type)
 Set what type of OpenGL buffer type we should bind as. More...
 
template<typename T >
void DeduceAndSetType (T t)
 deduce the buffer type from the template value type that was passed in, and set that as our type More...
 
vtkm::Int64 GetSize () const
 Get the size of the buffer in bytes. More...
 
void SetSize (vtkm::Int64 size)
 
vtkm::Int64 GetCapacity () const
 Get the capacity of the buffer in bytes. More...
 
bool ShouldRealloc (vtkm::Int64 desiredSize) const
 
void SetCapacity (vtkm::Int64 capacity)
 
vtkm::interop::internal::TransferResource * GetResource ()
 
void SetResource (vtkm::interop::internal::TransferResource *resource)
 

Private Member Functions

 BufferState (const BufferState &)=delete
 
void operator= (const BufferState &)=delete
 

Private Attributes

GLuint * OpenGLHandle
 
GLenum BufferType
 
vtkm::Int64 SizeOfActiveSection
 
vtkm::Int64 CapacityOfBuffer
 
GLuint DefaultGLHandle
 
std::unique_ptr< vtkm::interop::internal::TransferResource > Resource
 

Detailed Description

Manages the state for transferring an ArrayHandle to opengl.

BufferState holds all the relevant data information for a given ArrayHandle mapping into OpenGL. Reusing the state information for all renders of an ArrayHandle will allow for the most efficient interop between backends and OpenGL ( especially for CUDA ).

The interop code in vtk-m uses a lazy buffer re-allocation.

Constructor & Destructor Documentation

◆ BufferState() [1/4]

vtkm::interop::BufferState::BufferState ( GLuint &  gLHandle)
inline

Construct a BufferState using an existing GLHandle.

◆ BufferState() [2/4]

vtkm::interop::BufferState::BufferState ( GLuint &  gLHandle,
GLenum  type 
)
inline

Construct a BufferState using an existing GLHandle and type.

◆ BufferState() [3/4]

vtkm::interop::BufferState::BufferState ( )
inline

◆ ~BufferState()

vtkm::interop::BufferState::~BufferState ( )
inline

◆ BufferState() [4/4]

vtkm::interop::BufferState::BufferState ( const BufferState )
privatedelete

Member Function Documentation

◆ DeduceAndSetType()

template<typename T >
void vtkm::interop::BufferState::DeduceAndSetType ( t)
inline

deduce the buffer type from the template value type that was passed in, and set that as our type

Will be GL_ELEMENT_ARRAY_BUFFER for vtkm::Int32, vtkm::UInt32, vtkm::Int64, vtkm::UInt64, vtkm::Id, and vtkm::IdComponent will be GL_ARRAY_BUFFER for everything else.

◆ GetCapacity()

vtkm::Int64 vtkm::interop::BufferState::GetCapacity ( ) const
inline

Get the capacity of the buffer in bytes.

The buffers that vtk-m allocate in OpenGL use lazy resizing. This allows vtk-m to not have to reallocate a buffer while the size stays the same or shrinks. This allows allows the cuda to OpenGL to perform significantly better as we than don't need to call cudaGraphicsGLRegisterBuffer as often

◆ GetHandle()

GLuint* vtkm::interop::BufferState::GetHandle ( ) const
inline

get the OpenGL buffer handle

◆ GetResource()

vtkm::interop::internal::TransferResource* vtkm::interop::BufferState::GetResource ( )
inline

◆ GetSize()

vtkm::Int64 vtkm::interop::BufferState::GetSize ( ) const
inline

Get the size of the buffer in bytes.

Get the size of the active section of the buffer This will always be <= the capacity of the buffer

◆ GetType()

GLenum vtkm::interop::BufferState::GetType ( ) const
inline

return what OpenGL buffer type we are bound to

will return GL_INVALID_VALUE if we don't have a valid type set

◆ HasType()

bool vtkm::interop::BufferState::HasType ( ) const
inline

return if this buffer has a valid OpenGL buffer type

◆ operator=()

void vtkm::interop::BufferState::operator= ( const BufferState )
privatedelete

◆ SetCapacity()

void vtkm::interop::BufferState::SetCapacity ( vtkm::Int64  capacity)
inline

◆ SetResource()

void vtkm::interop::BufferState::SetResource ( vtkm::interop::internal::TransferResource *  resource)
inline

◆ SetSize()

void vtkm::interop::BufferState::SetSize ( vtkm::Int64  size)
inline

◆ SetType()

void vtkm::interop::BufferState::SetType ( GLenum  type)
inline

Set what type of OpenGL buffer type we should bind as.

◆ ShouldRealloc()

bool vtkm::interop::BufferState::ShouldRealloc ( vtkm::Int64  desiredSize) const
inline

Member Data Documentation

◆ BufferType

GLenum vtkm::interop::BufferState::BufferType
private

◆ CapacityOfBuffer

vtkm::Int64 vtkm::interop::BufferState::CapacityOfBuffer
private

◆ DefaultGLHandle

GLuint vtkm::interop::BufferState::DefaultGLHandle
private

◆ OpenGLHandle

GLuint* vtkm::interop::BufferState::OpenGLHandle
private

◆ Resource

std::unique_ptr<vtkm::interop::internal::TransferResource> vtkm::interop::BufferState::Resource
private

◆ SizeOfActiveSection

vtkm::Int64 vtkm::interop::BufferState::SizeOfActiveSection
private

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