-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathCJITIncludeLoader.h
More file actions
62 lines (48 loc) · 1.91 KB
/
CJITIncludeLoader.h
File metadata and controls
62 lines (48 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef _NBL_VIDEO_C_JIT_INCLUDE_LOADER_H_INCLUDED_
#define _NBL_VIDEO_C_JIT_INCLUDE_LOADER_H_INCLUDED_
#include "nbl/asset/utils/IShaderCompiler.h"
#include "nbl/video/SPhysicalDeviceFeatures.h"
#include "nbl/video/SPhysicalDeviceLimits.h"
#include <string>
#include "nbl/builtin/hlsl/type_traits.hlsl"
namespace nbl::video
{
class NBL_API2 CJITIncludeLoader : public asset::IShaderCompiler::IIncludeLoader
{
public:
inline CJITIncludeLoader(const SPhysicalDeviceLimits& limits, const SPhysicalDeviceFeatures& features)
{
m_includes["nbl/builtin/hlsl/jit/device_capabilities.hlsl"] = collectDeviceCaps(limits,features);
}
found_t getInclude(const system::path& searchPath, const std::string& includeName, bool needHash = true) const override;
protected:
template<typename T>
struct to_string_impl
{
inline std::string operator()(const T& object) { return std::to_string(object); }
};
template<typename T> requires core::Bitflag<std::remove_cvref_t<T>>
struct to_string_impl<T>
{
inline std::string operator()(const T& object) {
return std::to_string(static_cast<int>(object.value));
}
};
template<typename T> requires is_scoped_enum<std::remove_cvref_t<T>>
struct to_string_impl<T>
{
inline std::string operator()(const T& object) {
return std::to_string(static_cast<int>(object));
}
};
private:
core::unordered_map<system::path,std::string> m_includes;
std::string collectDeviceCaps(const SPhysicalDeviceLimits& limits, const SPhysicalDeviceFeatures& features);
template<typename T>
static inline std::string to_string(T&& object)
{
return to_string_impl<T>()(std::forward<T>(object));
}
};
} //nbl::video
#endif // CJITINCLUDELOADER_H