Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::VulkanRenderer Class Reference

Vulkan implementation of the RendererAPI interface. More...

#include <VulkanRenderer.h>

Inheritance diagram for Raven::VulkanRenderer:
Raven::RendererAPI Raven::Castable< RendererAPI >

Public Member Functions

void Init (Window &wnd) override
 Initializes the VulkanRenderer with a reference to the application window. Creates Vulkan instance, device, surface, and prepares rendering resources.
void Shutdown () override
 Cleans up all Vulkan resources and shuts down the renderer.
void InitCommandBuffers () override
 Allocates and initializes Vulkan command buffers for rendering.
void CreateDescriptorPool ()
 Creates the Vulkan descriptor pool used for descriptor set allocations.
void CreateTimeStampQueryPool ()
void GetTimeStampResults ()
void BeginFrame () override
 Begins the frame by acquiring the next swapchain image and preparing command buffers.
void EndFrame () override
 Ends the frame, submitting command buffers and presenting the swapchain image.
void BeginRenderPass (const Ref< RenderPass > &renderPass, const Ref< RenderCommandBuffer > &commandBuffer) override
 Begins a render pass by recording commands into the provided command buffer.
void DrawGeometry (Ref< RenderCommandBuffer > commandBuffer, Ref< Pipeline > pipeline, Ref< VertexBuffer > vertexBuffer, Ref< IndexBuffer > indexBuffer, const Crux::mat4 &transform) override
 Issues a draw call for geometry with vertex and index buffers.
void DrawStaticMesh (Ref< RenderCommandBuffer > commandBuffer, Ref< Pipeline > pipeline, Ref< Mesh > mesh, const Crux::mat4 &transform) override
 Issues a draw call for a static mesh.
void EndRenderPass (const Ref< RenderCommandBuffer > &commandBuffer) override
 Ends the currently active render pass.
Ref< RenderCommandBufferGetCommandBuffer () const override
 Gets the primary command buffer for the current frame.
Ref< RenderCommandBufferGetCommandBuffer (u8 index) const override
 Gets a command buffer by index (for multi-buffering).
u32 GetImageIndex () const override
 Gets the current swapchain image index.
void * GetDescriptorPool () const override
 Gets the Vulkan descriptor pool handle.
void * BeginSingleTimeCommand () override
 Begins recording a single-use command buffer for immediate commands.
void EndSingleTimeCommand (void *commandBuffer) override
 Ends recording of a single-use command buffer and submits it.
void CopyBuffer (void *srcBuffer, void *dstBuffer, u32 size) override
 Copies data from a source buffer to a destination buffer.
void CopyBufferToImage (void *srcBuffer, void *dstImage, u32 width, u32 height) override
 Copies buffer data into an image (texture).
void TransitionImageLayout (void *image, ImageFormat format, ImageLayout oldLayout, ImageLayout newLayout, u32 mipCount) override
 Transitions an image layout between usage states (e.g. undefined to shader read).
void Submit (const StaticMeshSubmission &submission) override
 Submits a static mesh to be rendered during the current frame.
const std::vector< StaticMeshSubmission > & GetStaticMeshSubmissions () const override
 Gets all static mesh submissions queued for the current frame.
void * GetInstance () const override
 Gets the raw Vulkan instance handle.
WindowGetWindow () const override
 Gets the window reference the renderer is rendering to.
Public Member Functions inherited from Raven::RendererAPI
virtual ~RendererAPI ()=default
Public Member Functions inherited from Raven::Castable< RendererAPI >
T & As ()
 Non-const version of As<T>(), for casting to a non-const target type.

Additional Inherited Members

Public Types inherited from Raven::RendererAPI
enum class  API : u8 { None = 0 , Vulkan = 1 }
 Supported rendering backends. More...
Static Public Member Functions inherited from Raven::RendererAPI
static API GetAPI ()
 Returns the current rendering API in use.
static Scope< RendererAPICreate ()
 Factory method to create the renderer API instance for the selected backend.
static std::string_view APIToString ()
 Converts the API enum to a string representation.
Static Public Attributes inherited from Raven::RendererAPI
static float m_ElapsedTime = 0.0f
 Elapsed time tracker for rendering, to be improved with GPU timers.

Detailed Description

Vulkan implementation of the RendererAPI interface.

Responsible for managing Vulkan instance, device, swapchain, command buffers, descriptor pools, and rendering submissions.

Member Function Documentation

◆ BeginFrame()

void Raven::VulkanRenderer::BeginFrame ( )
overridevirtual

Begins the frame by acquiring the next swapchain image and preparing command buffers.

Implements Raven::RendererAPI.

◆ BeginRenderPass()

void Raven::VulkanRenderer::BeginRenderPass ( const Ref< RenderPass > & renderPass,
const Ref< RenderCommandBuffer > & commandBuffer )
overridevirtual

Begins a render pass by recording commands into the provided command buffer.

Parameters
renderPassThe render pass to begin.
commandBufferThe command buffer to record commands into.

Implements Raven::RendererAPI.

◆ BeginSingleTimeCommand()

void * Raven::VulkanRenderer::BeginSingleTimeCommand ( )
overridevirtual

Begins recording a single-use command buffer for immediate commands.

Returns
Raw pointer to the Vulkan command buffer.

Implements Raven::RendererAPI.

◆ CopyBuffer()

void Raven::VulkanRenderer::CopyBuffer ( void * srcBuffer,
void * dstBuffer,
u32 size )
overridevirtual

Copies data from a source buffer to a destination buffer.

Parameters
srcBufferSource Vulkan buffer pointer.
dstBufferDestination Vulkan buffer pointer.
sizeNumber of bytes to copy.

Implements Raven::RendererAPI.

◆ CopyBufferToImage()

void Raven::VulkanRenderer::CopyBufferToImage ( void * srcBuffer,
void * dstImage,
u32 width,
u32 height )
overridevirtual

Copies buffer data into an image (texture).

Parameters
srcBufferSource Vulkan buffer pointer.
dstImageDestination Vulkan image pointer.
widthWidth of the image.
heightHeight of the image.

Implements Raven::RendererAPI.

◆ CreateDescriptorPool()

void Raven::VulkanRenderer::CreateDescriptorPool ( )

Creates the Vulkan descriptor pool used for descriptor set allocations.

◆ CreateTimeStampQueryPool()

void Raven::VulkanRenderer::CreateTimeStampQueryPool ( )

◆ DrawGeometry()

void Raven::VulkanRenderer::DrawGeometry ( Ref< RenderCommandBuffer > commandBuffer,
Ref< Pipeline > pipeline,
Ref< VertexBuffer > vertexBuffer,
Ref< IndexBuffer > indexBuffer,
const Crux::mat4 & transform )
overridevirtual

Issues a draw call for geometry with vertex and index buffers.

Parameters
commandBufferThe command buffer to record into.
pipelineThe graphics pipeline to use.
vertexBufferThe vertex buffer containing geometry vertices.
indexBufferThe index buffer for indexed drawing.
transformTransformation matrix applied to the geometry.

Implements Raven::RendererAPI.

◆ DrawStaticMesh()

void Raven::VulkanRenderer::DrawStaticMesh ( Ref< RenderCommandBuffer > commandBuffer,
Ref< Pipeline > pipeline,
Ref< Mesh > mesh,
const Crux::mat4 & transform )
overridevirtual

Issues a draw call for a static mesh.

Parameters
commandBufferThe command buffer to record into.
pipelineThe graphics pipeline to use.
meshThe static mesh to draw.
transformTransformation matrix applied to the mesh.

Implements Raven::RendererAPI.

◆ EndFrame()

void Raven::VulkanRenderer::EndFrame ( )
overridevirtual

Ends the frame, submitting command buffers and presenting the swapchain image.

Implements Raven::RendererAPI.

◆ EndRenderPass()

void Raven::VulkanRenderer::EndRenderPass ( const Ref< RenderCommandBuffer > & commandBuffer)
overridevirtual

Ends the currently active render pass.

Parameters
commandBufferThe command buffer being recorded.

Implements Raven::RendererAPI.

◆ EndSingleTimeCommand()

void Raven::VulkanRenderer::EndSingleTimeCommand ( void * commandBuffer)
overridevirtual

Ends recording of a single-use command buffer and submits it.

Parameters
commandBufferRaw pointer to the Vulkan command buffer.

Implements Raven::RendererAPI.

◆ GetCommandBuffer() [1/2]

Ref< RenderCommandBuffer > Raven::VulkanRenderer::GetCommandBuffer ( ) const
inlineoverridevirtual

Gets the primary command buffer for the current frame.

Returns
Reference-counted pointer to the command buffer.

Implements Raven::RendererAPI.

◆ GetCommandBuffer() [2/2]

Ref< RenderCommandBuffer > Raven::VulkanRenderer::GetCommandBuffer ( u8 index) const
inlineoverridevirtual

Gets a command buffer by index (for multi-buffering).

Parameters
indexIndex of the command buffer.
Returns
Reference-counted pointer to the command buffer.

Implements Raven::RendererAPI.

◆ GetDescriptorPool()

void * Raven::VulkanRenderer::GetDescriptorPool ( ) const
inlineoverridevirtual

Gets the Vulkan descriptor pool handle.

Returns
Raw Vulkan descriptor pool pointer.

Implements Raven::RendererAPI.

◆ GetImageIndex()

u32 Raven::VulkanRenderer::GetImageIndex ( ) const
inlineoverridevirtual

Gets the current swapchain image index.

Returns
Index of the swapchain image.

Implements Raven::RendererAPI.

◆ GetInstance()

void * Raven::VulkanRenderer::GetInstance ( ) const
inlineoverridevirtual

Gets the raw Vulkan instance handle.

Returns
Vulkan instance pointer.

Implements Raven::RendererAPI.

◆ GetStaticMeshSubmissions()

const std::vector< StaticMeshSubmission > & Raven::VulkanRenderer::GetStaticMeshSubmissions ( ) const
inlineoverridevirtual

Gets all static mesh submissions queued for the current frame.

Returns
Vector of static mesh submissions.

Implements Raven::RendererAPI.

◆ GetTimeStampResults()

void Raven::VulkanRenderer::GetTimeStampResults ( )

◆ GetWindow()

Window & Raven::VulkanRenderer::GetWindow ( ) const
inlineoverridevirtual

Gets the window reference the renderer is rendering to.

Returns
Reference to the Window.

Implements Raven::RendererAPI.

◆ Init()

void Raven::VulkanRenderer::Init ( Window & wnd)
overridevirtual

Initializes the VulkanRenderer with a reference to the application window. Creates Vulkan instance, device, surface, and prepares rendering resources.

Parameters
wndThe window to render into.

Implements Raven::RendererAPI.

◆ InitCommandBuffers()

void Raven::VulkanRenderer::InitCommandBuffers ( )
overridevirtual

Allocates and initializes Vulkan command buffers for rendering.

Implements Raven::RendererAPI.

◆ Shutdown()

void Raven::VulkanRenderer::Shutdown ( )
overridevirtual

Cleans up all Vulkan resources and shuts down the renderer.

Implements Raven::RendererAPI.

◆ Submit()

void Raven::VulkanRenderer::Submit ( const StaticMeshSubmission & submission)
overridevirtual

Submits a static mesh to be rendered during the current frame.

Parameters
submissionThe mesh submission data.

Implements Raven::RendererAPI.

◆ TransitionImageLayout()

void Raven::VulkanRenderer::TransitionImageLayout ( void * image,
ImageFormat format,
ImageLayout oldLayout,
ImageLayout newLayout,
u32 mipCount )
overridevirtual

Transitions an image layout between usage states (e.g. undefined to shader read).

Parameters
imageVulkan image pointer.
formatImage format.
oldLayoutCurrent image layout.
newLayoutDesired image layout.
mipCountNumber of mip levels.

Implements Raven::RendererAPI.


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