class render::RendererUtility

Contains various utility methods that make various common operations in the renderer easier.

Public

Constructors

RendererUtility

RendererUtility()

Methods

~RendererUtility

~RendererUtility() noexcept = default

SetPass

void SetPass(GpuCommandBuffer &commandBuffer, const SPtr<Material> &material, u32 passIndex = 0, u32 variationIndex = 0)

Activates the specified material pass for rendering.

Any further draw calls will be executed using this pass.

commandBuffer
Command buffer to bind the material pass to.
material
Material containing the pass.
passIndex
Index of the pass in the material.
variationIndex
Index of the variation the pass belongs to, if the material has multiple variations.

SetComputePass

void SetComputePass(GpuCommandBuffer &commandBuffer, const SPtr<Material> &material, u32 passIndex = 0)

Activates the specified material pass for compute.

Any further dispatch calls will be executed using this pass.

commandBuffer
Command buffer to bind the pass to.
material
Material containing the pass.
passIndex
Index of the pass in the material.

SetPassParams

void SetPassParams(GpuCommandBuffer &commandBuffer, const SPtr<MaterialParameterAdapter> &adapter, u32 passIndex = 0)

Sets parameters (textures, samplers, buffers) for the currently active pass.

commandBuffer
Command buffer to bind the pass parameters to.
adapter
Object containing the parameters.
passIndex
Pass for which to set the parameters.

Draw

void Draw(GpuCommandBuffer &commandBuffer, const SPtr<MeshBase> &mesh, u32 instanceCount = 1)

Draws the specified mesh.

commandBuffer
Command buffer to encode the draw command on.
mesh
Mesh to draw.
instanceCount
Number of times to draw the mesh using instanced rendering.

Draw

void Draw(GpuCommandBuffer &commandBuffer, const SPtr<MeshBase> &mesh, const SubMesh &subMesh, u32 instanceCount = 1)

Draws the specified mesh.

commandBuffer
Command buffer to encode the draw command on.
mesh
Mesh to draw.
subMesh
Portion of the mesh to draw.
instanceCount
Number of times to draw the mesh using instanced rendering.

DrawMorph

void DrawMorph(GpuCommandBuffer &commandBuffer, const SPtr<MeshBase> &mesh, const SubMesh &subMesh, const SPtr<GpuBuffer> &morphVertices, const SPtr<VertexDescription> &morphVertexDescription)

Draws the specified mesh with an additional vertex buffer containing morph shape vertices.

commandBuffer
Command buffer to encode the draw command on.
mesh
Mesh to draw.
subMesh
Portion of the mesh to draw.
morphVertices
Buffer containing the morph shape vertices. Will be bound to stream 1. Expected to contain the same number of vertices as the source mesh.
morphVertexDescription
Object describing vertices of the provided mesh and the vertices provided in the morph vertex buffer.

Blit

void Blit(GpuCommandBuffer &commandBuffer, const BlitInformation &blitInformation)

Blits a source texture to a render target with optional filtering, blending, and coordinate transformations.

This method encapsulates the complete blit operation including render pass management and viewport setup.

commandBuffer
Command buffer to record the blit operation into.
blitInformation
Structure containing all blit parameters (source/destination, areas, options).

DrawScreenQuad

void DrawScreenQuad(GpuCommandBuffer &commandBuffer, const Area2 &uv, const Vector2I &textureSize = Vector2I(1, 1), u32 numInstances = 1, bool flipUV = false)

Draws a quad over the entire viewport in normalized device coordinates.

commandBuffer
Command buffer to encode the draw command on.
uv
UV coordinates to assign to the corners of the quad.
textureSize
Size of the texture the UV coordinates are specified for. If the UV coordinates are already in normalized (0, 1) range then keep this value as is. If the UV coordinates are in texels then set this value to the texture size so they can be normalized internally.
numInstances
How many instances of the quad to draw (using instanced rendering). Useful when drawing to 3D textures.
flipUV
If true, vertical UV coordinate will be flipped upside down.

DrawScreenQuad

void DrawScreenQuad(GpuCommandBuffer &commandBuffer, u32 numInstances = 1)

Draws a quad over the entire viewport in normalized device coordinates.

commandBuffer
Command buffer to encode the draw command on.
numInstances
How many instances of the quad to draw (using instanced rendering). Useful when drawing to 3D textures.

Clear

void Clear(GpuCommandBuffer &commandBuffer, u32 value)

Clears the currently bound render target to the provided integer value.

This is similar to RenderAPI::clearRenderTarget(), except it supports integer clears.

GetSphereStencil

SPtr<Mesh> GetSphereStencil() const

Returns a unit sphere stencil mesh.

GetBoxStencil

SPtr<Mesh> GetBoxStencil() const

Returns a unit axis aligned box stencil mesh.

GetSpotLightStencil

SPtr<Mesh> GetSpotLightStencil() const

Returns a stencil mesh used for a spot light.

Actual vertex positions need to be computed in shader as this method will return uninitialized vertex positions.

GetSkyBoxMesh

SPtr<Mesh> GetSkyBoxMesh() const

Returns a mesh that can be used for rendering a skybox.

staticInstance

static T &Instance()

Returns a reference to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticInstancePtr

static T *InstancePtr()

Returns a pointer to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticShutDown

static void ShutDown()

Shuts down this module and frees any resources it is using.

staticIsStarted

static bool IsStarted()

Query if the module has been started.

Protected

Methods

~Module<T>

virtual ~Module<T>() = default

OnStartUp

virtual void OnStartUp()

Override if you want your module to be notified once it has been constructed and started.

OnShutDown

virtual void OnShutDown()

Override if you want your module to be notified just before it is deleted.

staticInstanceInternal

static T *&InstanceInternal()

Returns a singleton instance of this module.

staticIsDestroyed

static bool &IsDestroyed()

Checks has the Module been shut down.

staticIsStartedUp

static bool &IsStartedUp()

Checks has the Module been started up.

Private

Fields

mFullScreenQuadIB

SPtr<GpuBuffer> mFullScreenQuadIB

mFullScreenQuadVB

SPtr<GpuBuffer> mFullScreenQuadVB

mFullscreenQuadVertexDescription

SPtr<VertexDescription> mFullscreenQuadVertexDescription

mNextQuadVBSlot

u32 mNextQuadVBSlot

mUnitSphereStencilMesh

SPtr<Mesh> mUnitSphereStencilMesh

mUnitBoxStencilMesh

SPtr<Mesh> mUnitBoxStencilMesh

mSpotLightStencilMesh

SPtr<Mesh> mSpotLightStencilMesh

mSkyBoxMesh

SPtr<Mesh> mSkyBoxMesh