The Joe Engine
Joe's engine programming playground
JoeEngine::JEShaderManager Class Reference

The JEShaderManger class. More...

#include <ShaderManager.h>

Public Member Functions

 JEShaderManager ()
 Default constructor. More...
 
 JEShaderManager (VkDevice device)
 Primary constructor. More...
 
 ~JEShaderManager ()=default
 Destructor (default). More...
 
uint32_t CreateShader (VkDevice device, VkPhysicalDevice physicalDevice, const JEVulkanSwapChain &swapChain, const MaterialComponent &materialComponent, uint32_t numSourceTextures, VkRenderPass renderPass, const std::string &vertPath, const std::string &fragPath, PipelineType type)
 Create new shader. More...
 
uint32_t CreateDescriptor (VkDevice device, VkPhysicalDevice physicalDevice, const JEVulkanSwapChain &swapChain, const std::vector< std::vector< VkImageView >> &imageViews, const std::vector< VkSampler > &samplers, const std::vector< uint32_t > &bufferSizes, const std::vector< uint32_t > &ssboSizes, VkDescriptorSetLayout layout, PipelineType type, bool recreate, uint32_t recreateIdx=UINT32_MAX)
 Create descriptor. More...
 
const JEShaderGetShaderAt (int shaderID) const
 Get shader object. More...
 
const JEVulkanDescriptorGetDescriptorAt (int descriptorID) const
 Get descriptor object. More...
 
void UpdateBuffers (VkDevice device, uint32_t descriptorID, uint32_t imageIndex, const std::vector< const void * > &buffers, const std::vector< uint32_t > &bufferSizes, const std::vector< const void * > &ssboBuffers, const std::vector< uint32_t > &ssboSizes)
 Update the uniform and shader storage buffers of the specified descriptor. More...
 
void Cleanup ()
 Cleanup all managed shader and descriptor objects. More...
 

Detailed Description

The JEShaderManger class.

Class that manages all shader resources, including shader pipeline objects and descriptor objects. Provides creation and getter convenience functions.

See also
JEShader, JEVulkanDescriptor,
JEVulkanRenderer

Constructor & Destructor Documentation

◆ JEShaderManager() [1/2]

JoeEngine::JEShaderManager::JEShaderManager ( )
inline

Default constructor.

◆ JEShaderManager() [2/2]

JoeEngine::JEShaderManager::JEShaderManager ( VkDevice  device)
inline

Primary constructor.

◆ ~JEShaderManager()

JoeEngine::JEShaderManager::~JEShaderManager ( )
default

Destructor (default).

Member Function Documentation

◆ Cleanup()

void JoeEngine::JEShaderManager::Cleanup ( )
inline

Cleanup all managed shader and descriptor objects.

◆ CreateDescriptor()

uint32_t JoeEngine::JEShaderManager::CreateDescriptor ( VkDevice  device,
VkPhysicalDevice  physicalDevice,
const JEVulkanSwapChain swapChain,
const std::vector< std::vector< VkImageView >> &  imageViews,
const std::vector< VkSampler > &  samplers,
const std::vector< uint32_t > &  bufferSizes,
const std::vector< uint32_t > &  ssboSizes,
VkDescriptorSetLayout  layout,
PipelineType  type,
bool  recreate,
uint32_t  recreateIdx = UINT32_MAX 
)
inline

Create descriptor.

Creates a new descriptor object given various images and buffers.

Parameters
devicethe Vulkan logical device.
physicalDevicethe Vulkan physical device.
swapChainthe Vulkan swap chain.
imageViewslist of Vulkan image view objects.
samplerslist of Vulkna texture sampler objects.
bufferSizeslist of sizes of each uniform buffer.
ssboSizeslist of sizes for each shader storage buffer.
layoutthe Vulkan descriptor set layout for the new descriptor object.
typethe shader pipeline type that this descriptor will be used with (and must be compatible with).
recreateflag indicating whether this function is being called to recreate an existing descriptor object or to create a new one.
recreateIdxif we are recreating an existing descriptor object, this is the ID of that descriptor object.
Returns
an ID corresponding to the newly created descriptor.

◆ CreateShader()

uint32_t JoeEngine::JEShaderManager::CreateShader ( VkDevice  device,
VkPhysicalDevice  physicalDevice,
const JEVulkanSwapChain swapChain,
const MaterialComponent materialComponent,
uint32_t  numSourceTextures,
VkRenderPass  renderPass,
const std::string &  vertPath,
const std::string &  fragPath,
PipelineType  type 
)
inline

Create new shader.

Creates a new shader given the necessary shader pipeline settings.

Parameters
devicethe Vulkan logical device.
physicalDevicethe Vulkan physical device.
swapChainthe Vulkan swap chain.
materialComponentthe material component with shader settings.
numSourceTexturesthe number of source textures for the shader.
renderPassthe Vulkan render pass object during which the new shader will be used.
vertPaththe vertex shader file source path.
fragPaththe fragment shader file source path.
typethe shader pipeline type enum.
Returns
a shader ID corresponding to the newly created shader object.

◆ GetDescriptorAt()

const JEVulkanDescriptor& JoeEngine::JEShaderManager::GetDescriptorAt ( int  descriptorID) const
inline

Get descriptor object.

Parameters
descriptorIDthe ID of the descriptor object to access.
Returns
the descriptor object corresponding to the given ID.

◆ GetShaderAt()

const JEShader* JoeEngine::JEShaderManager::GetShaderAt ( int  shaderID) const
inline

Get shader object.

Parameters
shaderIDthe ID of the shader object to access.
Returns
the shader object corresponding to the given ID.

◆ UpdateBuffers()

void JoeEngine::JEShaderManager::UpdateBuffers ( VkDevice  device,
uint32_t  descriptorID,
uint32_t  imageIndex,
const std::vector< const void * > &  buffers,
const std::vector< uint32_t > &  bufferSizes,
const std::vector< const void * > &  ssboBuffers,
const std::vector< uint32_t > &  ssboSizes 
)
inline

Update the uniform and shader storage buffers of the specified descriptor.

Parameters
devicethe Vulkan logical device.
descriptorIDthe ID of the descriptor object to update.
imageIndexthe currently active swap chain image index.
bufferslist of uniform data buffers
bufferSizeslist of uniform data buffer sizes
ssboBufferslist of shader storage data buffers
ssboSizeslist of shader storage data buffer sizes

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