Toast Engine
Loading...
Searching...
No Matches
slang_vfs.hpp
1// @file slang_vfs.hpp
2// @author Xein
3// @date 17 Jul 2026
4
5#pragma once
6
7#include <slang.h>
8#include <string>
9#include <string_view>
10#include <vector>
11
12namespace renderer {
13
14class SlangVfs final : public ISlangFileSystem {
15public:
16 static auto get() -> SlangVfs&;
17
18 SLANG_NO_THROW auto SLANG_MCALL queryInterface(const SlangUUID& uuid, void** out_object) -> SlangResult override;
19
20 SLANG_NO_THROW auto SLANG_MCALL addRef() -> uint32_t override { return 1; }
21
22 SLANG_NO_THROW auto SLANG_MCALL release() -> uint32_t override { return 1; }
23
24 SLANG_NO_THROW auto SLANG_MCALL castAs(const SlangUUID& uuid) -> void* override;
25
26 SLANG_NO_THROW auto SLANG_MCALL loadFile(const char* path, ISlangBlob** out_blob) -> SlangResult override;
27
28 static auto normalizeUri(std::string_view path) -> std::string;
29
30 static auto makeBlob(const void* data, size_t size) -> ISlangBlob*;
31
36 class Recorder {
37 public:
38 Recorder();
39 ~Recorder();
40
41 Recorder(const Recorder&) = delete;
42 auto operator=(const Recorder&) -> Recorder& = delete;
43 Recorder(Recorder&&) = delete;
44 auto operator=(Recorder&&) -> Recorder& = delete;
45
46 [[nodiscard]]
47 auto resolved() const -> const std::vector<std::string>& {
48 return m_resolved;
49 }
50
51 private:
52 friend class SlangVfs;
53
54 void record(std::string uri);
55
56 std::vector<std::string> m_resolved;
57 };
58
59private:
60 static inline thread_local Recorder* s_recorder = nullptr;
61};
62
63}
Records every URI resolved while alive. Slang getDependencyFileCount() is empty for modules loaded fr...
Definition slang_vfs.hpp:36
Definition slang_vfs.hpp:14