MetalCompute 1.0
An API to make GPU compute calls easier
Loading...
Searching...
No Matches
MTLCompute::CommandManager< T > Class Template Reference

#include <MTLComputeCommandManager.hpp>

Public Member Functions

 CommandManager (MTL::Device *gpu, MTLCompute::Kernel *kernel)
 Constructor for the CommandManager class.
 
 CommandManager ()=default
 Default constructor for the CommandManager class.
 
 ~CommandManager ()
 Destructor for the CommandManager class.
 
void loadBuffer (Buffer< T > buffer, int index)
 Load a buffer into the CommandManager.
 
void loadTexture (Texture< T > texture, int index)
 Load a texture into the CommandManager.
 
void dispatch ()
 Dispatch the kernel.
 
void resetBuffers ()
 reset the buffers and cached length
 
void resetTextures ()
 reset the textures and cached width and height
 
void reset ()
 reset the buffers and textures
 
MTL::Device * getGPU ()
 Get the GPU device.
 
KernelgetKernel ()
 Get the kernel object.
 
std::vector< Buffer< T > > & getBuffers ()
 Get the loaded buffers.
 
std::vector< Texture< T > > & getTextures ()
 Get the loaded textures.
 

Private Attributes

MTL::Device * gpu
 The Metal device object.
 
Kernelkernel
 The kernel object.
 
MTL::ComputePipelineState * pipeline
 The Metal compute pipeline state object.
 
MTL::CommandQueue * commandQueue
 The Metal command queue object.
 
MTL::CommandBuffer * commandBuffer
 The Metal command buffer object.
 
MTL::ComputeCommandEncoder * commandEncoder
 The Metal compute command encoder object.
 
std::vector< Buffer< T > > buffers = std::vector<Buffer<T>>(MAX_BUFFERS)
 The buffers.
 
std::vector< Texture< T > > textures = std::vector<Texture<T>>(MAX_TEXTURES)
 The textures.
 
int bufferlength = -1
 The length of the buffers.
 
int texwidth = -1
 The width of the textures.
 
int texheight = -1
 The height of the textures.
 

Constructor & Destructor Documentation

◆ CommandManager() [1/2]

template<typename T >
MTLCompute::CommandManager< T >::CommandManager ( MTL::Device * gpu,
MTLCompute::Kernel * kernel )
inline

Constructor for the CommandManager class.

Takes in the GPU device and the kernel object and creates a new CommandManager. Also takes in the target buffer type with a template parameter.

Parameters
gpuThe GPU device
kernelThe kernel object

◆ CommandManager() [2/2]

template<typename T >
MTLCompute::CommandManager< T >::CommandManager ( )
default

Default constructor for the CommandManager class.

◆ ~CommandManager()

template<typename T >
MTLCompute::CommandManager< T >::~CommandManager ( )
inline

Destructor for the CommandManager class.

Releases the command queue

Member Function Documentation

◆ dispatch()

template<typename T >
void MTLCompute::CommandManager< T >::dispatch ( )
inline

Dispatch the kernel.

Creates new command buffer and command encoder objects, adds the specified buffers at the correct positons, and dispatches the kernel

◆ getBuffers()

template<typename T >
std::vector< Buffer< T > > & MTLCompute::CommandManager< T >::getBuffers ( )
inline

Get the loaded buffers.

Returns
std::vector<Buffer<T>> The buffers

◆ getGPU()

template<typename T >
MTL::Device * MTLCompute::CommandManager< T >::getGPU ( )
inline

Get the GPU device.

Returns
MTL::Device* The GPU device

◆ getKernel()

template<typename T >
Kernel * MTLCompute::CommandManager< T >::getKernel ( )
inline

Get the kernel object.

Returns
Kernel* The kernel object

◆ getTextures()

template<typename T >
std::vector< Texture< T > > & MTLCompute::CommandManager< T >::getTextures ( )
inline

Get the loaded textures.

Returns
std::vector<Texture<T>> The textures

◆ loadBuffer()

template<typename T >
void MTLCompute::CommandManager< T >::loadBuffer ( Buffer< T > buffer,
int index )
inline

Load a buffer into the CommandManager.

Takes in a buffer and an index and adds the buffer to an internal array

Parameters
bufferThe buffer to load
indexThe index to load the buffer into

◆ loadTexture()

template<typename T >
void MTLCompute::CommandManager< T >::loadTexture ( Texture< T > texture,
int index )
inline

Load a texture into the CommandManager.

Takes in a texture and an index and adds the texture to an internal array

Parameters
textureThe texture to load
indexThe index to load the texture into

◆ reset()

template<typename T >
void MTLCompute::CommandManager< T >::reset ( )
inline

reset the buffers and textures

Calls CommandManager::resetBuffers and CommandManager::resetTextures

◆ resetBuffers()

template<typename T >
void MTLCompute::CommandManager< T >::resetBuffers ( )
inline

reset the buffers and cached length

◆ resetTextures()

template<typename T >
void MTLCompute::CommandManager< T >::resetTextures ( )
inline

reset the textures and cached width and height

Member Data Documentation

◆ bufferlength

template<typename T >
int MTLCompute::CommandManager< T >::bufferlength = -1
private

The length of the buffers.

◆ buffers

template<typename T >
std::vector<Buffer<T> > MTLCompute::CommandManager< T >::buffers = std::vector<Buffer<T>>(MAX_BUFFERS)
private

The buffers.

◆ commandBuffer

template<typename T >
MTL::CommandBuffer* MTLCompute::CommandManager< T >::commandBuffer
private

The Metal command buffer object.

◆ commandEncoder

template<typename T >
MTL::ComputeCommandEncoder* MTLCompute::CommandManager< T >::commandEncoder
private

The Metal compute command encoder object.

◆ commandQueue

template<typename T >
MTL::CommandQueue* MTLCompute::CommandManager< T >::commandQueue
private

The Metal command queue object.

◆ gpu

template<typename T >
MTL::Device* MTLCompute::CommandManager< T >::gpu
private

The Metal device object.

◆ kernel

template<typename T >
Kernel* MTLCompute::CommandManager< T >::kernel
private

The kernel object.

◆ pipeline

template<typename T >
MTL::ComputePipelineState* MTLCompute::CommandManager< T >::pipeline
private

The Metal compute pipeline state object.

◆ texheight

template<typename T >
int MTLCompute::CommandManager< T >::texheight = -1
private

The height of the textures.

◆ textures

template<typename T >
std::vector<Texture<T> > MTLCompute::CommandManager< T >::textures = std::vector<Texture<T>>(MAX_TEXTURES)
private

The textures.

◆ texwidth

template<typename T >
int MTLCompute::CommandManager< T >::texwidth = -1
private

The width of the textures.


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