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

Vulkan-specific material resource binder. More...

#include <VulkanMaterial.h>

Inherits Raven::Material.

Public Member Functions

ILLUMINE_API VulkanMaterial (Ref< Shader > shader)
 Constructs a VulkanMaterial using the provided shader.
ILLUMINE_API void Destroy ()
 Releases all GPU-bound material resources.
ILLUMINE_API void SetTexture (const std::string &name, Ref< Texture2D > texture) override
 Assigns a 2D texture to the material.
ILLUMINE_API void SetFloat (const std::string &name, float value) override
 Assigns a scalar float value to the material.
ILLUMINE_API void SetFloat3 (const std::string &name, const Crux::vec3 &value) override
 Assigns a 3-component float vector to the material.
void SetFloat4 (const std::string &name, const Crux::vec4 &value) override
 Assigns a 4-component float vector to the material.
ILLUMINE_API void Bind (Ref< RenderCommandBuffer > commandBuffer, void *pipelineLayout) override
 Binds this material's resources to the GPU pipeline.
void SetName (const std::string &name) override
 Sets the name of this material.
ILLUMINE_API const std::string & GetName () const override
 Retrieves the name of this material.
Public Member Functions inherited from Raven::Material
virtual ~Material ()=default
Public Member Functions inherited from Raven::RefCounted
 RefCounted ()
virtual ~RefCounted ()
void IncRefCount ()
void DecRefCount ()
u32 GetRefCount () const

Additional Inherited Members

Static Public Member Functions inherited from Raven::Material
static Ref< MaterialCreate (Ref< Shader > shader)
 Factory method to create a material for the active rendering backend.

Detailed Description

Vulkan-specific material resource binder.

VulkanMaterial extends Raven::Material and provides Vulkan-native handling of descriptors and shader resource bindings. It maintains maps of textures and uniform values which, when modified, mark the material as "dirty." On the next Bind() call, VulkanMaterial updates its descriptor set before binding it to the current command buffer.

Key Responsibilities:

  • Manage lifetime of material-associated GPU resources (textures, samplers).
  • Allocate and update descriptor sets from the renderer’s global descriptor pool.
  • Provide overrides for setting material uniforms (float, vec3, vec4).

Usage:

  • Construct with a reference to a Raven::Shader (VulkanShader backend required).
  • Call SetTexture/SetFloat/etc. to configure material parameters.
  • Call Bind(commandBuffer, pipelineLayout) to bind the material for rendering.

Constructor & Destructor Documentation

◆ VulkanMaterial()

Raven::VulkanMaterial::VulkanMaterial ( Ref< Shader > shader)

Constructs a VulkanMaterial using the provided shader.

Allocates a descriptor set from the global Vulkan descriptor pool using the layout defined in the shader (set = 2).

Parameters
shaderReference to a VulkanShader instance.

Member Function Documentation

◆ Bind()

void Raven::VulkanMaterial::Bind ( Ref< RenderCommandBuffer > commandBuffer,
void * pipelineLayout )
overridevirtual

Binds this material's resources to the GPU pipeline.

If the material is marked dirty (modified since last bind), this updates the Vulkan descriptor set with all bound textures and the primary sampler. The descriptor set is then bound to the provided command buffer at set = 2.

Parameters
commandBufferRender command buffer used for issuing Vulkan commands.
pipelineLayoutVulkan pipeline layout to bind against.

Implements Raven::Material.

◆ Destroy()

void Raven::VulkanMaterial::Destroy ( )

Releases all GPU-bound material resources.

This explicitly releases references to textures and the underlying shader. Should be called when the material is no longer needed.

◆ GetName()

ILLUMINE_API const std::string & Raven::VulkanMaterial::GetName ( ) const
inlineoverridevirtual

Retrieves the name of this material.

Returns
The assigned material name.

Implements Raven::Material.

◆ SetFloat()

void Raven::VulkanMaterial::SetFloat ( const std::string & name,
float value )
overridevirtual

Assigns a scalar float value to the material.

Parameters
nameThe shader uniform name.
valueThe float value to bind.

Implements Raven::Material.

◆ SetFloat3()

void Raven::VulkanMaterial::SetFloat3 ( const std::string & name,
const Crux::vec3 & value )
overridevirtual

Assigns a 3-component float vector to the material.

Parameters
nameThe shader uniform name.
valueThe vec3 value to bind.

Implements Raven::Material.

◆ SetFloat4()

void Raven::VulkanMaterial::SetFloat4 ( const std::string & name,
const Crux::vec4 & value )
overridevirtual

Assigns a 4-component float vector to the material.

Parameters
nameThe shader uniform name.
valueThe vec4 value to bind.

Implements Raven::Material.

◆ SetName()

void Raven::VulkanMaterial::SetName ( const std::string & name)
inlineoverridevirtual

Sets the name of this material.

Parameters
nameThe name to assign.

Implements Raven::Material.

◆ SetTexture()

void Raven::VulkanMaterial::SetTexture ( const std::string & name,
Ref< Texture2D > texture )
overridevirtual

Assigns a 2D texture to the material.

Parameters
nameThe shader resource name (e.g., "u_AlbedoMap").
textureReference to a Texture2D resource.

Implements Raven::Material.


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