/// <summary> /// Compiles Shaders related to this effect. /// </summary> /// <param name="device"></param> /// <returns></returns> public static List <Shader> CompileAll(Device device, ShaderLibrary library) { List <Shader> shaders = new List <Shader>(); foreach (Program program in library.Programs) { Shader shader = new Shader(device); if (program.VertexShader != null) { foreach (Source source in from n in program.VertexShader.Includes from m in library.Sources where n.Source == m.ID select m) { shader.AppendVertexSource(source.Code); } } if (program.GeometryShader != null) { shader.InputTopology = program.GeometryShader.InputTopology; shader.OutputTopology = program.GeometryShader.OutputTopology; shader.OutputVertexCount = program.GeometryShader.OutputVertexCount; foreach (Source source in from n in program.GeometryShader.Includes from m in library.Sources where n.Source == m.ID select m) { shader.AppendGeometrySource(source.Code); } } if (program.FragmentShader != null) { foreach (Source source in from n in program.FragmentShader.Includes from m in library.Sources where n.Source == m.ID select m) { shader.AppendFragmentSource(source.Code); } } ShaderCompileResult compileResult = shader.Compile(); if (!compileResult.HasError) { shaders.Add(shader); } else { throw new Exception(compileResult.Summary); } } return(shaders); }
/// <summary> /// Compiles Shaders related to this effect. /// </summary> /// <param name="device"></param> /// <returns></returns> public static List<Shader> CompileAll(Device device, ShaderLibrary library) { List<Shader> shaders = new List<Shader>(); foreach (Program program in library.Programs) { Shader shader = new Shader(device); if (program.VertexShader != null) { foreach (Source source in from n in program.VertexShader.Includes from m in library.Sources where n.Source == m.ID select m) shader.AppendVertexSource(source.Code); } if (program.GeometryShader != null) { shader.InputTopology = program.GeometryShader.InputTopology; shader.OutputTopology = program.GeometryShader.OutputTopology; shader.OutputVertexCount = program.GeometryShader.OutputVertexCount; foreach (Source source in from n in program.GeometryShader.Includes from m in library.Sources where n.Source == m.ID select m) shader.AppendGeometrySource(source.Code); } if (program.FragmentShader != null) { foreach (Source source in from n in program.FragmentShader.Includes from m in library.Sources where n.Source == m.ID select m) shader.AppendFragmentSource(source.Code); } ShaderCompileResult compileResult = shader.Compile(); if (!compileResult.HasError) { shaders.Add(shader); } else { throw new Exception(compileResult.Summary); } } return shaders; }