KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
Karma::VulkanVertexArray Class Reference

Vulkan specific implementation of VertexArray class. More...

#include <VulkanVertexArray.h>

Inheritance diagram for Karma::VulkanVertexArray:
Karma::VertexArray

Public Member Functions

 VulkanVertexArray ()
 A constructor.
virtual ~VulkanVertexArray ()
 A destructor.
virtual void Bind () const override
 For binding OpenGL vertex array object.
virtual void UnBind () const override
 Undo what Bind does.
virtual void AddVertexBuffer (const std::shared_ptr< VertexBuffer > &vertexBuffer) override
 For legacy purposes. Use Mesh abstraction.
virtual void SetIndexBuffer (const std::shared_ptr< IndexBuffer > &indexBuffer) override
 For legacy purposes. Use Mesh abstraction.
virtual void SetShader (std::shared_ptr< Shader > shader) override
 For legacy purposes. Use Material abstraction.
virtual void SetMesh (std::shared_ptr< Mesh > mesh) override
 Sets the index and vertex buffers seperately.
virtual void SetMaterial (std::shared_ptr< Material > material) override
 Sets the material.
void CreateDescriptorSetLayout ()
 Creates the descriptor set layout .
void CreatePipelineLayout ()
 Creates the pipeline layout.
void CreateGraphicsPipeline ()
 Creates the graphics pipeline.
void CreateKarmaGuiGraphicsPipeline (VkRenderPass renderPassKG, float windowKGWidth, float windowKGHeight)
 Creates the graphics pipeline for KarmaGui window display.
void CreateDescriptorPool ()
 Creates the descriptor pool.
void CreateDescriptorSets ()
 Creates the descriptor sets.
void GenerateVulkanVA ()
 Generates the Vulkan Vertex Array by creating descriptor set layout, pipeline layout, graphics pipeline, descriptor pool, and descriptor sets.
void RecreateVulkanVA ()
 Recreates the Vulkan Vertex Array.
void CleanupPipeline ()
 Cleans up the graphics pipeline and related resources (pipelinelayout and descriptorsets).
void CleanupKarmaGuiGraphicsPipeline ()
 Cleans up the KarmaGui graphics pipeline (m_graphicsPipelineKGWindow).
VkShaderModule CreateShaderModule (const std::vector< uint32_t > &code)
 Creates a Vulkan shader module from SPIR-V bytecode.
VkPipeline GetGraphicsPipeline () const
VkPipeline GetKarmaGuiGraphicsPipeline () const
VkPipelineLayout GetGraphicsPipelineLayout () const
const std::shared_ptr< VulkanShader > & GetShader () const
const std::shared_ptr< VulkanVertexBuffer > & GetVertexBuffer () const
const std::vector< VkDescriptorSet > & GetDescriptorSets () const
virtual std::shared_ptr< MaterialGetMaterial () const override
 Getter function for material.
virtual void UpdateProcessAndSetReadyForSubmission () const override
 Called each game loop for updating.
virtual const std::vector< std::shared_ptr< VertexBuffer > > & GetVertexBuffers () const override
virtual const VulkanIndexBufferGetIndexBuffer () const override
Public Member Functions inherited from Karma::VertexArray
virtual ~VertexArray ()
 A destructor.

Additional Inherited Members

Static Public Member Functions inherited from Karma::VertexArray
static VertexArrayCreate ()
 Create the VertexArray object based on the rendering API chosen by the programmer.

Detailed Description

Vulkan specific implementation of VertexArray class.

This class handles the creation and management of Vulkan vertex arrays, including descriptor sets, pipeline layouts, and graphics pipelines. Furthermore the shaders, materials, vertex buffers, and index buffers are also managed here.

A VertexArray is an object, associated with a scene, containing all of the state needed to supply vertex data while drawing.

See also
RenderCommand::DrawIndexed
Since
Karma 1.0.0

Constructor & Destructor Documentation

◆ VulkanVertexArray()

Karma::VulkanVertexArray::VulkanVertexArray ( )

A constructor.

Since
Karma 1.0.0

◆ ~VulkanVertexArray()

Karma::VulkanVertexArray::~VulkanVertexArray ( )
virtual

A destructor.

Cleans up vulkan resources associated with the vertex array including pipelines, pipeline layouts, descriptor set layouts, and descriptor pools.

See also
VulkanVertexArray::CleanupPipeline()
Since
Karma 1.0.0

Member Function Documentation

◆ AddVertexBuffer()

void Karma::VulkanVertexArray::AddVertexBuffer ( const std::shared_ptr< VertexBuffer > & vertexBuffer)
overridevirtual

For legacy purposes. Use Mesh abstraction.

Parameters
vertexBufferThe vertex buffer to be added
See also
Mesh, VulkanVertexArray::SetMesh()
Since
Karma 1.0.0

Implements Karma::VertexArray.

◆ Bind()

void Karma::VulkanVertexArray::Bind ( ) const
overridevirtual

For binding OpenGL vertex array object.

Todo
Seems only specific to OpenGL. Need to think the abstraction with Vulkan in mind
Since
Karma 1.0.0

Implements Karma::VertexArray.

◆ CleanupKarmaGuiGraphicsPipeline()

void Karma::VulkanVertexArray::CleanupKarmaGuiGraphicsPipeline ( )

Cleans up the KarmaGui graphics pipeline (m_graphicsPipelineKGWindow).

See also
KarmaGuiVulkanHandler::KarmaGui_ImplVulkan_DestroyWindow

◆ CleanupPipeline()

void Karma::VulkanVertexArray::CleanupPipeline ( )

Cleans up the graphics pipeline and related resources (pipelinelayout and descriptorsets).

See also
VulkanRendererAPI::RecreateCommandBuffersPipelineSwapchain()
Since
Karma 1.0.0

◆ CreateDescriptorPool()

void Karma::VulkanVertexArray::CreateDescriptorPool ( )

Creates the descriptor pool.

See also
VulkanVertexArray::GenerateVulkanVA()
Since
Karma 1.0.0

◆ CreateDescriptorSetLayout()

void Karma::VulkanVertexArray::CreateDescriptorSetLayout ( )

Creates the descriptor set layout .

See also
VulkanVertexArray::GenerateVulkanVA()
Since
Karma 1.0.0

◆ CreateDescriptorSets()

void Karma::VulkanVertexArray::CreateDescriptorSets ( )

Creates the descriptor sets.

In Vulkan, descriptor sets are allocated from a descriptor pool and are used to bind resources like uniform buffers and textures to shaders. Survey KarmaGuiRenderer::FrameRender to see how descriptor sets are bound before drawing.

See also
VulkanVertexArray::GenerateVulkanVA()
Since
Karma 1.0.0

◆ CreateGraphicsPipeline()

void Karma::VulkanVertexArray::CreateGraphicsPipeline ( )

Creates the graphics pipeline.

See also
VulkanVertexArray::GenerateVulkanVA()
Since
Karma 1.0.0

◆ CreateKarmaGuiGraphicsPipeline()

void Karma::VulkanVertexArray::CreateKarmaGuiGraphicsPipeline ( VkRenderPass renderPassKG,
float windowKGWidth,
float windowKGHeight )

Creates the graphics pipeline for KarmaGui window display.

Parameters
renderPassKGThe render pass created specifically for KarmaGui offscreen texture rendering
windowKGWidthWidth of the KarmaGui window
windowKGHeightHeight of the KarmaGui window
See also
KarmaGuiVulkanHandler::CreateOffScreenTextureResources()
Since
Karma 1.0.0

◆ CreatePipelineLayout()

void Karma::VulkanVertexArray::CreatePipelineLayout ( )

Creates the pipeline layout.

See also
VulkanVertexArray::GenerateVulkanVA()
Since
Karma 1.0.0

◆ CreateShaderModule()

VkShaderModule Karma::VulkanVertexArray::CreateShaderModule ( const std::vector< uint32_t > & code)

Creates a Vulkan shader module from SPIR-V bytecode.

This is specifically used when creating the graphics pipeline to load vertex and fragment shaders.

For instance while creating vertex shader stage info (pipeline creation):

VkPipelineShaderStageCreateInfo vertShaderStageInfo{};
vertShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
vertShaderStageInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
vertShaderStageInfo.module = vertShaderModule;
vertShaderStageInfo.pName = "main";
Parameters
codeThe SPIR-V bytecode as a vector of uint32_t
Returns
The created VkShaderModule
Since
Karma 1.0.0

◆ GenerateVulkanVA()

void Karma::VulkanVertexArray::GenerateVulkanVA ( )

Generates the Vulkan Vertex Array by creating descriptor set layout, pipeline layout, graphics pipeline, descriptor pool, and descriptor sets.

Called when setting material or shader to setup the necessary Vulkan structures for rendering. Survey VulkanVertexArray::SetShader or VulkanVertexArray::SetMaterial.

See also
VulkanVertexArray::CreateDescriptorSetLayout()
VulkanVertexArray::CreatePipelineLayout()
VulkanVertexArray::CreateGraphicsPipeline()
VulkanVertexArray::CreateDescriptorPool()
VulkanVertexArray::CreateDescriptorSets()
Since
Karma 1.0.0

◆ GetIndexBuffer()

virtual const VulkanIndexBuffer * Karma::VulkanVertexArray::GetIndexBuffer ( ) const
inlineoverridevirtual

Implements Karma::VertexArray.

◆ GetMaterial()

virtual std::shared_ptr< Material > Karma::VulkanVertexArray::GetMaterial ( ) const
inlineoverridevirtual

Getter function for material.

Since
Karma 1.0.0

Implements Karma::VertexArray.

◆ GetVertexBuffers()

virtual const std::vector< std::shared_ptr< VertexBuffer > > & Karma::VulkanVertexArray::GetVertexBuffers ( ) const
inlineoverridevirtual

Implements Karma::VertexArray.

◆ RecreateVulkanVA()

void Karma::VulkanVertexArray::RecreateVulkanVA ( )

Recreates the Vulkan Vertex Array.

Used when the swapchain is recreated (e.g. window resize) to ensure the vertex array is compatible with the new swapchain.

See also
VulkanRendererAPI::RecreateCommandBuffersPipelineSwapchain(), KarmaGuiRenderer::GiveLoopBeginControlToVulkan()
Since
Karma 1.0.0

◆ SetIndexBuffer()

void Karma::VulkanVertexArray::SetIndexBuffer ( const std::shared_ptr< IndexBuffer > & indexBuffer)
overridevirtual

For legacy purposes. Use Mesh abstraction.

Parameters
indexBufferThe index buffer to be set
See also
Mesh, VulkanVertexArray::SetMesh()
Since
Karma 1.0.0

Implements Karma::VertexArray.

◆ SetMaterial()

void Karma::VulkanVertexArray::SetMaterial ( std::shared_ptr< Material > material)
overridevirtual

Sets the material.

Parameters
materialShader and texture setting
Since
Karma 1.0.0

Implements Karma::VertexArray.

◆ SetMesh()

void Karma::VulkanVertexArray::SetMesh ( std::shared_ptr< Mesh > mesh)
overridevirtual

Sets the index and vertex buffers seperately.

Parameters
meshA collection of index and vertex buffers to be set
See also
Since
Karma 1.0.0

Implements Karma::VertexArray.

◆ SetShader()

void Karma::VulkanVertexArray::SetShader ( std::shared_ptr< Shader > shader)
overridevirtual

For legacy purposes. Use Material abstraction.

Parameters
shaderThe shader to be set
See also
Material, VulkanVertexArray::SetMaterial()
Since
Karma 1.0.0

Implements Karma::VertexArray.

◆ UnBind()

virtual void Karma::VulkanVertexArray::UnBind ( ) const
inlineoverridevirtual

Undo what Bind does.

Todo
Again, need to think the abstraction
Since
Karma 1.0.0

Implements Karma::VertexArray.

◆ UpdateProcessAndSetReadyForSubmission()

void Karma::VulkanVertexArray::UpdateProcessAndSetReadyForSubmission ( ) const
overridevirtual

Called each game loop for updating.

Note
includes uniform updation (vertex coordinates updation in shader by view and projection matrices)
Since
Karma 1.0.0

Implements Karma::VertexArray.


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