Ejemplo n.º 1
0
            private void Visit(ShaderBlock shaderBlock)
            {
                HasMixin = true;

                // Create a context associated with ShaderBlock
                currentContext = new ShaderBlockContext();
                shaderBlock.SetTag(BlockContextTag, currentContext);

                foreach (Statement statement in shaderBlock.Body.Statements)
                {
                    VisitDynamic(statement);
                }
                currentContext = null;
            }
Ejemplo n.º 2
0
        protected virtual void Visit(ShaderBlock shaderBlock)
        {
            WriteLinkLine(shaderBlock);
            currentBlock = shaderBlock;

            VariableAsParameterKey = false;

            // Clear ParameterKey and Mixin references
            parameterKeysReferenced.Clear();
            mixinsReferenced.Clear();

            // Use a single internal class for all shader mixins
            Write("internal static partial class ShaderMixins");
            {
                OpenBrace();
                Write("internal partial class");
                Write(" ");
                Write(shaderBlock.Name);
                WriteSpace();
                Write(" : IShaderMixinBuilder");
                {
                    OpenBrace();
                    // Generate the main generate method for each shader block
                    Write("public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)");
                    {
                        OpenBrace();
                        // Create a context associated with ShaderBlock
                        foreach (Statement statement in shaderBlock.Body.Statements)
                        {
                            VisitDynamic(statement);
                        }
                        CloseBrace();
                    }

                    WriteLine();
                    WriteLine("[ModuleInitializer]");
                    WriteLine("internal static void __Initialize__()");
                    {
                        OpenBrace();
                        Write("ShaderMixinManager.Register(\"").Write(shaderBlock.Name).Write("\", new ").Write(shaderBlock.Name).WriteLine("());");
                        CloseBrace();
                    }
                    CloseBrace();
                }
                CloseBrace();
            }
    
            VariableAsParameterKey = true;
            currentBlock = null;
        }