@@ -77,31 +77,29 @@ static tcpp::TInputStreamUniquePtr getInputStreamInclude(
7777 std::vector<std::pair<uint32_t , std::string>>& includeStack
7878)
7979{
80- std::filesystem::path relDir ;
80+ std::filesystem::path requestingSourceDir ;
8181 #ifdef NBL_EMBED_BUILTIN_RESOURCES
8282 const bool reqFromBuiltin = nbl::builtin::hasPathPrefix (requestingSource) || spirv::builtin::hasPathPrefix (requestingSource);
8383 const bool reqBuiltin = nbl::builtin::hasPathPrefix (requestedSource) || spirv::builtin::hasPathPrefix (requestedSource);
84+ // While #includ'ing a builtin, one must specify its full path (starting with "nbl/builtin" or "/nbl/builtin").
85+ // This rule applies also while a builtin is #includ`ing another builtin.
86+ // While including a filesystem file it must be either absolute path (or relative to any search dir added to asset::iIncludeHandler; <>-type),
87+ // or path relative to executable's working directory (""-type).
8488 if (!reqFromBuiltin && !reqBuiltin)
85- {
86- // While #includ'ing a builtin, one must specify its full path (starting with "nbl/builtin" or "/nbl/builtin").
87- // This rule applies also while a builtin is #includ`ing another builtin.
88- // While including a filesystem file it must be either absolute path (or relative to any search dir added to asset::iIncludeHandler; <>-type),
89- // or path relative to executable's working directory (""-type).
90- relDir = std::filesystem::path (requestingSource).parent_path ();
91- }
9289 #else
9390 const bool reqBuiltin = false ;
9491 #endif // NBL_EMBED_BUILTIN_RESOURCES
95- std::filesystem::path name = isRelative ? (relDir / requestedSource) : (requestedSource );
92+ requestingSourceDir = system::path (requestingSource). parent_path ( );
9693
94+ system::path name = isRelative ? (requestingSourceDir / requestedSource) : (requestedSource);
9795 if (std::filesystem::exists (name) && !reqBuiltin)
9896 name = std::filesystem::absolute (name);
9997
10098 std::optional<std::string> result;
10199 if (isRelative)
102- result = inclFinder->getIncludeRelative (relDir , requestedSource);
100+ result = inclFinder->getIncludeRelative (requestingSourceDir , requestedSource);
103101 else // shaderc_include_type_standard
104- result = inclFinder->getIncludeStandard (relDir , requestedSource);
102+ result = inclFinder->getIncludeStandard (requestingSourceDir , requestedSource);
105103
106104 if (!result)
107105 {
0 commit comments