Kale
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Member Functions | List of all members
Kale::Vulkan::Shader Class Reference

#include <Shader.hpp>

+ Inheritance diagram for Kale::Vulkan::Shader:

Public Member Functions

 Shader ()
 
 Shader (const std::string &filename, ShaderType type, Device &device)
 
void init (const std::string &filename, ShaderType type, Device &device)
 
void freeResources (bool remove=true) override
 
vk::ShaderStageFlagBits getShaderStage () const
 
vk::PipelineShaderStageCreateInfo getShaderPipelineInfo () const
 

Public Attributes

ShaderType type
 
vk::UniqueShaderModule shader
 

Private Member Functions

std::vector< char > readFile (const std::string &filename) const
 
void createShaderModule (const std::vector< char > &code)
 

Additional Inherited Members

- Protected Member Functions inherited from Kale::Vulkan::ChildResource< Device >
 ChildResource ()
 
 ChildResource (Device &parent)
 
virtual void init (Device &parent)
 
 ~ChildResource ()
 
- Protected Attributes inherited from Kale::Vulkan::ChildResource< Device >
DeviceparentPtr
 

Detailed Description

Represents a simple Spir-V shader

Definition at line 44 of file Shader.hpp.

Constructor & Destructor Documentation

◆ Shader() [1/2]

Shader::Shader ( )

Creates an uninitialized object

Definition at line 33 of file Shader.cpp.

◆ Shader() [2/2]

Shader::Shader ( const std::string & filename,
ShaderType type,
Device & device )

Creates and initializes the object

Parameters
filenameThe filename of the shader to create from
typeThe type of shader
deviceThe device to link the shader to
Exceptions
Ifunable to open the file

Definition at line 44 of file Shader.cpp.

Member Function Documentation

◆ createShaderModule()

void Shader::createShaderModule ( const std::vector< char > & code)
private

Creates the shader module given the byte code

Parameters
codeThe byte code

Definition at line 84 of file Shader.cpp.

◆ freeResources()

void Shader::freeResources ( bool remove = true)
overridevirtual

Frees resources for this shader

Reimplemented from Kale::Vulkan::ChildResource< Device >.

Definition at line 93 of file Shader.cpp.

◆ getShaderPipelineInfo()

vk::PipelineShaderStageCreateInfo Shader::getShaderPipelineInfo ( ) const

Gets the shader pipeline create information from this shader module

Returns
The shader pipeline create information

Definition at line 117 of file Shader.cpp.

◆ getShaderStage()

vk::ShaderStageFlagBits Shader::getShaderStage ( ) const

Gets the shader stage from the type

Returns
the shader stage

Definition at line 102 of file Shader.cpp.

◆ init()

void Shader::init ( const std::string & filename,
ShaderType type,
Device & device )

Initializes this object

Parameters
filenameThe shader file to initialize from
typeThe type of shader this is
deviceThe device to link the shader to
Exceptions
Ifunable to open the file

Definition at line 56 of file Shader.cpp.

◆ readFile()

std::vector< char > Shader::readFile ( const std::string & filename) const
private

Reads a shader file

Parameters
filenameThe file name
Returns
the code
Exceptions
Ifunable to open the file

Definition at line 69 of file Shader.cpp.

Member Data Documentation

◆ shader

vk::UniqueShaderModule Kale::Vulkan::Shader::shader

The shader module

Definition at line 70 of file Shader.hpp.

◆ type

ShaderType Kale::Vulkan::Shader::type

The type of shader

Definition at line 65 of file Shader.hpp.


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