Esempio n. 1
0
        private void ParseTechnique(UnifiedShaderInfo info, List <UnifiedShaderToken> tokens)
        {
            var name = ConsumeToken(tokens);

            ExpectToken(name, UnifiedShaderTokenType.StringToken);
            ExpectToken(ConsumeToken(tokens), UnifiedShaderTokenType.OpenBrace);

            var technique = new TechniqueInfo
            {
                Name   = name.Text,
                Passes = new List <PassInfo>()
            };

            while (tokens[0].TokenType == UnifiedShaderTokenType.StringToken &&
                   tokens[0].Text == "pass")
            {
                var pass = new PassInfo();
                ExpectToken(ConsumeToken(tokens), "pass");
                var passName = ConsumeToken(tokens);
                ExpectToken(passName, UnifiedShaderTokenType.StringToken);
                pass.Name = passName.Text;
                ParsePass(pass, tokens);
                technique.Passes.Add(pass);
            }

            info.Techniques.Add(technique);

            ExpectToken(ConsumeToken(tokens), UnifiedShaderTokenType.CloseBrace);
        }
        private void ParseTechnique(UnifiedShaderInfo info, List<UnifiedShaderToken> tokens)
        {
            var name = ConsumeToken(tokens);
            ExpectToken(name, UnifiedShaderTokenType.StringToken);
            ExpectToken(ConsumeToken(tokens), UnifiedShaderTokenType.OpenBrace);

            var technique = new TechniqueInfo
            {
                Name = name.Text,
                Passes = new List<PassInfo>()
            };

            while (tokens[0].TokenType == UnifiedShaderTokenType.StringToken &&
                   tokens[0].Text == "pass")
            {
                var pass = new PassInfo();
                ExpectToken(ConsumeToken(tokens), "pass");
                var passName = ConsumeToken(tokens);
                ExpectToken(passName, UnifiedShaderTokenType.StringToken);
                pass.Name = passName.Text;
                ParsePass(pass, tokens);
                technique.Passes.Add(pass);
            }

            info.Techniques.Add(technique);

            ExpectToken(ConsumeToken(tokens), UnifiedShaderTokenType.CloseBrace);
        }
Esempio n. 3
0
        private void ParsePass(PassInfo pass, List <UnifiedShaderToken> tokens)
        {
            ExpectToken(ConsumeToken(tokens), UnifiedShaderTokenType.OpenBrace);

            while (tokens[0].TokenType == UnifiedShaderTokenType.StringToken)
            {
                var type = ConsumeToken(tokens);
                ExpectToken(type, UnifiedShaderTokenType.StringToken);

                switch (type.Text)
                {
                case "pixel":
                case "vertex":
                case "geometry":
                case "domain":
                case "hull":
                    var name = ConsumeToken(tokens);
                    ExpectToken(name, UnifiedShaderTokenType.StringToken);
                    ExpectToken(ConsumeToken(tokens), UnifiedShaderTokenType.Semicolon);
                    switch (type.Text)
                    {
                    case "pixel":
                        pass.PixelShaderName = name.Text;
                        break;

                    case "vertex":
                        pass.VertexShaderName = name.Text;
                        break;

                    case "geometry":
                        pass.GeometryShaderName = name.Text;
                        break;

                    case "domain":
                        pass.DomainShaderName = name.Text;
                        break;

                    case "hull":
                        pass.HullShaderName = name.Text;
                        break;
                    }
                    break;

                case "compute":
                    // TODO: This implementation is not complete.
                    break;

                case "blend":
                case "depth":
                case "raster":
                    // TODO: This implementation is not complete.
                    break;
                }
            }

            ExpectToken(ConsumeToken(tokens), UnifiedShaderTokenType.CloseBrace);
        }
        private void ParsePass(PassInfo pass, List<UnifiedShaderToken> tokens)
        {
            ExpectToken(ConsumeToken(tokens), UnifiedShaderTokenType.OpenBrace);

            while (tokens[0].TokenType == UnifiedShaderTokenType.StringToken)
            {
                var type = ConsumeToken(tokens);
                ExpectToken(type, UnifiedShaderTokenType.StringToken);

                switch (type.Text)
                {
                    case "pixel":
                    case "vertex":
                    case "geometry":
                    case "domain":
                    case "hull":
                        var name = ConsumeToken(tokens);
                        ExpectToken(name, UnifiedShaderTokenType.StringToken);
                        ExpectToken(ConsumeToken(tokens), UnifiedShaderTokenType.Semicolon);
                        switch (type.Text)
                        {
                            case "pixel":
                                pass.PixelShaderName = name.Text;
                                break;
                            case "vertex":
                                pass.VertexShaderName = name.Text;
                                break;
                            case "geometry":
                                pass.GeometryShaderName = name.Text;
                                break;
                            case "domain":
                                pass.DomainShaderName = name.Text;
                                break;
                            case "hull":
                                pass.HullShaderName = name.Text;
                                break;
                        }
                        break;
                    case "compute":
                        // TODO: This implementation is not complete.
                        break;
                    case "blend":
                    case "depth":
                    case "raster":
                        // TODO: This implementation is not complete.
                        break;
                }
            }

            ExpectToken(ConsumeToken(tokens), UnifiedShaderTokenType.CloseBrace);
        }