4
4
5
5
CJITIncludeLoader::CJITIncludeLoader ()
6
6
{
7
- m_includes[" device_capabilities.hlsl" ] = collectDeviceCaps ();
7
+ m_includes[" nbl/builtin/hlsl/jit/ device_capabilities.hlsl" ] = collectDeviceCaps (limits, features );
8
8
}
9
9
10
- std::string CJITIncludeLoader::loadInclude (const std::string path)
10
+ std::optional<std:: string> CJITIncludeLoader::getInclude (const system::path& searchPath, const std::string& includeName) const
11
11
{
12
- const std::string prefix = " nbl/builtin/hlsl/jit/" ;
13
- if (path.compare (0 , prefix.size (), prefix) == 0 )
14
- {
15
- std::string includeFileName = path.substr (prefix.size ());
12
+ system::path path = searchPath / includeName;
16
13
14
+ if (searchPath == " nbl/builtin/hlsl/jit" )
15
+ {
17
16
// Look up the content in m_includes map
18
- auto it = m_includes.find (includeFileName );
17
+ auto it = m_includes.find (path );
19
18
if (it != m_includes.end ())
20
19
{
21
20
// Return the content of the specified include file
22
21
return it->second ;
23
22
}
24
- else
25
- {
26
- // Handle error: include file not found
27
- std::cerr << " Error: Include file '" << path << " ' not found!" << std::endl;
28
- return " " ;
29
- }
30
- }
31
- else
32
- {
33
- // Handle error: invalid include path
34
- std::cerr << " Error: Invalid include path '" << path << " '!" << std::endl;
35
- return " " ;
23
+ return std::nullopt;
36
24
}
25
+ return std::nullopt;
37
26
}
38
27
39
28
40
- std::string CJITIncludeLoader::collectDeviceCaps ()
29
+ std::string CJITIncludeLoader::collectDeviceCaps (const SPhysicalDeviceLimits& limits, const SPhysicalDeviceFeatures& features )
41
30
{
42
- std::ostringstream content;
43
- content << " #ifndef _NBL_BUILTIN_HLSL_JIT_DEVICE_CAPABILITIES_INCLUDED_" << std::endl;
44
- content << " #define _NBL_BUILTIN_HLSL_JIT_DEVICE_CAPABILITIES_INCLUDED_" << std::endl;
45
- content << " namespace nbl {" << std::endl;
46
- content << " namespace hlsl {" << std::endl;
47
- content << " namespace jit {" << std::endl;
48
- content << " struct device_capabilities {" << std::endl;
49
- content << " NBL_CONSTEXPR_STATIC_INLINE bool shaderFloat64 = false" << std::endl;
50
- content << " NBL_CONSTEXPR_STATIC_INLINE bool shaderDrawParameters = false" << std::endl;
51
- content << " NBL_CONSTEXPR_STATIC_INLINE bool subgroupArithmetic = false" << std::endl;
52
- content << " NBL_CONSTEXPR_STATIC_INLINE bool fragmentShaderPixelInterlock = false" << std::endl;
53
- content << std::endl;
54
- content << " NBL_CONSTEXPR_STATIC_INLINE uint16_t maxOptimallyResidentWorkgroupInvocations = 0" << std::endl;
55
- content << " };" << std::endl;
56
- content << " }" << std::endl;
57
- content << " }" << std::endl;
58
- content << " #endif" << std::endl;
59
-
60
- return content.str ();
61
- }
31
+ return R"===(
32
+ #ifndef _NBL_BUILTIN_HLSL_JIT_DEVICE_CAPABILITIES_INCLUDED_
33
+ #define _NBL_BUILTIN_HLSL_JIT_DEVICE_CAPABILITIES_INCLUDED_
34
+
35
+ namespace nbl
36
+ {
37
+ namespace hlsl
38
+ {
39
+ namespace jit
40
+ {
41
+ struct device_capabilities
42
+ {
43
+ NBL_CONSTEXPR_STATIC_INLINE bool shaderFloat64 = )===" + std::to_string (features.shaderFloat64 ) + R"===( ;
44
+ NBL_CONSTEXPR_STATIC_INLINE bool shaderDrawParameters = )===" + std::to_string (features.shaderDrawParameters ) + R"===( ;
45
+ NBL_CONSTEXPR_STATIC_INLINE bool subgroupArithmetic = )===" + std::to_string (limits.shaderSubgroupArithmetic ) + R"===( ;
46
+ NBL_CONSTEXPR_STATIC_INLINE bool fragmentShaderPixelInterlock = )===" + std::to_string (features.fragmentShaderPixelInterlock ) + R"===( ;
47
+
48
+ NBL_CONSTEXPR_STATIC_INLINE uint16_t maxOptimallyResidentWorkgroupInvocations = )===" + std::to_string (limits.maxOptimallyResidentWorkgroupInvocations ) + R"===( ;
49
+ };
50
+ }
51
+ }
52
+ }
53
+
54
+ #endif // _NBL_BUILTIN_HLSL_JIT_DEVICE_CAPABILITIES_INCLUDED_
55
+ )===" ;
56
+ }
0 commit comments