44
55CJITIncludeLoader::CJITIncludeLoader ()
66{
7- m_includes[" device_capabilities.hlsl" ] = collectDeviceCaps ();
7+ m_includes[" nbl/builtin/hlsl/jit/ device_capabilities.hlsl" ] = collectDeviceCaps (limits, features );
88}
99
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
1111{
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;
1613
14+ if (searchPath == " nbl/builtin/hlsl/jit" )
15+ {
1716 // Look up the content in m_includes map
18- auto it = m_includes.find (includeFileName );
17+ auto it = m_includes.find (path );
1918 if (it != m_includes.end ())
2019 {
2120 // Return the content of the specified include file
2221 return it->second ;
2322 }
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 ;
3624 }
25+ return std::nullopt ;
3726}
3827
3928
40- std::string CJITIncludeLoader::collectDeviceCaps ()
29+ std::string CJITIncludeLoader::collectDeviceCaps (const SPhysicalDeviceLimits& limits, const SPhysicalDeviceFeatures& features )
4130{
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