SDEngine
Game Engine
Loading...
Searching...
No Matches
ShaderLibrary.hpp
Go to the documentation of this file.
1
// TODO(docs): Add file-level Doxygen header
2
// - @file ShaderLibrary.hpp
3
// - @brief HLSL to SPIR-V compilation and shader module caching
4
// - Hot reload support via file change detection
5
#pragma once
6
7
#include <filesystem>
8
#include <set>
9
#include <string>
10
#include <unordered_map>
11
12
#include <vulkan/vulkan.hpp>
13
14
#include "
SD/core/ShaderCompiler.hpp
"
15
namespace
sd
{
16
17
// TODO(docs): Document ShaderLibrary class
18
// - Purpose: Compiles HLSL to SPIR-V and caches VkShaderModules
19
// - Load() method usage and profile parameter
20
// - Hot reload: CheckForChanges() + ClearCache() pattern
21
// - Integration with PipelineFactory
22
// - Example: Loading and using shaders
24
class
ShaderLibrary
{
25
public
:
26
explicit
ShaderLibrary
(
VkDevice
device
);
27
~ShaderLibrary
();
28
29
VkShaderModule
load
(
const
std::string&
hlsl_path
,
const
std::string& profile);
30
33
std::set<std::string>
check_for_changes
();
34
36
void
clear_cache
();
37
38
ShaderLibrary
(
const
ShaderLibrary
&) =
delete
;
39
ShaderLibrary
&
operator=
(
const
ShaderLibrary
&) =
delete
;
40
41
private
:
42
struct
ShaderEntry
{
43
vk::UniqueShaderModule
module
;
44
std::filesystem::file_time_type
last_write_time
;
45
std::string
profile
;
46
};
47
48
VkDevice
m_device
;
49
std::unordered_map<std::string, ShaderEntry>
m_cache
;
50
ShaderCompiler
m_compiler
;
51
};
52
53
}
// namespace sd
ShaderCompiler.hpp
sd::ShaderCompiler
Definition
ShaderCompiler.hpp:17
sd::ShaderLibrary
Compiles HLSL → SPIR-V and caches VkShaderModules.
Definition
ShaderLibrary.hpp:24
sd::ShaderLibrary::operator=
ShaderLibrary & operator=(const ShaderLibrary &)=delete
sd::ShaderLibrary::load
VkShaderModule load(const std::string &hlsl_path, const std::string &profile)
Definition
ShaderLibrary.cpp:14
sd::ShaderLibrary::m_compiler
ShaderCompiler m_compiler
Definition
ShaderLibrary.hpp:50
sd::ShaderLibrary::clear_cache
void clear_cache()
Destroys all shader modules and clears the cache.
Definition
ShaderLibrary.cpp:64
sd::ShaderLibrary::ShaderLibrary
ShaderLibrary(const ShaderLibrary &)=delete
sd::ShaderLibrary::m_cache
std::unordered_map< std::string, ShaderEntry > m_cache
Definition
ShaderLibrary.hpp:49
sd::ShaderLibrary::~ShaderLibrary
~ShaderLibrary()
sd::ShaderLibrary::m_device
VkDevice m_device
Definition
ShaderLibrary.hpp:48
sd::ShaderLibrary::check_for_changes
std::set< std::string > check_for_changes()
Definition
ShaderLibrary.cpp:52
sd
Definition
Application.hpp:28
sd::ShaderLibrary::ShaderEntry
Definition
ShaderLibrary.hpp:42
sd::ShaderLibrary::ShaderEntry::last_write_time
vk::UniqueShaderModule std::filesystem::file_time_type last_write_time
Definition
ShaderLibrary.hpp:44
sd::ShaderLibrary::ShaderEntry::profile
std::string profile
Definition
ShaderLibrary.hpp:45
g_type_max
constexpr T g_type_max
Definition
types.hpp:21
SD
include
SD
core
vulkan
ShaderLibrary.hpp
Generated by
1.9.8