MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ resolve_shader_path()

std::optional< std::filesystem::path > MayaFlux::Portal::Graphics::ShaderFoundry::resolve_shader_path ( const std::string &  filepath) const
private

Definition at line 466 of file ShaderFoundry.cpp.

467{
468 namespace fs = std::filesystem;
469
470 fs::path path(filepath);
471 std::error_code ec;
472
473 if (path.is_absolute() || fs::exists(path, ec)) {
474 return path;
475 }
476
477 std::vector<std::string> user_paths;
478
479#ifdef MAYAFLUX_PROJECT_SHADER_DIR
480 user_paths.emplace_back(MAYAFLUX_PROJECT_SHADER_DIR);
481#endif
482
483 user_paths.insert(user_paths.end(),
484 { "./shaders", "./data/shaders", "../shaders", "../data/shaders", "data/shaders" });
485
486 if (std::string_view(Config::SHADER_EXAMPLE_DIR).length() > 0) {
487 user_paths.emplace_back(Config::SHADER_EXAMPLE_DIR);
488 }
489
490 const std::vector<std::string> library_paths = {
491 Config::SHADER_BUILD_OUTPUT_DIR,
492 Config::SHADER_INSTALL_DIR,
493 Config::SHADER_SOURCE_DIR
494 };
495
496 for (const auto& search_path : user_paths) {
497 fs::path full_path = fs::path(search_path) / filepath;
498 if (!fs::exists(full_path, ec)) {
499 continue;
500 }
501
502 for (const auto& library_path : library_paths) {
503 fs::path shadowed = fs::path(library_path) / filepath;
504 if (fs::exists(shadowed, ec) && !fs::equivalent(full_path, shadowed, ec)) {
506 "Shader '{}' at '{}' shadows library shader '{}'",
507 filepath, full_path.string(), shadowed.string());
508 break;
509 }
510 }
511 return full_path;
512 }
513
514 for (const auto& search_path : library_paths) {
515 fs::path full_path = fs::path(search_path) / filepath;
516 if (fs::exists(full_path, ec)) {
517 return full_path;
518 }
519 }
520
521 return std::nullopt;
522}
#define MF_WARN(comp, ctx,...)
uint64_t length
Definition Composite.cpp:11
@ ShaderCompilation
Shader compilation tasks (Portal::Graphics::ShaderCompiler)
@ Portal
High-level user-facing API layer.

References length, MF_WARN, MayaFlux::Journal::Portal, and MayaFlux::Journal::ShaderCompilation.

Referenced by detect_source_type().

+ Here is the caller graph for this function: