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
15namespace 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
25public:
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;
40
41private:
42 struct ShaderEntry {
43 vk::UniqueShaderModule module;
44 std::filesystem::file_time_type last_write_time;
45 std::string profile;
46 };
47
49 std::unordered_map<std::string, ShaderEntry> m_cache;
51};
52
53} // namespace sd
Definition ShaderCompiler.hpp:17
Compiles HLSL → SPIR-V and caches VkShaderModules.
Definition ShaderLibrary.hpp:24
ShaderLibrary & operator=(const ShaderLibrary &)=delete
VkShaderModule load(const std::string &hlsl_path, const std::string &profile)
Definition ShaderLibrary.cpp:14
ShaderCompiler m_compiler
Definition ShaderLibrary.hpp:50
void clear_cache()
Destroys all shader modules and clears the cache.
Definition ShaderLibrary.cpp:64
ShaderLibrary(const ShaderLibrary &)=delete
std::unordered_map< std::string, ShaderEntry > m_cache
Definition ShaderLibrary.hpp:49
VkDevice m_device
Definition ShaderLibrary.hpp:48
std::set< std::string > check_for_changes()
Definition ShaderLibrary.cpp:52
Definition Application.hpp:28
Definition ShaderLibrary.hpp:42
vk::UniqueShaderModule std::filesystem::file_time_type last_write_time
Definition ShaderLibrary.hpp:44
std::string profile
Definition ShaderLibrary.hpp:45
constexpr T g_type_max
Definition types.hpp:21