Class Shader¶
Defined in File shader.h
Inheritance Relationships¶
Base Type¶
public portal::Resource(Class Resource)
Derived Type¶
public portal::renderer::vulkan::VulkanShader(Class VulkanShader)
Class Documentation¶
-
class Shader : public portal::Resource¶
Manages shader variants with different permutations.
Compiles and caches shader variants for different sets of defines, allowing multiple materials to share shader code with different configurations.
Subclassed by portal::renderer::vulkan::VulkanShader
Public Functions
-
void load_source(Buffer &&new_source, const std::filesystem::path &shader_path)¶
Loads shader source code.
- Parameters:
new_source – Shader source buffer
shader_path – Source file path
-
uint64_t compile_with_permutations(const std::vector<ShaderDefine> &permutations)¶
Compiles shader with given defines.
- Parameters:
permutations – List of shader defines
- Returns:
Hash to retrieve compiled variant
-
virtual WeakReference<ShaderVariant> get_shader(uint64_t shader_hash) = 0¶
Gets compiled shader variant.
- Parameters:
shader_hash – Permutation hash
- Returns:
Shader variant reference
Public Static Functions
-
static inline portal::ResourceType static_type()¶
Protected Functions
-
uint64_t calculate_permutations_hash(const std::vector<ShaderDefine> &permutations) const¶
Calculates hash from permutations.
- Parameters:
permutations – Shader defines
- Returns:
Unique hash for permutation set
-
void load_source(Buffer &&new_source, const std::filesystem::path &shader_path)¶