Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::RendererAPI Class Referenceabstract

Core abstraction for GPU rendering operations. More...

#include <RendererAPI.h>

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

Public Types

enum class  API : u8 { None = 0 , Vulkan = 1 }
 Supported rendering backends. More...

Public Member Functions

virtual ~RendererAPI ()=default
virtual void Init (Window &wnd)=0
 Initializes the rendering backend with a reference to the window.
virtual void Shutdown ()=0
 Shuts down the rendering backend, releasing all GPU resources.
virtual void InitCommandBuffers ()=0
 Initializes command buffers for multi-buffered rendering.
virtual void BeginFrame ()=0
 Marks the start of rendering a new frame.
virtual void EndFrame ()=0
 Marks the end of rendering the current frame and presents it.
virtual void BeginRenderPass (const Ref< RenderPass > &renderPass, const Ref< RenderCommandBuffer > &commandBuffer)=0
 Begins a render pass with the given framebuffer and command buffer.
virtual void EndRenderPass (const Ref< RenderCommandBuffer > &commandBuffer)=0
 Ends the current render pass.
virtual Ref< RenderCommandBufferGetCommandBuffer () const =0
 Gets the currently active command buffer.
virtual Ref< RenderCommandBufferGetCommandBuffer (u8 index) const =0
 Gets the command buffer at a specific index (for multi-buffering).
virtual u32 GetImageIndex () const =0
 Gets the current swapchain image index.
virtual void CopyBuffer (void *srcBuffer, void *dstBuffer, u32 size)=0
 Copies data between GPU buffers.
virtual void CopyBufferToImage (void *srcBuffer, void *dstImage, u32 width, u32 height)=0
 Copies buffer data to an image resource.
virtual void TransitionImageLayout (void *image, ImageFormat format, ImageLayout oldLayout, ImageLayout newLayout, u32 mipCount)=0
 Transitions an image's layout for usage in different pipeline stages.
virtual void * BeginSingleTimeCommand ()=0
 Begins recording a single-time command buffer for transient operations.
virtual void EndSingleTimeCommand (void *commandBuffer)=0
 Ends recording and submits a single-time command buffer.
virtual void DrawGeometry (Ref< RenderCommandBuffer > commandBuffer, Ref< Pipeline > pipeline, Ref< VertexBuffer > vertexBuffer, Ref< IndexBuffer > indexBuffer, const Crux::mat4 &transform)=0
 Issues a draw call for indexed geometry.
virtual void DrawStaticMesh (Ref< RenderCommandBuffer > commandBuffer, Ref< Pipeline > pipeline, Ref< Mesh > mesh, const Crux::mat4 &transform)=0
 Issues a draw call for a static mesh.
virtual void Submit (const StaticMeshSubmission &submission)=0
 Submits a static mesh draw submission for batched rendering.
virtual const std::vector< StaticMeshSubmission > & GetStaticMeshSubmissions () const =0
 Returns a read-only list of all static mesh submissions queued.
virtual void * GetDescriptorPool () const =0
 Gets the underlying descriptor pool handle (opaque).
virtual void * GetInstance () const =0
 Gets the underlying instance handle (opaque).
virtual WindowGetWindow () const =0
 Gets a reference to the associated application window.
Public Member Functions inherited from Raven::Castable< RendererAPI >
T & As ()
 Non-const version of As<T>(), for casting to a non-const target type.

Static Public Member Functions

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

static float m_ElapsedTime = 0.0f
 Elapsed time tracker for rendering, to be improved with GPU timers.

Detailed Description

Core abstraction for GPU rendering operations.

This interface defines all necessary commands and states to interact with the GPU through the chosen graphics API. It separates high-level frame control from low-level command buffer management.

Usage:

  • Initialize with a Window reference.
  • Manage frame lifecycle with BeginFrame/EndFrame.
  • Use render passes to define render targets and scopes.
  • Submit draw calls and static mesh submissions.
Note
: Internally exposes Vulkan-specific handles as opaque pointers for flexibility but encourages safe encapsulation in backend implementations.
: These functions get called by the static IllumineRenderer functions.

Member Enumeration Documentation

◆ API

enum class Raven::RendererAPI::API : u8
strong

Supported rendering backends.

Enumerator
None 
Vulkan 

Constructor & Destructor Documentation

◆ ~RendererAPI()

virtual Raven::RendererAPI::~RendererAPI ( )
virtualdefault

Member Function Documentation

◆ APIToString()

std::string_view Raven::RendererAPI::APIToString ( )
inlinestatic

Converts the API enum to a string representation.

◆ BeginFrame()

virtual void Raven::RendererAPI::BeginFrame ( )
pure virtual

Marks the start of rendering a new frame.

Implemented in Raven::VulkanRenderer.

◆ BeginRenderPass()

virtual void Raven::RendererAPI::BeginRenderPass ( const Ref< RenderPass > & renderPass,
const Ref< RenderCommandBuffer > & commandBuffer )
pure virtual

Begins a render pass with the given framebuffer and command buffer.

Parameters
renderPassThe target render pass defining attachments and states.
commandBufferThe command buffer to record commands into.

Implemented in Raven::VulkanRenderer.

◆ BeginSingleTimeCommand()

virtual void * Raven::RendererAPI::BeginSingleTimeCommand ( )
pure virtual

Begins recording a single-time command buffer for transient operations.

Returns
Pointer to the command buffer.

Implemented in Raven::VulkanRenderer.

◆ CopyBuffer()

virtual void Raven::RendererAPI::CopyBuffer ( void * srcBuffer,
void * dstBuffer,
u32 size )
pure virtual

Copies data between GPU buffers.

Parameters
srcBufferSource buffer pointer.
dstBufferDestination buffer pointer.
sizeSize of data to copy in bytes.

Implemented in Raven::VulkanRenderer.

◆ CopyBufferToImage()

virtual void Raven::RendererAPI::CopyBufferToImage ( void * srcBuffer,
void * dstImage,
u32 width,
u32 height )
pure virtual

Copies buffer data to an image resource.

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

Implemented in Raven::VulkanRenderer.

◆ Create()

Scope< RendererAPI > Raven::RendererAPI::Create ( )
static

Factory method to create the renderer API instance for the selected backend.

◆ DrawGeometry()

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

Issues a draw call for indexed geometry.

Parameters
commandBufferCommand buffer to record into.
pipelinePipeline state object.
vertexBufferVertex buffer reference.
indexBufferIndex buffer reference.
transformTransform matrix for the geometry.

Implemented in Raven::VulkanRenderer.

◆ DrawStaticMesh()

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

Issues a draw call for a static mesh.

Parameters
commandBufferCommand buffer to record into.
pipelinePipeline state object.
meshMesh to draw.
transformTransform matrix for the mesh.

Implemented in Raven::VulkanRenderer.

◆ EndFrame()

virtual void Raven::RendererAPI::EndFrame ( )
pure virtual

Marks the end of rendering the current frame and presents it.

Implemented in Raven::VulkanRenderer.

◆ EndRenderPass()

virtual void Raven::RendererAPI::EndRenderPass ( const Ref< RenderCommandBuffer > & commandBuffer)
pure virtual

Ends the current render pass.

Parameters
commandBufferThe command buffer used for recording.

Implemented in Raven::VulkanRenderer.

◆ EndSingleTimeCommand()

virtual void Raven::RendererAPI::EndSingleTimeCommand ( void * commandBuffer)
pure virtual

Ends recording and submits a single-time command buffer.

Parameters
commandBufferPointer to the command buffer.

Implemented in Raven::VulkanRenderer.

◆ GetAPI()

API Raven::RendererAPI::GetAPI ( )
inlinestatic

Returns the current rendering API in use.

◆ GetCommandBuffer() [1/2]

virtual Ref< RenderCommandBuffer > Raven::RendererAPI::GetCommandBuffer ( ) const
pure virtual

Gets the currently active command buffer.

Returns
Reference to the active command buffer.

Implemented in Raven::VulkanRenderer.

◆ GetCommandBuffer() [2/2]

virtual Ref< RenderCommandBuffer > Raven::RendererAPI::GetCommandBuffer ( u8 index) const
pure virtual

Gets the command buffer at a specific index (for multi-buffering).

Parameters
indexIndex of the command buffer.
Returns
Reference to the command buffer at the specified index.

Implemented in Raven::VulkanRenderer.

◆ GetDescriptorPool()

virtual void * Raven::RendererAPI::GetDescriptorPool ( ) const
pure virtual

Gets the underlying descriptor pool handle (opaque).

Returns
Pointer to the descriptor pool.

Implemented in Raven::VulkanRenderer.

◆ GetImageIndex()

virtual u32 Raven::RendererAPI::GetImageIndex ( ) const
pure virtual

Gets the current swapchain image index.

Returns
The index of the image currently targeted for rendering.

Implemented in Raven::VulkanRenderer.

◆ GetInstance()

virtual void * Raven::RendererAPI::GetInstance ( ) const
pure virtual

Gets the underlying instance handle (opaque).

Returns
Pointer to the instance.

Implemented in Raven::VulkanRenderer.

◆ GetStaticMeshSubmissions()

virtual const std::vector< StaticMeshSubmission > & Raven::RendererAPI::GetStaticMeshSubmissions ( ) const
pure virtual

Returns a read-only list of all static mesh submissions queued.

Returns
Vector of static mesh submissions.

Implemented in Raven::VulkanRenderer.

◆ GetWindow()

virtual Window & Raven::RendererAPI::GetWindow ( ) const
pure virtual

Gets a reference to the associated application window.

Returns
Reference to the Window.

Implemented in Raven::VulkanRenderer.

◆ Init()

virtual void Raven::RendererAPI::Init ( Window & wnd)
pure virtual

Initializes the rendering backend with a reference to the window.

Parameters
wndReference to the application window.

Implemented in Raven::VulkanRenderer.

◆ InitCommandBuffers()

virtual void Raven::RendererAPI::InitCommandBuffers ( )
pure virtual

Initializes command buffers for multi-buffered rendering.

Implemented in Raven::VulkanRenderer.

◆ Shutdown()

virtual void Raven::RendererAPI::Shutdown ( )
pure virtual

Shuts down the rendering backend, releasing all GPU resources.

Implemented in Raven::VulkanRenderer.

◆ Submit()

virtual void Raven::RendererAPI::Submit ( const StaticMeshSubmission & submission)
pure virtual

Submits a static mesh draw submission for batched rendering.

Parameters
submissionThe static mesh submission data.

Implemented in Raven::VulkanRenderer.

◆ TransitionImageLayout()

virtual void Raven::RendererAPI::TransitionImageLayout ( void * image,
ImageFormat format,
ImageLayout oldLayout,
ImageLayout newLayout,
u32 mipCount )
pure virtual

Transitions an image's layout for usage in different pipeline stages.

Parameters
imagePointer to the image resource.
formatFormat of the image.
oldLayoutCurrent layout of the image.
newLayoutDesired new layout.
mipCountNumber of mip levels.

Implemented in Raven::VulkanRenderer.

Member Data Documentation

◆ m_ElapsedTime

float Raven::RendererAPI::m_ElapsedTime = 0.0f
static

Elapsed time tracker for rendering, to be improved with GPU timers.


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