#pragma once #include #include #include #ifndef _WIN32 #include #else #include #endif #include template using RefCountPtr = nvrhi::RefCountPtr; enum class MaterialRenderPass : int { Deferred, Forward, CubeMap, Count }; enum class ShaderPlatform { D3D12, Vulkan }; class MaShaderCompiler { public: int Run(); std::filesystem::path m_project_path; std::filesystem::path m_output_path; private: // Stored in the native format, since DXC does not accept forward // slashes in UNC paths. Use wstring() to retrieve it in native // format or generic_wstring() to get the canonical forward slash // format. std::filesystem::path m_shader_path; bool m_generate_debug = false; void ParseOptions(); void Init(); YAML::Binary CompileShaderToBlob( std::filesystem::path file_name, std::wstring entry_name, std::vector> defines, std::string target, ShaderPlatform platform); bool CompileUtilityShader(YAML::Node& dest, const YAML::Node& src, const YAML::Node& templates, ShaderPlatform platform); bool CompileMaterial(YAML::Node& dest, const YAML::Node& src, const YAML::Node& templates, ShaderPlatform platform); bool CompileProject(YAML::Node& dest, const YAML::Node& src, const YAML::Node& templates, ShaderPlatform platform); RefCountPtr m_dxc_utils; RefCountPtr m_dxc_compiler; RefCountPtr m_dxc_include_handler; };