Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
 /// <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;