C++ API Reference
MGPUDeformerBuffer Class Reference

Store GPU Representation of a data buffer. More...

#include <MPxGPUDeformer.h>

Public Member Functions

 MGPUDeformerBuffer (const MPlug &plug, const MUniqueString &name, bool readOnly, unsigned int elementSizeInBytes, unsigned int elementCount, unsigned int capacityInBytes, const MAutoCLMem &buffer, const MAutoCLEvent &event)
 Constructs an MGPUDeformerBuffer for an existing MAutoCLMem. More...
 
 MGPUDeformerBuffer ()
 Constructs an empty MGPUDeformerBuffer which cannot be used.
 
 ~MGPUDeformerBuffer ()
 Destructor.
 
 MGPUDeformerBuffer (const MGPUDeformerBuffer &other)
 Copy constructor. More...
 
 MGPUDeformerBuffer (MGPUDeformerBuffer &&other)
 Move Constructor. More...
 
MGPUDeformerBufferoperator= (const MGPUDeformerBuffer &other)
 Copy Assignment Operator. More...
 
MGPUDeformerBufferoperator= (MGPUDeformerBuffer &&other)
 Move assignment operator. More...
 
MOpenCLBuffer createMOpenCLBuffer ()
 Create and return an MOpenCLBuffer backed by the same GPU buffer that this MGPUDeformerBuffer is backed by. More...
 
bool isValid () const
 
const MUniqueString name () const
 It is only safe to call name() when MGPUDeformerBuffer is valid. More...
 
const MPlug plug () const
 It is only safe to call name() when MGPUDeformerBuffer is valid. More...
 
bool isReadOnly () const
 It is only safe to call isReadOnly() when MGPUDeformerBuffer is valid. More...
 
unsigned int elementSizeInBytes () const
 It is only safe to call elementSizeInBytes() when MGPUDeformerBuffer is valid. More...
 
unsigned int elementCount () const
 It is only safe to call elementCount() when MGPUDeformerBuffer is valid. More...
 
const MAutoCLMem buffer () const
 It is only safe to call buffer() when MGPUDeformerBuffer is valid. More...
 
const MAutoCLEvent bufferReadyEvent () const
 It is only safe to call bufferReadyEvent() when MGPUDeformerBuffer is valid. More...
 
void setBufferReadyEvent (const MAutoCLEvent &)
 It is only safe to call setBufferReadyEvent() when MGPUDeformerBuffer is valid. More...
 
void destroy ()
 Release all resources and references held by this MGPUDeformerBuffer. More...
 

Detailed Description

Store GPU Representation of a data buffer.

MGPUDeformerBuffer is a simple buffer structure to group data related to a single GPU buffer which is associated with a plug in the DG.

Examples:
basicMorphNode/basicMorphNode.cpp, identityNode/identityNode.cpp, and offsetNode/offsetNode.cpp.

Constructor & Destructor Documentation

MGPUDeformerBuffer ( const MPlug plug,
const MUniqueString name,
bool  readOnly,
unsigned int  elementSizeInBytes,
unsigned int  elementCount,
unsigned int  capacityInBytes,
const MAutoCLMem buffer,
const MAutoCLEvent event 
)

Constructs an MGPUDeformerBuffer for an existing MAutoCLMem.

capacityInBytes must be less than or equal to the actual size of the cl_mem held by buffer. elementSizeInBytes() * elementCount must be less than or equal to capacityInBytes.

Parameters
[in]plugThe plug whose data this buffer represents.
[in]nameThe name of the buffer.
[in]readOnlyTrue if the MGPUDeformerBuffer is a read only buffer.
[in]elementSizeInBytesThe size of each element in the buffer in bytes.
[in]elementCountThe number of elements stored in the buffer.
[in]capacityInBytesThe capacity of the cl_mem in bytes.
[in]bufferThe OpenCL memory resource.
[in]eventThe data is buffer is safe to read when event holds a NULL event or event is complete.

Copy constructor.

"This" and "other" will have different MAutoCLMem objects which reference the same underlying cl_mem. "This" and "other will have difference MAutoCLEvent objects which reference the same underlying cl_event.

Parameters
[in]otherMGPUDeformerBuffer to be copied.

Move Constructor.

Parameters
[in]otherrvalue to "steal" resources from.

Member Function Documentation

MGPUDeformerBuffer & operator= ( const MGPUDeformerBuffer other)

Copy Assignment Operator.

"This" and "other" will have different MAutoCLMem objects which reference the same underlying cl_mem. "This" and "other will have difference MAutoCLEvent objects which reference the same underlying cl_event.

Parameters
[in]otherMGPUDeformerBuffer to be copied.
MGPUDeformerBuffer & operator= ( MGPUDeformerBuffer &&  other)

Move assignment operator.

Parameters
[in]otherrvalue to "steal" resources from.
MOpenCLBuffer createMOpenCLBuffer ( )

Create and return an MOpenCLBuffer backed by the same GPU buffer that this MGPUDeformerBuffer is backed by.

If this MGPUDeformerBuffer is read only that property is inherited by the created MOpenCLBuffer.

To create a writable MOpenCLBuffer from a read only MGPUDeformerBuffer you must first call MPxGPUDeformer::createOutputBuffer().

Returns
An MOpenCLBuffer backed by the same GPU buffer that this MGPUDeformerBuffer is backed by.
bool isValid ( ) const
const MUniqueString name ( ) const

It is only safe to call name() when MGPUDeformerBuffer is valid.

Returns
The name of the MGPUDeformerBuffer.
const MPlug plug ( ) const

It is only safe to call name() when MGPUDeformerBuffer is valid.

Returns
The plug the MGPUDeformerBuffer represents.
bool isReadOnly ( ) const

It is only safe to call isReadOnly() when MGPUDeformerBuffer is valid.

Returns
true if the buffer is read only.
unsigned int elementSizeInBytes ( ) const

It is only safe to call elementSizeInBytes() when MGPUDeformerBuffer is valid.

Returns
The size in bytes of each element of the MGPUDeformerBuffer.
unsigned int elementCount ( ) const

It is only safe to call elementCount() when MGPUDeformerBuffer is valid.

Returns
The number of elements in the MGPUDeformerBuffer.
Examples:
basicMorphNode/basicMorphNode.cpp, identityNode/identityNode.cpp, and offsetNode/offsetNode.cpp.
const MAutoCLMem buffer ( ) const

It is only safe to call buffer() when MGPUDeformerBuffer is valid.

Returns
The OpenCL representation of the MGPUDeformerBuffer.
Examples:
basicMorphNode/basicMorphNode.cpp, and offsetNode/offsetNode.cpp.
const MAutoCLEvent bufferReadyEvent ( ) const

It is only safe to call bufferReadyEvent() when MGPUDeformerBuffer is valid.

Returns
The event to wait on before reading the contents of buffer.
Examples:
basicMorphNode/basicMorphNode.cpp, identityNode/identityNode.cpp, and offsetNode/offsetNode.cpp.
void setBufferReadyEvent ( const MAutoCLEvent event)

It is only safe to call setBufferReadyEvent() when MGPUDeformerBuffer is valid.

Returns
A non-constant reference to the event to wait on which can be set after enqueuing work which modifies the buffer.
Examples:
basicMorphNode/basicMorphNode.cpp, identityNode/identityNode.cpp, and offsetNode/offsetNode.cpp.
void destroy ( )

Release all resources and references held by this MGPUDeformerBuffer.

This may or may not release the last reference to a cl_mem or cl_event object.


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