protected virtual Func<ParseNode> GetBlockParseMethod(IdentifierToken blockName) { switch (blockName.Identifier) { case "headercode": return () => ParseHeaderCodeBlock(); default: return () => ParseParameterBlock(blockName); } }
protected override Func<ParseNode> GetBlockParseMethod(IdentifierToken blockName) { switch (blockName.Identifier) { case "vs": case "ps": return () => ParseShaderCodeBlock(blockName); default: return base.GetBlockParseMethod(blockName); } }
protected override Func<ParseNode> GetBlockParseMethod(IdentifierToken blockName) { switch (blockName.Identifier) { case "techniques": return () => ParseTechniqueBlock(); case "fragments": return () => ParseFragmentsBlock(); default: return base.GetBlockParseMethod(blockName); } }
protected override ParameterBlockType GetParameterBlockType(IdentifierToken blockName) { switch (blockName.Identifier) { case "interpolators": return ParameterBlockType.Interpolators; case "parameters": case "params": return ParameterBlockType.Parameters; case "textures": return ParameterBlockType.Textures; case "vertexattributes": case "vertex": return ParameterBlockType.VertexAttributes; case "pixeloutputs": return ParameterBlockType.PixelOutputs; default: ReportError(Resources.FragmentParserParameterBlockTypeExpected, blockName.Identifier); throw new NotSupportedException(); } }
protected CodeBlockNodeBase ParseShaderCodeBlock(IdentifierToken blockName) { ShaderType shaderType = GetShaderType(blockName); // Shader profile is optional. ShaderProfile? shaderProfile = null; if (PeekType() == TokenType.Identifier) { IdentifierToken version = (IdentifierToken) Eat(TokenType.Identifier); shaderProfile = GetShaderProfile(version); } Eat(TokenType.CloseSquare); ShaderCodeToken shaderCode = (ShaderCodeToken) Eat(TokenType.ShaderCode); return new ShaderCodeBlockNode { ShaderType = shaderType, ShaderProfile = shaderProfile, Code = shaderCode.ShaderCode }; }
protected abstract ParameterBlockType GetParameterBlockType(IdentifierToken blockName);
protected ParameterBlockNode ParseParameterBlock(IdentifierToken blockName) { Eat(TokenType.CloseSquare); ParameterBlockType blockType = GetParameterBlockType(blockName); bool allowInitialValue = (blockType == ParameterBlockType.Parameters); List<VariableDeclarationNode> variableDeclarations = ParseVariableDeclarations(allowInitialValue, false, true, true, null); return new ParameterBlockNode { Type = blockType, VariableDeclarations = variableDeclarations }; }
private ShaderProfile GetShaderProfile(IdentifierToken model) { switch (model.Identifier) { case "2_0": return ShaderProfile.Version2_0; case "3_0": return ShaderProfile.Version3_0; default: ReportError(Resources.ParserShaderProfileNotSupported, model.Identifier); throw new NotSupportedException(); } }
private static ShaderType GetShaderType(IdentifierToken blockName) { switch (blockName.Identifier) { case "vs": return ShaderType.VertexShader; case "ps" : return ShaderType.PixelShader; default : throw new NotSupportedException(); } }
protected override ParameterBlockType GetParameterBlockType(IdentifierToken blockName) { ReportError(Resources.StitchedEffectParserParameterBlockTypeExpected, blockName.Identifier); throw new NotSupportedException(); }