public void MergeLibrary(ShadersLibrary shadersLibrary) { if (shadersLibrary == null) { throw new ArgumentNullException(nameof(shadersLibrary)); } if (shadersLibrary.Includes == null) { return; } foreach (ShadersLibrary.Include shaderLibraryInclude in shadersLibrary.Includes) { if (_IncludeFileSystem.ContainsKey(shaderLibraryInclude.Path)) { throw new InvalidOperationException(String.Format("include path '{0}' is duplicated", shaderLibraryInclude.Path)); } ShaderInclude shaderInclude; LinkResource(shaderInclude = new ShaderInclude(shaderLibraryInclude.Path)); shaderInclude.LoadSource(shaderLibraryInclude.Resource); _IncludeFileSystem.Add(shaderInclude.IncludePath, shaderInclude); } }
/// <summary> /// Construct a ShaderIncludeLibrary. /// </summary> public ShaderIncludeLibrary() { // Load all include files defined by ShadersLibrary foreach (ShadersLibrary.Include shaderLibraryInclude in ShadersLibrary.Instance.Includes) { if (_IncludeFileSystem.ContainsKey(shaderLibraryInclude.Id)) { throw new InvalidOperationException(String.Format("include path '{0}' is duplicated", shaderLibraryInclude.Id)); } ShaderInclude shaderInclude = new ShaderInclude(shaderLibraryInclude.Id); shaderInclude.LoadSource(shaderLibraryInclude.Path); shaderInclude.IncRef(); _IncludeFileSystem.Add(shaderInclude.IncludePath, shaderInclude); } }