|
KarmaEngine
Game Engine for practical learning and research purposes
|
Vulkan specific implementation of VertexArray class. More...
#include <VulkanVertexArray.h>
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< Material > | GetMaterial () 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 VulkanIndexBuffer * | GetIndexBuffer () 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 VertexArray * | Create () |
| Create the VertexArray object based on the rendering API chosen by the programmer. | |
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.
| Karma::VulkanVertexArray::VulkanVertexArray | ( | ) |
A constructor.
|
virtual |
A destructor.
Cleans up vulkan resources associated with the vertex array including pipelines, pipeline layouts, descriptor set layouts, and descriptor pools.
|
overridevirtual |
For legacy purposes. Use Mesh abstraction.
| vertexBuffer | The vertex buffer to be added |
Implements Karma::VertexArray.
|
overridevirtual |
For binding OpenGL vertex array object.
Implements Karma::VertexArray.
| void Karma::VulkanVertexArray::CleanupKarmaGuiGraphicsPipeline | ( | ) |
Cleans up the KarmaGui graphics pipeline (m_graphicsPipelineKGWindow).
| void Karma::VulkanVertexArray::CleanupPipeline | ( | ) |
Cleans up the graphics pipeline and related resources (pipelinelayout and descriptorsets).
| void Karma::VulkanVertexArray::CreateDescriptorPool | ( | ) |
| void Karma::VulkanVertexArray::CreateDescriptorSetLayout | ( | ) |
| 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.
| void Karma::VulkanVertexArray::CreateGraphicsPipeline | ( | ) |
| void Karma::VulkanVertexArray::CreateKarmaGuiGraphicsPipeline | ( | VkRenderPass | renderPassKG, |
| float | windowKGWidth, | ||
| float | windowKGHeight ) |
| void Karma::VulkanVertexArray::CreatePipelineLayout | ( | ) |
| 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):
| code | The SPIR-V bytecode as a vector of uint32_t |
| 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.
|
inlineoverridevirtual |
Implements Karma::VertexArray.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Implements Karma::VertexArray.
| 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.
|
overridevirtual |
For legacy purposes. Use Mesh abstraction.
| indexBuffer | The index buffer to be set |
Implements Karma::VertexArray.
|
overridevirtual |
Sets the material.
| material | Shader and texture setting |
Implements Karma::VertexArray.
|
overridevirtual |
Sets the index and vertex buffers seperately.
| mesh | A collection of index and vertex buffers to be set |
Implements Karma::VertexArray.
|
overridevirtual |
For legacy purposes. Use Material abstraction.
| shader | The shader to be set |
Implements Karma::VertexArray.
|
inlineoverridevirtual |
Undo what Bind does.
Implements Karma::VertexArray.
|
overridevirtual |
Called each game loop for updating.
Implements Karma::VertexArray.