Raven Engine v0.1
A modern 3D Game Engine
Loading...
Searching...
No Matches
Raven::VulkanRenderer Class Reference

Vulkan implementation of the RendererAPI interface. More...

#include <VulkanRenderer.h>

Inherits Raven::RendererAPI.

Public Member Functions

ILLUMINE_API void Init (Window &wnd) override
 Initializes the VulkanRenderer with a reference to the application window. Creates Vulkan instance, device, surface, and prepares rendering resources.
ILLUMINE_API void Shutdown () override
 Cleans up all Vulkan resources and shuts down the renderer.
ILLUMINE_API void InitCommandBuffers () override
 Allocates and initializes Vulkan command buffers for rendering.
ILLUMINE_API void CreateDescriptorPool ()
 Creates the Vulkan descriptor pool used for descriptor set allocations.
ILLUMINE_API void BeginFrame () override
 Begins the frame by acquiring the next swapchain image and preparing command buffers.
ILLUMINE_API void EndFrame () override
 Ends the frame, submitting command buffers and presenting the swapchain image.
ILLUMINE_API void BeginRenderPass (Ref< RenderPass > renderPass) override
 Begins a render pass by recording commands into the provided command buffer.
ILLUMINE_API void DrawGeometry (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.
ILLUMINE_API void DrawGeometryIndexed (Ref< VertexBuffer > vb, Ref< IndexBuffer > ib, u32 indexCount) override
ILLUMINE_API void DrawGeometryRaw (Ref< VertexBuffer > vb, u32 vertexCount) override
ILLUMINE_API void DrawFullscreenQuad (Ref< Pipeline > pipeline, Ref< VertexBuffer > vb, Ref< IndexBuffer > ib) override
ILLUMINE_API void DrawStaticMesh (Ref< Pipeline > pipeline, Ref< Mesh > mesh, const Crux::mat4 &transform, const Crux::Frustum &frustum) override
 Issues a draw call for a static mesh.
ILLUMINE_API void DrawStaticMeshDepthOnly (Ref< Pipeline > pipeline, Ref< Mesh > mesh, const Crux::mat4 &transform, const Crux::Frustum &frustum) override
ILLUMINE_API void DrawSkybox (Ref< Pipeline > pipeline, Ref< VertexBuffer > vb) override
ILLUMINE_API void EndRenderPass () 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.
ILLUMINE_API void * BeginSingleTimeCommand () override
 Begins recording a single-use command buffer for immediate commands.
ILLUMINE_API void EndSingleTimeCommand (void *commandBuffer) override
 Ends recording of a single-use command buffer and submits it.
ILLUMINE_API void BeginGPUPerf (const std::string &name) override
ILLUMINE_API void EndGPUPerf () override
ILLUMINE_API std::vector< GPUTimeSpanGetGPUTimes () override
ILLUMINE_API void CopyBuffer (void *srcBuffer, void *dstBuffer, u32 size) override
 Copies data from a source buffer to a destination buffer.
ILLUMINE_API void CopyBufferToImage (void *srcBuffer, void *dstImage, u32 width, u32 height) override
 Copies buffer data into an image (texture).
ILLUMINE_API void TransitionImage (Ref< Image2D > image, ResourceState newState) override
ILLUMINE_API void TransitionImageLayout (Ref< Image2D > image, ImageFormat format, ImageLayout oldLayout, ImageLayout newLayout, u32 mipCount) override
 Transitions an image layout between usage states (e.g. undefined to shader read).
ILLUMINE_API void FullBarrier () override
ILLUMINE_API void StorageWriteToComputeRead () override
ILLUMINE_API void StorageWriteToFragmentRead () override
ILLUMINE_API void DepthWriteToComputeRead () override
ILLUMINE_API void ComputeReadToDepthWrite () override
ILLUMINE_API 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::RefCounted
 RefCounted ()
virtual ~RefCounted ()
void IncRefCount ()
void DecRefCount ()
u32 GetRefCount () const

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 Ref< 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.

◆ BeginGPUPerf()

void Raven::VulkanRenderer::BeginGPUPerf ( const std::string & name)
overridevirtual

Implements Raven::RendererAPI.

◆ BeginRenderPass()

void Raven::VulkanRenderer::BeginRenderPass ( Ref< RenderPass > renderPass)
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.

◆ ComputeReadToDepthWrite()

void Raven::VulkanRenderer::ComputeReadToDepthWrite ( )
overridevirtual

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.

◆ DepthWriteToComputeRead()

void Raven::VulkanRenderer::DepthWriteToComputeRead ( )
overridevirtual

Implements Raven::RendererAPI.

◆ DrawFullscreenQuad()

void Raven::VulkanRenderer::DrawFullscreenQuad ( Ref< Pipeline > pipeline,
Ref< VertexBuffer > vb,
Ref< IndexBuffer > ib )
overridevirtual

Implements Raven::RendererAPI.

◆ DrawGeometry()

void Raven::VulkanRenderer::DrawGeometry ( 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.

◆ DrawGeometryIndexed()

void Raven::VulkanRenderer::DrawGeometryIndexed ( Ref< VertexBuffer > vb,
Ref< IndexBuffer > ib,
u32 indexCount )
overridevirtual

Implements Raven::RendererAPI.

◆ DrawGeometryRaw()

void Raven::VulkanRenderer::DrawGeometryRaw ( Ref< VertexBuffer > vb,
u32 vertexCount )
overridevirtual

Implements Raven::RendererAPI.

◆ DrawSkybox()

void Raven::VulkanRenderer::DrawSkybox ( Ref< Pipeline > pipeline,
Ref< VertexBuffer > vb )
overridevirtual

Implements Raven::RendererAPI.

◆ DrawStaticMesh()

void Raven::VulkanRenderer::DrawStaticMesh ( Ref< Pipeline > pipeline,
Ref< Mesh > mesh,
const Crux::mat4 & transform,
const Crux::Frustum & frustum )
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.

◆ DrawStaticMeshDepthOnly()

void Raven::VulkanRenderer::DrawStaticMeshDepthOnly ( Ref< Pipeline > pipeline,
Ref< Mesh > mesh,
const Crux::mat4 & transform,
const Crux::Frustum & frustum )
overridevirtual

Implements Raven::RendererAPI.

◆ EndFrame()

void Raven::VulkanRenderer::EndFrame ( )
overridevirtual

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

Implements Raven::RendererAPI.

◆ EndGPUPerf()

void Raven::VulkanRenderer::EndGPUPerf ( )
overridevirtual

Implements Raven::RendererAPI.

◆ EndRenderPass()

void Raven::VulkanRenderer::EndRenderPass ( )
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.

◆ FullBarrier()

void Raven::VulkanRenderer::FullBarrier ( )
overridevirtual

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.

◆ GetGPUTimes()

std::vector< GPUTimeSpan > Raven::VulkanRenderer::GetGPUTimes ( )
overridevirtual

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.

◆ 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.

◆ StorageWriteToComputeRead()

void Raven::VulkanRenderer::StorageWriteToComputeRead ( )
overridevirtual

Implements Raven::RendererAPI.

◆ StorageWriteToFragmentRead()

void Raven::VulkanRenderer::StorageWriteToFragmentRead ( )
overridevirtual

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.

◆ TransitionImage()

void Raven::VulkanRenderer::TransitionImage ( Ref< Image2D > image,
ResourceState newState )
overridevirtual

Implements Raven::RendererAPI.

◆ TransitionImageLayout()

void Raven::VulkanRenderer::TransitionImageLayout ( Ref< Image2D > image,
ImageFormat format,
ImageLayout oldLayout,
ImageLayout newLayout,
u32 mipCount )
overridevirtual

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

Parameters
imageImage ref.
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: