public ShaderSetProcessorInput( string name, ShaderFunction vertexFunction, ShaderFunction fragmentFunction, ShaderModel model) { SetName = name; VertexFunction = vertexFunction; FragmentFunction = fragmentFunction; Model = model; }
private void GenerateShaders(ShaderSetInfo ss, ShaderGenerationResult result) { TypeAndMethodName vertexFunctionName = ss.VertexShader; TypeAndMethodName fragmentFunctionName = ss.FragmentShader; HashSet <SyntaxTree> treesToVisit = new HashSet <SyntaxTree>(); if (vertexFunctionName != null) { GetTrees(treesToVisit, vertexFunctionName.TypeName); } if (fragmentFunctionName != null) { GetTrees(treesToVisit, fragmentFunctionName.TypeName); } foreach (LanguageBackend language in _languages) { language.InitContext(ss.Name); } ShaderSyntaxWalker walker = new ShaderSyntaxWalker(_compilation, _languages.ToArray(), ss); foreach (SyntaxTree tree in treesToVisit) { walker.Visit(tree.GetRoot()); } foreach (LanguageBackend language in _languages) { ShaderModel model = language.GetShaderModel(ss.Name); ShaderFunction vsFunc = (ss.VertexShader != null) ? model.GetFunction(ss.VertexShader.FullName) : null; ShaderFunction fsFunc = (ss.FragmentShader != null) ? model.GetFunction(ss.FragmentShader.FullName) : null; { string vsCode = null; string fsCode = null; if (vsFunc != null) { vsCode = language.GetCode(ss.Name, vsFunc); } if (fsFunc != null) { fsCode = language.GetCode(ss.Name, fsFunc); } result.AddShaderSet(language, new GeneratedShaderSet(ss.Name, vsCode, fsCode, vsFunc, fsFunc, model)); } } }
public GeneratedShaderSet( string name, string vsCode, string fsCode, ShaderFunction vertexfunction, ShaderFunction fragmentFunction, ShaderModel model) { if (string.IsNullOrEmpty(vsCode) && string.IsNullOrEmpty(fsCode)) { throw new ShaderGenerationException("At least one of vsCode or fsCode must be non-empty"); } Name = name; VertexShaderCode = vsCode; FragmentShaderCode = fsCode; VertexFunction = vertexfunction; FragmentFunction = fragmentFunction; Model = model; }