public static HeaderInfo FromString(string str) { HeaderInfo header; header.Name = ReadTagFromHeader("Name", str); header.EntryPoint = ReadTagFromHeader("EntryPoint", str, "main"); header.Type = EnumUtils.FromDescription <ShaderType>(ReadTagFromHeader("Type", str, "ps")); header.Defines = new List <string>(); string defines = ReadTagFromHeader("Defines", str, ""); foreach (string define in defines.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries)) { header.Defines.Add(define); } return(header); }
private static void FillConfig() { string[] separators = { "," }; // Shaders extensions Config.ShaderExtensions = new List <string>(); foreach (string extension in Data["ShaderCompiler"]["ShaderExtensions"].Split(separators, StringSplitOptions.RemoveEmptyEntries)) { Config.ShaderExtensions.Add(extension.Trim()); } // Ignored folders Config.IgnoredFolders = new List <string>(); foreach (string folder in Data["ShaderCompiler"]["IgnoredFolders"].Split(separators, StringSplitOptions.RemoveEmptyEntries)) { Config.IgnoredFolders.Add(ResolvePath(folder.Trim(), false)); } Config.ShaderSourcePath = ResolvePath(Data["ShaderCompiler"]["ShaderSourcePath"], true); Config.ShaderHFile = ResolvePath(Data["ShaderCompiler"]["ShaderHFile"], true); Config.ConstantBufferHFile = ResolvePath(Data["ShaderCompiler"]["ConstantBufferHFile"], true); Config.VertexLayoutHFile = ResolvePath(Data["ShaderCompiler"]["VertexLayoutHFile"], true); Config.DatabasePath = ResolvePath(Data["ShaderCompiler"]["DatabasePath"], false); Config.GeneratedFolderPath = ResolvePath(Data["ShaderCompiler"]["GeneratedFolderPath"], false); Config.GeneratedHeaderExtension = Data["ShaderCompiler"]["GeneratedHeaderExtension"]; // RecursiveSearch bool succes = Boolean.TryParse(Data["ShaderCompiler"]["RecursiveSearch"], out Config.RecursiveSearch); if (!succes) { Config.RecursiveSearch = false; } // EnableDebugInformation succes = Boolean.TryParse(Data["ShaderCompiler"]["EnableDebugInformation"], out Config.EnableDebugInformation); if (!succes) { Config.EnableDebugInformation = false; } // Weird setup, this is to make code smaller string currentKey = ""; try { currentKey = "Compiler"; Config.Compiler = EnumUtils.FromDescription <Compiler>(Data["ShaderCompiler"][currentKey]); currentKey = "ShaderModel"; Config.ShaderModel = EnumUtils.FromDescription <ShaderModel>(Data["ShaderCompiler"][currentKey]); } catch (EnumException e) { throw new Exception(e.Message + " when parsing config file. Key=" + currentKey); } Config.GlobalDefines = new List <string>(); foreach (string define in Data["ShaderCompiler"]["GlobalDefines"].Split(separators, StringSplitOptions.RemoveEmptyEntries)) { Config.GlobalDefines.Add(define.Trim()); } Config.Verify(throws: true); }