Пример #1
0
		protected virtual Func<ParseNode> GetBlockParseMethod(IdentifierToken blockName)
		{
			switch (blockName.Identifier)
			{
				case "headercode":
					return () => ParseHeaderCodeBlock();
				default:
					return () => ParseParameterBlock(blockName);
			}
		}
Пример #2
0
		protected override Func<ParseNode> GetBlockParseMethod(IdentifierToken blockName)
		{
			switch (blockName.Identifier)
			{
				case "vs":
				case "ps":
					return () => ParseShaderCodeBlock(blockName);
				default:
					return base.GetBlockParseMethod(blockName);
			}
		}
Пример #3
0
		protected override Func<ParseNode> GetBlockParseMethod(IdentifierToken blockName)
		{
			switch (blockName.Identifier)
			{
				case "techniques":
					return () => ParseTechniqueBlock();
				case "fragments":
					return () => ParseFragmentsBlock();
				default:
					return base.GetBlockParseMethod(blockName);
			}
		}
Пример #4
0
		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();
			}
		}
Пример #5
0
		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
			};
		}
Пример #6
0
		protected abstract ParameterBlockType GetParameterBlockType(IdentifierToken blockName);
Пример #7
0
		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
			};
		}
Пример #8
0
		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();
			}
		}
Пример #9
0
		private static ShaderType GetShaderType(IdentifierToken blockName)
		{
			switch (blockName.Identifier)
			{
				case "vs":
					return ShaderType.VertexShader;
				case "ps" :
					return ShaderType.PixelShader;
				default :
					throw new NotSupportedException();
			}
		}
Пример #10
0
		protected override ParameterBlockType GetParameterBlockType(IdentifierToken blockName)
		{
			ReportError(Resources.StitchedEffectParserParameterBlockTypeExpected, blockName.Identifier);
			throw new NotSupportedException();
		}