sandbox
Loading...
Searching...
No Matches
compiler.hpp
1#ifndef LIBSBX_GRAPHICS_PIPELINE_COMPILER_HPP_
2#define LIBSBX_GRAPHICS_PIPELINE_COMPILER_HPP_
3
4#include <vulkan/vulkan.hpp>
5
6#include <slang.h>
7#include <slang-com-ptr.h>
8#include <slang-com-helper.h>
9
10#include <libsbx/utility/logger.hpp>
11#include <libsbx/utility/exception.hpp>
12#include <libsbx/utility/target.hpp>
13
14#include <libsbx/memory/blob.hpp>
15
16namespace sbx::graphics {
17
18class compiler {
19
20public:
21
22 struct define {
23 std::string key;
24 std::string value;
25 }; // struct define
26
28
29 struct per_stage {
30 std::string entry_point{"main"};
31 std::vector<std::string> specializations{};
32 }; // struct per_stage
33
34 std::filesystem::path path{};
35 std::vector<define> defines{};
36 std::unordered_map<SlangStage, compile_request::per_stage> per_stage{};
37
38 }; // struct compile_request
39
41 std::unordered_map<SlangStage, std::vector<std::uint32_t>> code;
42 }; // struct compile_result
43
44 compiler();
45
46 ~compiler();
47
48 auto compile(const compile_request& compile_request) -> compile_result;
49
50private:
51
52 static auto _read_file(const std::filesystem::path& path) -> std::string;
53
54 auto _create_session(const compile_request& compile_request) -> Slang::ComPtr<slang::ISession>;
55
56 Slang::ComPtr<slang::IGlobalSession> _global_session;
57
58}; // class compiler
59
60} // namespace sbx::graphics
61
62#endif // LIBSBX_GRAPHICS_PIPELINE_COMPILER_HPP_
Definition: compiler.hpp:18
Definition: compiler.hpp:27
Definition: compiler.hpp:40
Definition: compiler.hpp:22