private static bool CompileCode(LanguageBackend lang, string shaderPath, string entryPoint, ShaderFunctionType type, out string[] paths) { Type langType = lang.GetType(); if (langType == typeof(HlslBackend) && IsFxcAvailable()) { bool result = CompileHlsl(shaderPath, entryPoint, type, out string path); paths = new[] { path }; return(result); } else if (langType == typeof(Glsl450Backend) && IsGlslangValidatorAvailable()) { bool result = CompileSpirv(shaderPath, entryPoint, type, out string path); paths = new[] { path }; return(result); } else if (langType == typeof(MetalBackend) && AreMetalMacOSToolsAvailable()) { bool macOSresult = CompileMetal(shaderPath, true, out string pathMacOS); bool iosResult = CompileMetal(shaderPath, false, out string pathiOS); paths = new[] { pathMacOS, pathiOS }; return(macOSresult && iosResult); } else { paths = Array.Empty <string>(); return(false); } }
private static string BackendExtension(LanguageBackend lang) { if (lang.GetType() == typeof(HlslBackend)) { return("hlsl"); } else if (lang.GetType() == typeof(Glsl330Backend)) { return("330.glsl"); } else if (lang.GetType() == typeof(Glsl450Backend)) { return("450.glsl"); } throw new InvalidOperationException("Invalid backend type: " + lang.GetType().Name); }
private static bool CompileCode(LanguageBackend lang, string shaderPath, string entryPoint, ShaderFunctionType type, out string path) { Type langType = lang.GetType(); if (langType == typeof(HlslBackend) && IsFxcAvailable()) { return(CompileHlsl(shaderPath, entryPoint, type, out path)); } else if (langType == typeof(Glsl450Backend) && IsGlslangValidatorAvailable()) { return(CompileSpirv(shaderPath, entryPoint, type, out path)); } else { path = null; return(false); } }
/// <summary> /// Gets the <see cref="ToolChain" /> for the specified backend. /// </summary> /// <param name="backend">The backend.</param> /// <returns> /// A <see cref="ToolChain" /> if available; otherwise <see langword="null" />. /// </returns> public static ToolChain Get(LanguageBackend backend) => backend != null?Get(backend.GetType()) : null;