Class Shader#
Defined in File Shader.h
Nested Relationships#
Nested Types#
Inheritance Relationships#
Derived Type#
public TRAP::Graphics::API::VulkanShader
(Class VulkanShader)
Class Documentation#
-
class Shader#
Subclassed by TRAP::Graphics::API::VulkanShader
Public Functions
-
virtual ~Shader() = default#
Destructor.
-
bool Reload()#
Reload shader.
- Returns:
True on successful reload (valid shader), else (invalid shader) otherwise.
-
virtual constexpr usize GetID() const noexcept = 0#
Retrieve the unique identifier of the shader.
Note
The ID of the shader changes when reloaded.
-
constexpr std::string GetName() const noexcept#
Retrieve the name of the shader.
- Returns:
Name of the shader.
-
std::filesystem::path GetFilePath() const noexcept#
Retrieve the file path of the shader.
- Returns:
File path of the shader.
-
constexpr RendererAPI::ShaderStage GetShaderStages() const noexcept#
Retrieve the shader stages of the shader.
- Returns:
Shader stages of the shader.
-
constexpr const std::vector<Macro> &GetMacros() const noexcept#
Retrieve the used macros of the shader.
- Returns:
Used macros.
-
TRAP::Ref<RootSignature> GetRootSignature() const noexcept#
Retrieve the root signature of the shader.
- Returns:
Root signature of the shader.
-
constexpr const std::array<TRAP::Scope<DescriptorSet>, RendererAPI::MaxDescriptorSets> &GetDescriptorSets() const noexcept#
Retrieve the descriptor sets of the shader.
- Returns:
Descriptor sets of the shader.
-
constexpr bool IsShaderValid() const noexcept#
Retrieve whether the shader is valid (i.e. loaded and compiled) or not.
- Returns:
True if shader is valid, false otherwise.
-
constexpr RendererAPI::ShaderType GetShaderType() const noexcept#
Retrieve the type of the shader.
- Returns:
ShaderType.
-
virtual void Use(const Window &window = *TRAP::Application::GetWindow()) = 0#
Use shader for rendering on the given window.
Remark
Headless mode: This function is not available in headless mode.
-
virtual void UseTexture(u32 set, u32 binding, const TRAP::Graphics::Texture &texture, const Window &window = *TRAP::Application::GetWindow()) const = 0#
Use texture with this shader on the given window.
Remark
Headless mode: This function is not available in headless mode.
-
virtual void UseTextures(u32 set, u32 binding, const std::vector<const TRAP::Graphics::Texture*> &textures, const Window &window = *TRAP::Application::GetWindow()) const = 0#
Use multiple textures with this shader on the given window.
Remark
Headless mode: This function is not available in headless mode.
-
virtual void UseSampler(u32 set, u32 binding, const TRAP::Graphics::Sampler &sampler, const Window &window = *TRAP::Application::GetWindow()) const = 0#
Use sampler with this shader on the given window.
Remark
Headless mode: This function is not available in headless mode.
-
virtual void UseSamplers(u32 set, u32 binding, const std::vector<const TRAP::Graphics::Sampler*> &samplers, const Window &window = *TRAP::Application::GetWindow()) const = 0#
Use multiple samplers with this shader on the given window.
Remark
Headless mode: This function is not available in headless mode.
-
virtual void UseUBO(u32 set, u32 binding, const TRAP::Graphics::UniformBuffer &uniformBuffer, u64 size = 0, u64 offset = 0, const Window &window = *TRAP::Application::GetWindow()) const = 0#
Use uniform buffer object with this shader on the given window.
Remark
Headless mode: This function is not available in headless mode.
-
virtual void UseSSBO(u32 set, u32 binding, const TRAP::Graphics::StorageBuffer &storageBuffer, u64 size = 0, const Window &window = *TRAP::Application::GetWindow()) const = 0#
Use shader storage buffer object with this shader on the given window.
Remark
Headless mode: This function is not available in headless mode.
Public Static Functions
-
static Ref<Shader> CreateFromFile(RendererAPI::ShaderType shaderType, const std::string &name, const std::filesystem::path &filePath, const std::vector<Macro> &userMacros = {})#
Create a shader from file.
-
static Ref<Shader> CreateFromFile(RendererAPI::ShaderType shaderType, const std::filesystem::path &filePath, const std::vector<Macro> &userMacros = {})#
Create a shader from file. File name will be used as the shader name.
-
static Ref<Shader> CreateFromSource(RendererAPI::ShaderType shaderType, const std::string &name, const std::string &glslSource, const std::vector<Macro> &userMacros = {})#
Create a shader from GLSL source.
Public Static Attributes
-
static constexpr std::array<std::string_view, 3> SupportedShaderFormatSuffixes = {".shader", ".glsl", ".tp-spv"}#
Protected Functions
-
Shader(RendererAPI::ShaderType shaderType, std::string name, bool valid, RendererAPI::ShaderStage stages, const std::vector<Macro> &userMacros = {}, std::filesystem::path filepath = "")#
Constructor.
-
virtual void Init(const RendererAPI::BinaryShaderDesc &desc) = 0#
Initialize API dependent shader.
- Parameters:
desc – Binary shader description.
-
virtual void Shutdown() = 0#
Shutdown API dependent shader.
Protected Attributes
-
std::string m_name#
-
std::filesystem::path m_filepath#
-
RendererAPI::ShaderStage m_shaderStages = {}#
-
TRAP::Ref<RootSignature> m_rootSignature#
-
std::array<TRAP::Scope<DescriptorSet>, RendererAPI::MaxDescriptorSets> m_descriptorSets = {}#
-
bool m_valid = {}#
-
RendererAPI::ShaderType m_shaderType#
-
struct Macro#
Struct defining a shader macro.
-
virtual ~Shader() = default#