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

Vulkan-specific material resource binder. More...

#include <VulkanMaterial.h>

Inheritance diagram for Raven::VulkanMaterial:
Raven::Material

Public Member Functions

 VulkanMaterial (const Ref< Shader > &shader)
 Constructs a VulkanMaterial using the provided shader.
void Destroy ()
 Releases all GPU-bound material resources.
void SetTexture (const std::string &name, const Ref< Texture2D > &texture) override
 Assigns a 2D texture to the material.
void SetFloat (const std::string &name, float value) override
 Assigns a scalar float value to the material.
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.
void Bind (const Ref< RenderCommandBuffer > &commandBuffer, void *pipelineLayout) override
 Binds this material's resources to the GPU pipeline.

Additional Inherited Members

Static Public Member Functions inherited from Raven::Material
static Ref< MaterialCreate (const 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 ( const 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 ( const 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.

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

◆ SetTexture()

void Raven::VulkanMaterial::SetTexture ( const std::string & name,
const 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: