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