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

Vulkan specific implementation of RendererAPI pure virtual functions. More...

#include <VulkanRendererAPI.h>

Inheritance diagram for Karma::VulkanRendererAPI:
Karma::RendererAPI

Public Member Functions

 VulkanRendererAPI ()
 A constructor.
virtual ~VulkanRendererAPI ()
 A destructor.
virtual void SetClearColor (const glm::vec4 &color) override
 Sets the color to be used for clear (rendering) screen.
virtual void Clear () override
 Clear the rendering screen. Not much use in Vulkan as such since we record commands in command buffers.
virtual void BeginScene () override
 Setting up resources for rendering of a scene which includes allocating command buffers if not already done or when swapchain is rebuilt.
virtual void DrawIndexed (std::shared_ptr< VertexArray > vertexArray) override
 Routine for drawing primitives.
virtual void EndScene () override
 Instructions for end of the scene.
void AllocateCommandBuffers ()
 Allocates resources for command buffers.
void RecordCommandBuffers (VkCommandBuffer commandBuffer, uint32_t imageIndex)
 Records the command buffers with rendering commands for a particular image in the swapchain.
void SubmitCommandBuffers ()
 Submits the recorded command buffers to the graphics queue for execution.
void CreateSynchronicity ()
 Creates synchronization objects like semaphores and fences for coordinating rendering operations.
void ClearVulkanRendererAPI ()
 Clears up VulkanRendererAPI specific resources like command buffers and synchronization objects.
void RemoveSynchronicity ()
 Removes synchronization objects like semaphores and fences.
void RecreateCommandBuffersPipelineSwapchain ()
 Recreates command buffers, graphics pipelines, and uniform buffer objects when swapchain is recreated (like on window resize when acquiring next image from swapchain gives VK_ERROR_OUT_OF_DATE_KHR).
void RecreateCommandBuffersAndSwapChain ()
 Recreates command buffers and swapchain when swapchain is recreated (like on window resize when acquiring next image from swapchain gives VK_ERROR_OUT_OF_DATE_KHR).
const std::vector< VkCommandBuffer > & GetCommandBuffers () const
const int & GetMaxFramesInFlight () const
const std::vector< VkFence > & GetFences () const
const std::vector< VkSemaphore > & GetImageAvailableSemaphores () const
const std::vector< VkSemaphore > GetRenderFinishedSemaphore () const
Public Member Functions inherited from Karma::RendererAPI
virtual ~RendererAPI ()
 A destructor.
glm::vec4 & GetClearColor () const
 Getter for m_ClearColor variable.

Additional Inherited Members

Public Types inherited from Karma::RendererAPI
enum class  API { None = 0 , OpenGL = 1 , Vulkan = 2 }
 The rendering API used by the Engine. More...
Static Public Member Functions inherited from Karma::RendererAPI
static API GetAPI ()
 Getter for rendering api being used.
Static Protected Attributes inherited from Karma::RendererAPI
static glm::vec4 m_ClearColor = { 0.0f, 0.0f, 0.0f, 0.0f }

Detailed Description

Vulkan specific implementation of RendererAPI pure virtual functions.

See also
RendererAPI
Since
Karma 1.0.0

Constructor & Destructor Documentation

◆ VulkanRendererAPI()

Karma::VulkanRendererAPI::VulkanRendererAPI ( )

A constructor.

Note
Vulkan specific resoures are allocated in VulkanContext::Init()
Since
Karma 1.0.0

◆ ~VulkanRendererAPI()

Karma::VulkanRendererAPI::~VulkanRendererAPI ( )
virtual

A destructor.

Note
Vulkan specific resources are deallocated in VulkanContext::~VulkanContext()
Since
Karma 1.0.0

Member Function Documentation

◆ AllocateCommandBuffers()

void Karma::VulkanRendererAPI::AllocateCommandBuffers ( )

Allocates resources for command buffers.

Command buffers are objects used to record commands which can be subsequently submitted to a device queue for execution. For instance the graphics and presentation queues.

Since
Karma 1.0.0

◆ BeginScene()

void Karma::VulkanRendererAPI::BeginScene ( )
overridevirtual

Setting up resources for rendering of a scene which includes allocating command buffers if not already done or when swapchain is rebuilt.

See also
RenderCommand::BeginScene, VulkanRendererAPI::RecreateCommandBuffersAndSwapChain()
Since
Karma 1.0.0

Implements Karma::RendererAPI.

◆ Clear()

void Karma::VulkanRendererAPI::Clear ( )
overridevirtual

Clear the rendering screen. Not much use in Vulkan as such since we record commands in command buffers.

The commandbuffers are reset and begin command recording afresh each frame in RecordCommandBuffers() which includes clearing the screen.

Since
Karma 1.0.0

Implements Karma::RendererAPI.

◆ ClearVulkanRendererAPI()

void Karma::VulkanRendererAPI::ClearVulkanRendererAPI ( )

Clears up VulkanRendererAPI specific resources like command buffers and synchronization objects.

See also
VulkanContext::~VulkanContext()
Since
Karma 1.0.0

◆ CreateSynchronicity()

void Karma::VulkanRendererAPI::CreateSynchronicity ( )

Creates synchronization objects like semaphores and fences for coordinating rendering operations.

Since
Karma 1.0.0

◆ DrawIndexed()

void Karma::VulkanRendererAPI::DrawIndexed ( std::shared_ptr< VertexArray > vertexArray)
overridevirtual

Routine for drawing primitives.

Parameters
vertexArrayThe format and relevant information of the rendrable vertex data
See also
VulkanVertexArray
Since
Karma 1.0.0

Implements Karma::RendererAPI.

◆ EndScene()

void Karma::VulkanRendererAPI::EndScene ( )
overridevirtual

Instructions for end of the scene.

See also
RenderCommand::EndScene
Since
Karma 1.0.0

Implements Karma::RendererAPI.

◆ RecordCommandBuffers()

void Karma::VulkanRendererAPI::RecordCommandBuffers ( VkCommandBuffer commandBuffer,
uint32_t imageIndex )

Records the command buffers with rendering commands for a particular image in the swapchain.

Parameters
commandBufferThe command buffer to be recorded
imageIndexThe index of the swapchain image to record commands for
See also
VulkanRendererAPI::SubmitCommandBuffers()
Since
Karma 1.0.0

◆ RecreateCommandBuffersAndSwapChain()

void Karma::VulkanRendererAPI::RecreateCommandBuffersAndSwapChain ( )

Recreates command buffers and swapchain when swapchain is recreated (like on window resize when acquiring next image from swapchain gives VK_ERROR_OUT_OF_DATE_KHR).

Note
Seems like better to calls this than RecreateCommandBuffersPipelineSwapchain()
See also
KarmaGuiRenderer::GiveLoopBeginControlToVulkan()
Since
Karma 1.0.0

◆ RecreateCommandBuffersPipelineSwapchain()

void Karma::VulkanRendererAPI::RecreateCommandBuffersPipelineSwapchain ( )

Recreates command buffers, graphics pipelines, and uniform buffer objects when swapchain is recreated (like on window resize when acquiring next image from swapchain gives VK_ERROR_OUT_OF_DATE_KHR).

See also
VulkanRendererAPI::SubmitCommandBuffers()
Since
Karma 1.0.0

◆ RemoveSynchronicity()

void Karma::VulkanRendererAPI::RemoveSynchronicity ( )

Removes synchronization objects like semaphores and fences.

See also
VulkanRendererAPI::ClearVulkanRendererAPI()
Since
Karma 1.0.0

◆ SetClearColor()

void Karma::VulkanRendererAPI::SetClearColor ( const glm::vec4 & color)
overridevirtual

Sets the color to be used for clear (rendering) screen.

Parameters
colorThe color to be used for clearing
Since
Karma 1.0.0

Implements Karma::RendererAPI.

◆ SubmitCommandBuffers()

void Karma::VulkanRendererAPI::SubmitCommandBuffers ( )

Submits the recorded command buffers to the graphics queue for execution.

See also
VulkanRendererAPI::DrawIndexed(), VulkanRendererAPI::RecordCommandBuffers()
Since
Karma 1.0.0

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