evan 2026.1.4
Evan
Loading...
Searching...
No Matches
evan::GPUShader Class Reference

The GPUShader class represents a shader used in rendering. More...

#include <headers/evan/GPUShader.hpp>

Inheritance diagram for evan::GPUShader:
Collaboration diagram for evan::GPUShader:

Public Member Functions

 GPUShader (VkDevice device, const utility::graphic::Shader &shader)
 Constructs a GPUShader object with the given vertex and fragment shader code.
 
void destroy ()
 Destroys the shader modules associated with this GPUShader object.
 
VkShaderModule getVertexShaderModule () const
 Retrieves the vertex shader module.
 
VkShaderModule getFragmentShaderModule () const
 Retrieves the fragment shader module.
 

Protected Member Functions

void cleanup ()
 Releases the Vulkan shader modules owned by this shader.
 

Protected Attributes

VkShaderModule _vertexShaderModule = VK_NULL_HANDLE
 
VkShaderModule _fragmentShaderModule = VK_NULL_HANDLE
 
std::vector< uint32_t > _vertexCode
 
std::vector< uint32_t > _fragmentCode
 
VkDevice _logicalDevice = VK_NULL_HANDLE
 

Detailed Description

The GPUShader class represents a shader used in rendering.

The GPUShader class encapsulates the vertex and fragment shader modules, as well as the SPIR-V code for both shaders. It provides methods to retrieve the shader modules and to destroy the shader modules when they are no longer needed.

Definition at line 28 of file GPUShader.hpp.

Constructor & Destructor Documentation

◆ GPUShader()

evan::GPUShader::GPUShader ( VkDevice  device,
const utility::graphic::Shader &  shader 
)

Constructs a GPUShader object with the given vertex and fragment shader code.

Parameters
deviceThe Vulkan device used to create the shader modules.
shaderA reference to the utility::graphic::Shader object containing the shader data.

Member Function Documentation

◆ cleanup()

void evan::GPUShader::cleanup ( )
protected

Releases the Vulkan shader modules owned by this shader.

Idempotent: modules are null-checked and reset after destruction.

◆ destroy()

void evan::GPUShader::destroy ( )

Destroys the shader modules associated with this GPUShader object.

Note
This method is idempotent: after a module is destroyed its handle is reset to VK_NULL_HANDLE, so calling destroy() multiple times is safe. It is also invoked automatically by the destructor.

◆ getFragmentShaderModule()

VkShaderModule evan::GPUShader::getFragmentShaderModule ( ) const

Retrieves the fragment shader module.

Returns
The Vulkan shader module for the fragment shader.

◆ getVertexShaderModule()

VkShaderModule evan::GPUShader::getVertexShaderModule ( ) const

Retrieves the vertex shader module.

Returns
The Vulkan shader module for the vertex shader.

Member Data Documentation

◆ _fragmentCode

std::vector<uint32_t> evan::GPUShader::_fragmentCode
protected

SPIR-V code for the fragment shader

Definition at line 95 of file GPUShader.hpp.

◆ _fragmentShaderModule

VkShaderModule evan::GPUShader::_fragmentShaderModule = VK_NULL_HANDLE
protected

Vulkan shader module for the fragment shader

Definition at line 85 of file GPUShader.hpp.

◆ _logicalDevice

VkDevice evan::GPUShader::_logicalDevice = VK_NULL_HANDLE
protected

Vulkan logical device used to create and manage shader modules

Definition at line 100 of file GPUShader.hpp.

◆ _vertexCode

std::vector<uint32_t> evan::GPUShader::_vertexCode
protected

SPIR-V code for the vertex shader

Definition at line 90 of file GPUShader.hpp.

◆ _vertexShaderModule

VkShaderModule evan::GPUShader::_vertexShaderModule = VK_NULL_HANDLE
protected

Vulkan shader module for the vertex shader

Definition at line 80 of file GPUShader.hpp.


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