Viskores  1.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
viskores::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...
 
viskores::Int64 GetSize () const
 Get the size of the buffer in bytes. More...
 
void SetSize (viskores::Int64 size)
 
viskores::Int64 GetCapacity () const
 Get the capacity of the buffer in bytes. More...
 
bool ShouldRealloc (viskores::Int64 desiredSize) const
 
void SetCapacity (viskores::Int64 capacity)
 
viskores::interop::internal::TransferResource * GetResource ()
 
void SetResource (viskores::interop::internal::TransferResource *resource)
 

Private Member Functions

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

Private Attributes

GLuint * OpenGLHandle
 
GLenum BufferType
 
viskores::Int64 SizeOfActiveSection
 
viskores::Int64 CapacityOfBuffer
 
GLuint DefaultGLHandle
 
std::unique_ptr< viskores::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 viskores uses a lazy buffer re-allocation.

Constructor & Destructor Documentation

◆ BufferState() [1/4]

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

Construct a BufferState using an existing GLHandle.

◆ BufferState() [2/4]

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

Construct a BufferState using an existing GLHandle and type.

◆ BufferState() [3/4]

viskores::interop::BufferState::BufferState ( )
inline

◆ ~BufferState()

viskores::interop::BufferState::~BufferState ( )
inline

◆ BufferState() [4/4]

viskores::interop::BufferState::BufferState ( const BufferState )
privatedelete

Member Function Documentation

◆ DeduceAndSetType()

template<typename T >
void viskores::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 viskores::Int32, viskores::UInt32, viskores::Int64, viskores::UInt64, viskores::Id, and viskores::IdComponent will be GL_ARRAY_BUFFER for everything else.

◆ GetCapacity()

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

Get the capacity of the buffer in bytes.

The buffers that viskores allocate in OpenGL use lazy resizing. This allows viskores 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* viskores::interop::BufferState::GetHandle ( ) const
inline

get the OpenGL buffer handle

◆ GetResource()

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

◆ GetSize()

viskores::Int64 viskores::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 viskores::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 viskores::interop::BufferState::HasType ( ) const
inline

return if this buffer has a valid OpenGL buffer type

◆ operator=()

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

◆ SetCapacity()

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

◆ SetResource()

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

◆ SetSize()

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

◆ SetType()

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

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

◆ ShouldRealloc()

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

Member Data Documentation

◆ BufferType

GLenum viskores::interop::BufferState::BufferType
private

◆ CapacityOfBuffer

viskores::Int64 viskores::interop::BufferState::CapacityOfBuffer
private

◆ DefaultGLHandle

GLuint viskores::interop::BufferState::DefaultGLHandle
private

◆ OpenGLHandle

GLuint* viskores::interop::BufferState::OpenGLHandle
private

◆ Resource

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

◆ SizeOfActiveSection

viskores::Int64 viskores::interop::BufferState::SizeOfActiveSection
private

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