Ejemplo n.º 1
0
 public void UpdateCustomGpuParameter(GpuProgramParameters.AutoConstantEntry entry, GpuProgramParameters gpuParams)
 {
     if (customParams[entry.data] != null)
     {
         gpuParams.SetConstant(entry.index, (Vector4)customParams[entry.data]);
     }
 }
Ejemplo n.º 2
0
 public void UpdateCustomGpuParameter(GpuProgramParameters.AutoConstantEntry entry, GpuProgramParameters gpuParams)
 {
     if (this.customParams[entry.Data] != null)
     {
         gpuParams.SetConstant(entry.PhysicalIndex, (Vector4)this.customParams[entry.Data]);
     }
 }
        public void SetConstantMatrix4()
        {
            float[] expected = new[] { (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(),
                                       (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(),
                                       (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(),
                                       (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom() };

            float[] actual = new float[16];

            GpuProgramParameters parameters = new GpuProgramParameters();

            //var floatLogical = new GpuLogicalBufferStruct();
            //parameters._setLogicalIndexes( floatLogical, new GpuLogicalBufferStruct() );
            parameters.SetConstant(0, new Matrix4(expected[0], expected[1], expected[2], expected[3],
                                                  expected[4], expected[5], expected[6], expected[7],
                                                  expected[8], expected[9], expected[10], expected[11],
                                                  expected[12], expected[13], expected[14], expected[15]));

            GpuProgramParameters.FloatConstantEntry fcEntry;
            for (int i = 0; i < 4; i++)
            {
                fcEntry = parameters.GetFloatConstant(i);
                Assert.IsTrue(fcEntry.isSet);

                fcEntry.val.CopyTo(actual, i * 4);
            }

            Assert.AreEqual(expected, actual);
        }
        public void SetConstantVector4()
        {
            float[] expected = new[] { (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom() };
            float[] actual;

            GpuProgramParameters parameters = new GpuProgramParameters();

            //var floatLogical = new GpuLogicalBufferStruct();
            //parameters._setLogicalIndexes( floatLogical, new GpuLogicalBufferStruct() );
            parameters.SetConstant(0, new Vector4(expected[0], expected[1], expected[2], expected[3]));

            Assert.IsTrue(parameters.GetFloatConstant(0).isSet);
            actual = parameters.GetFloatConstant(0).val;
            Assert.AreEqual(expected, actual);
        }
        public void SetConstantFloat()
        {
            float[] expected = new[] { (float)Utility.SymmetricRandom(), 0f, 0f, 0f };
            float   actual;

            GpuProgramParameters parameters = new GpuProgramParameters();

            //var floatLogical = new GpuLogicalBufferStruct();
            //parameters._setLogicalIndexes( floatLogical, new GpuLogicalBufferStruct() );
            parameters.SetConstant(0, expected[0]);

            Assert.IsTrue(parameters.GetFloatConstant(0) != 0);
            actual = parameters.GetFloatConstant(0);
            Assert.AreEqual(expected[0], actual);
        }
Ejemplo n.º 6
0
        public void UpdateCustomGpuParameter(GpuProgramParameters.AutoConstantEntry entry, GpuProgramParameters gpuParams)
        {
            if (entry.type == AutoConstants.AnimationParametric)
            {
                // Set up to 4 values, or up to limit of hardware animation entries
                // Pack into 4-element constants offset based on constant data index
                // If there are more than 4 entries, this will be called more than once
                Vector4 val = Vector4.Zero;

                int animIndex = entry.data * 4;
                for (int i = 0; i < 4 &&
                     animIndex < hardwareVertexAnimVertexData.HWAnimationDataList.Count;
                     ++i, ++animIndex)
                {
                    val[i] = hardwareVertexAnimVertexData.HWAnimationDataList[animIndex].Parametric;
                }
                // set the parametric morph value
                gpuParams.SetConstant(entry.index, val);
            }
            else if (customParams[entry.data] != null)
            {
                gpuParams.SetConstant(entry.index, (Vector4)customParams[entry.data]);
            }
        }
Ejemplo n.º 7
0
        protected void _updateParameter(GpuProgramParameters programParameters, String paramName, Object value,
                                        int sizeInBytes)
        {
            //programParameters.AutoAddParamName = true;
            var idx = programParameters.FindNamedConstantDefinition(paramName).LogicalIndex;

            if (value is Matrix4)
            {
                programParameters.SetConstant(idx, (Matrix4)value);
            }
            else if (value is ColorEx)
            {
                programParameters.SetConstant(idx, (ColorEx)value);
            }
            else if (value is Vector3)
            {
                programParameters.SetConstant(idx, ((Vector3)value));
            }
            else if (value is Vector4)
            {
                programParameters.SetConstant(idx, (Vector4)value);
            }
            else if (value is float[])
            {
                programParameters.SetConstant(idx, (float[])value);
            }
            else if (value is int[])
            {
                programParameters.SetConstant(idx, (int[])value);
            }
            else if (value is float)
            {
                programParameters.SetConstant(idx, new[]
                {
                    (float)value, 0.0f, 0.0f, 0.0f
                });
            }
            else
            {
                programParameters.SetConstant(idx, (float[])value);
            }
        }
        public void SetConstantFloatArray()
        {
            float[] expected = new[] { (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom() };
            float[] actual   = new float[4];

            GpuProgramParameters parameters = new GpuProgramParameters();

            //var floatLogical = new GpuLogicalBufferStruct();
            //parameters._setLogicalIndexes( floatLogical, new GpuLogicalBufferStruct() );
            parameters.SetConstant(0, expected);

            for (int i = 0; i < 4; i++)
            {
                float fcEntry = parameters.GetFloatConstant(i);
                Assert.IsTrue(fcEntry != 0);

                actual[i * 4] = fcEntry;
            }

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 9
0
        //-------------------------------------------------------------------------
        public void SetupTerrainMaterial()
        {
            if (string.IsNullOrEmpty(this.mCustomMaterialName))
            {
                // define our own material
                Options.terrainMaterial = (Material)MaterialManager.Instance.GetByName(TERRAIN_MATERIAL_NAME);
                // Make unique terrain material name
                string s = mName + "/Terrain";
                Options.terrainMaterial = (Material)MaterialManager.Instance.GetByName(s);
                if (null == Options.terrainMaterial)
                {
                    Options.terrainMaterial =
                        (Material)MaterialManager.Instance.Create(s, ResourceGroupManager.Instance.WorldResourceGroupName);
                }
                else
                {
                    Options.terrainMaterial.GetTechnique(0).GetPass(0).RemoveAllTextureUnitStates();
                }

                Pass pass = Options.terrainMaterial.GetTechnique(0).GetPass(0);

                if (this.mWorldTextureName != "")
                {
                    pass.CreateTextureUnitState(this.mWorldTextureName, 0);
                }
                if (this.mDetailTextureName != "")
                {
                    pass.CreateTextureUnitState(this.mDetailTextureName, 1);
                }

                Options.terrainMaterial.Lighting = Options.lit;

                if (Options.lodMorph && mPCZSM.TargetRenderSystem.Capabilities.HasCapability(Capabilities.VertexPrograms) &&
                    GpuProgramManager.Instance.GetByName("Terrain/VertexMorph") == null)
                {
                    // Create & assign LOD morphing vertex program
                    String syntax;
                    if (GpuProgramManager.Instance.IsSyntaxSupported("arbvp1"))
                    {
                        syntax = "arbvp1";
                    }
                    else
                    {
                        syntax = "vs_1_1";
                    }

                    // Get source, and take into account current fog mode
                    FogMode fm     = mPCZSM.FogMode;
                    string  source = new TerrainVertexProgram().getProgramSource(fm, syntax, false);

                    GpuProgram prog = GpuProgramManager.Instance.CreateProgramFromString("Terrain/VertexMorph",
                                                                                         ResourceGroupManager.Instance.
                                                                                         WorldResourceGroupName, source,
                                                                                         GpuProgramType.Vertex, syntax);

                    // Attach
                    pass.SetVertexProgram("Terrain/VertexMorph");

                    // Get params
                    GpuProgramParameters paras = pass.VertexProgramParameters;

                    // worldviewproj
                    paras.SetAutoConstant(0, GpuProgramParameters.AutoConstantType.WorldViewProjMatrix);
                    // morph factor
                    paras.SetAutoConstant(4, GpuProgramParameters.AutoConstantType.Custom, TerrainZoneRenderable.MORPH_CUSTOM_PARAM_ID);
                    // fog exp density(if relevant)
                    if (fm == FogMode.Exp || fm == FogMode.Exp2)
                    {
                        paras.SetConstant(5, new Vector3(mPCZSM.FogDensity, 0, 0));
                        // Override scene fog since otherwise it's applied twice
                        // Set to linear and we derive [0,1] fog value in the shader
                        pass.SetFog(true, FogMode.Linear, mPCZSM.FogColor, 0, 1, 0);
                    }

                    // Also set shadow receiver program
                    string source2 = new TerrainVertexProgram().getProgramSource(fm, syntax, true);

                    prog = GpuProgramManager.Instance.CreateProgramFromString("Terrain/VertexMorphShadowReceive",
                                                                              ResourceGroupManager.Instance.WorldResourceGroupName,
                                                                              source2, GpuProgramType.Vertex, syntax);
                    pass.SetShadowReceiverVertexProgram("Terrain/VertexMorphShadowReceive");
                    paras = pass.ShadowReceiverVertexProgramParameters;
                    // worldviewproj
                    paras.SetAutoConstant(0, GpuProgramParameters.AutoConstantType.WorldViewProjMatrix);
                    // world
                    paras.SetAutoConstant(4, GpuProgramParameters.AutoConstantType.WorldMatrix);
                    // texture view / proj
                    paras.SetAutoConstant(8, GpuProgramParameters.AutoConstantType.TextureViewProjMatrix);
                    // morph factor
                    paras.SetAutoConstant(12, GpuProgramParameters.AutoConstantType.Custom,
                                          TerrainZoneRenderable.MORPH_CUSTOM_PARAM_ID);


                    // Set param index
                    this.mLodMorphParamName  = "";
                    this.mLodMorphParamIndex = 4;
                }

                Options.terrainMaterial.Load();
            }
            else
            {
                // Custom material
                Options.terrainMaterial = (Material)MaterialManager.Instance.GetByName(this.mCustomMaterialName);
                Options.terrainMaterial.Load();
            }

            // now set up the linkage between vertex program and LOD morph param
            if (Options.lodMorph)
            {
                Technique t = Options.terrainMaterial.GetBestTechnique();
                for (ushort i = 0; i < t.PassCount; ++i)
                {
                    Pass p = t.GetPass(i);
                    if (p.HasVertexProgram)
                    {
                        // we have to assume vertex program includes LOD morph capability
                        GpuProgramParameters paras = p.VertexProgramParameters;
                        // Check to see if custom param is already there
                        //GpuProgramParameters::AutoConstantIterator aci = params->getAutoConstantIterator();
                        bool found = false;
                        foreach (GpuProgramParameters.AutoConstantEntry ace in paras.AutoConstantList)
                        {
                            if (ace.Type == GpuProgramParameters.AutoConstantType.Custom &&
                                ace.Data == TerrainZoneRenderable.MORPH_CUSTOM_PARAM_ID)
                            {
                                found = true;
                                break;
                            }
                        }
                        if (!found)
                        {
                            if (this.mLodMorphParamName != "")
                            {
                                paras.SetNamedAutoConstant(this.mLodMorphParamName, GpuProgramParameters.AutoConstantType.Custom,
                                                           TerrainZoneRenderable.MORPH_CUSTOM_PARAM_ID);
                            }
                            else
                            {
                                paras.SetAutoConstant(this.mLodMorphParamIndex, GpuProgramParameters.AutoConstantType.Custom,
                                                      TerrainZoneRenderable.MORPH_CUSTOM_PARAM_ID);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
            public static void TranslateProgramParameters(ScriptCompiler compiler, GpuProgramParameters parameters,
                                                          ObjectAbstractNode obj)
            {
                var animParametricsCount = 0;

                foreach (var i in obj.Children)
                {
                    if (!(i is PropertyAbstractNode))
                    {
                        continue;
                    }

                    var prop = (PropertyAbstractNode)i;
                    switch ((Keywords)prop.Id)
                    {
                        #region ID_SHARED_PARAMS_REF

                    case Keywords.ID_SHARED_PARAMS_REF:
                    {
                        if (prop.Values.Count != 1)
                        {
                            compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line,
                                              "shared_params_ref requires a single parameter");
                            continue;
                        }

                        var i0 = getNodeAt(prop.Values, 0);
                        if (!(i0 is AtomAbstractNode))
                        {
                            compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line,
                                              "shared parameter set name expected");
                            continue;
                        }
                        var atom0 = (AtomAbstractNode)i0;

                        try
                        {
                            parameters.AddSharedParameters(atom0.Value);
                        }
                        catch (AxiomException e)
                        {
                            compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line, e.Message);
                        }
                    }
                    break;

                        #endregion ID_SHARED_PARAMS_REF

                        #region ID_PARAM_INDEXED || ID_PARAM_NAMED

                    case Keywords.ID_PARAM_INDEXED:
                    case Keywords.ID_PARAM_NAMED:
                    {
                        if (prop.Values.Count >= 3)
                        {
                            var named = (prop.Id == (uint)Keywords.ID_PARAM_NAMED);
                            var i0    = getNodeAt(prop.Values, 0);
                            var i1    = getNodeAt(prop.Values, 1);
                            var k     = getNodeAt(prop.Values, 2);

                            if (!(i0 is AtomAbstractNode) || !(i1 is AtomAbstractNode))
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line,
                                                  "name or index and parameter type expected");
                                return;
                            }

                            var atom0 = (AtomAbstractNode)i0;
                            var atom1 = (AtomAbstractNode)i1;
                            if (!named && !atom0.IsNumber)
                            {
                                compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line, "parameter index expected");
                                return;
                            }

                            var name  = string.Empty;
                            var index = 0;
                            // Assign the name/index
                            if (named)
                            {
                                name = atom0.Value;
                            }
                            else
                            {
                                index = (int)atom0.Number;
                            }

                            // Determine the type
                            if (atom1.Value == "matrix4x4")
                            {
                                Matrix4 m;
                                if (getMatrix4(prop.Values, 2, out m))
                                {
                                    try
                                    {
                                        if (named)
                                        {
                                            parameters.SetNamedConstant(name, m);
                                        }
                                        else
                                        {
                                            parameters.SetConstant(index, m);
                                        }
                                    }
                                    catch
                                    {
                                        compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line,
                                                          "setting matrix4x4 parameter failed");
                                    }
                                }
                                else
                                {
                                    compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line, "incorrect matrix4x4 declaration");
                                }
                            }
                            else
                            {
                                // Find the number of parameters
                                var isValid = true;
                                var type    = GpuProgramParameters.ElementType.Real;
                                var count   = 0;
                                if (atom1.Value.Contains("float"))
                                {
                                    type = GpuProgramParameters.ElementType.Real;
                                    if (atom1.Value.Length >= 6)
                                    {
                                        count = int.Parse(atom1.Value.Substring(5));
                                    }
                                    else
                                    {
                                        count = 1;
                                    }
                                }
                                else if (atom1.Value.Contains("int"))
                                {
                                    type = GpuProgramParameters.ElementType.Int;
                                    if (atom1.Value.Length >= 4)
                                    {
                                        count = int.Parse(atom1.Value.Substring(3));
                                    }
                                    else
                                    {
                                        count = 1;
                                    }
                                }
                                else
                                {
                                    compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line,
                                                      "incorrect type specified; only variants of int and float allowed");
                                    isValid = false;
                                }

                                if (isValid)
                                {
                                    // First, clear out any offending auto constants
                                    if (named)
                                    {
                                        parameters.ClearNamedAutoConstant(name);
                                    }
                                    else
                                    {
                                        parameters.ClearAutoConstant(index);
                                    }

                                    var roundedCount = count % 4 != 0 ? count + 4 - (count % 4) : count;
                                    if (type == GpuProgramParameters.ElementType.Int)
                                    {
                                        var vals = new int[roundedCount];
                                        if (getInts(prop.Values, 2, out vals, roundedCount))
                                        {
                                            try
                                            {
                                                if (named)
                                                {
                                                    parameters.SetNamedConstant(name, vals, count, 1);
                                                }
                                                else
                                                {
                                                    parameters.SetConstant(index, vals, roundedCount / 4);
                                                }
                                            }
                                            catch
                                            {
                                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line, "setting of constant failed");
                                            }
                                        }
                                        else
                                        {
                                            compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line,
                                                              "incorrect integer constant declaration");
                                        }
                                    }
                                    else
                                    {
                                        var vals = new float[roundedCount];
                                        if (getFloats(prop.Values, 2, out vals, roundedCount))
                                        {
                                            try
                                            {
                                                if (named)
                                                {
                                                    parameters.SetNamedConstant(name, vals, count, 1);
                                                }
                                                else
                                                {
                                                    parameters.SetConstant(index, vals, roundedCount / 4);
                                                }
                                            }
                                            catch
                                            {
                                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line, "setting of constant failed");
                                            }
                                        }
                                        else
                                        {
                                            compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line,
                                                              "incorrect float constant declaration");
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line,
                                              "param_named and param_indexed properties requires at least 3 arguments");
                        }
                    }
                    break;

                        #endregion ID_PARAM_INDEXED || ID_PARAM_NAMED

                        #region ID_PARAM_INDEXED_AUTO || ID_PARAM_NAMED_AUTO

                    case Keywords.ID_PARAM_INDEXED_AUTO:
                    case Keywords.ID_PARAM_NAMED_AUTO:
                    {
                        var named = (prop.Id == (uint)Keywords.ID_PARAM_NAMED_AUTO);
                        var name  = string.Empty;
                        var index = 0;

                        if (prop.Values.Count >= 2)
                        {
                            var i0 = getNodeAt(prop.Values, 0);
                            var i1 = getNodeAt(prop.Values, 1);
                            var i2 = getNodeAt(prop.Values, 2);
                            var i3 = getNodeAt(prop.Values, 3);

                            if (!(i0 is AtomAbstractNode) || !(i1 is AtomAbstractNode))
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line,
                                                  "name or index and auto constant type expected");
                                return;
                            }
                            var atom0 = (AtomAbstractNode)i0;
                            var atom1 = (AtomAbstractNode)i1;

                            if (!named && !atom0.IsNumber)
                            {
                                compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line, "parameter index expected");
                                return;
                            }

                            if (named)
                            {
                                name = atom0.Value;
                            }
                            else
                            {
                                index = int.Parse(atom0.Value);
                            }

                            // Look up the auto constant
                            atom1.Value = atom1.Value.ToLower();

                            GpuProgramParameters.AutoConstantDefinition def;
                            var defFound = GpuProgramParameters.GetAutoConstantDefinition(atom1.Value, out def);

                            if (defFound)
                            {
                                switch (def.DataType)
                                {
                                    #region None

                                case GpuProgramParameters.AutoConstantDataType.None:
                                    // Set the auto constant
                                    try
                                    {
                                        if (named)
                                        {
                                            parameters.SetNamedAutoConstant(name, def.AutoConstantType);
                                        }
                                        else
                                        {
                                            parameters.SetAutoConstant(index, def.AutoConstantType);
                                        }
                                    }
                                    catch
                                    {
                                        compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line, "setting of constant failed");
                                    }
                                    break;

                                    #endregion None

                                    #region Int

                                case GpuProgramParameters.AutoConstantDataType.Int:
                                    if (def.AutoConstantType == GpuProgramParameters.AutoConstantType.AnimationParametric)
                                    {
                                        try
                                        {
                                            if (named)
                                            {
                                                parameters.SetNamedAutoConstant(name, def.AutoConstantType, animParametricsCount++);
                                            }
                                            else
                                            {
                                                parameters.SetAutoConstant(index, def.AutoConstantType, animParametricsCount++);
                                            }
                                        }
                                        catch
                                        {
                                            compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line, "setting of constant failed");
                                        }
                                    }
                                    else
                                    {
                                        // Only certain texture projection auto params will assume 0
                                        // Otherwise we will expect that 3rd parameter
                                        if (i2 == null)
                                        {
                                            if (def.AutoConstantType == GpuProgramParameters.AutoConstantType.TextureViewProjMatrix ||
                                                def.AutoConstantType == GpuProgramParameters.AutoConstantType.TextureWorldViewProjMatrix ||
                                                def.AutoConstantType == GpuProgramParameters.AutoConstantType.SpotLightViewProjMatrix ||
                                                def.AutoConstantType == GpuProgramParameters.AutoConstantType.SpotLightWorldViewProjMatrix)
                                            {
                                                try
                                                {
                                                    if (named)
                                                    {
                                                        parameters.SetNamedAutoConstant(name, def.AutoConstantType, 0);
                                                    }
                                                    else
                                                    {
                                                        parameters.SetAutoConstant(index, def.AutoConstantType, 0);
                                                    }
                                                }
                                                catch
                                                {
                                                    compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line, "setting of constant failed");
                                                }
                                            }
                                            else
                                            {
                                                compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line,
                                                                  "extra parameters required by constant definition " + atom1.Value);
                                            }
                                        }
                                        else
                                        {
                                            var success   = false;
                                            var extraInfo = 0;
                                            if (i3 == null)
                                            {
                                                // Handle only one extra value
                                                if (getInt(i2, out extraInfo))
                                                {
                                                    success = true;
                                                }
                                            }
                                            else
                                            {
                                                // Handle two extra values
                                                var extraInfo1 = 0;
                                                var extraInfo2 = 0;
                                                if (getInt(i2, out extraInfo1) && getInt(i3, out extraInfo2))
                                                {
                                                    extraInfo = extraInfo1 | (extraInfo2 << 16);
                                                    success   = true;
                                                }
                                            }

                                            if (success)
                                            {
                                                try
                                                {
                                                    if (named)
                                                    {
                                                        parameters.SetNamedAutoConstant(name, def.AutoConstantType, extraInfo);
                                                    }
                                                    else
                                                    {
                                                        parameters.SetAutoConstant(index, def.AutoConstantType, extraInfo);
                                                    }
                                                }
                                                catch
                                                {
                                                    compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line, "setting of constant failed");
                                                }
                                            }
                                            else
                                            {
                                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line,
                                                                  "invalid auto constant extra info parameter");
                                            }
                                        }
                                    }
                                    break;

                                    #endregion Int

                                    #region Real

                                case GpuProgramParameters.AutoConstantDataType.Real:
                                    if (def.AutoConstantType == GpuProgramParameters.AutoConstantType.Time ||
                                        def.AutoConstantType == GpuProgramParameters.AutoConstantType.FrameTime)
                                    {
                                        Real f = 1.0f;
                                        if (i2 != null)
                                        {
                                            getReal(i2, out f);
                                        }

                                        try
                                        {
                                            if (named)
                                            {
                                                parameters.SetNamedAutoConstantReal(name, def.AutoConstantType, f);
                                            }
                                            else
                                            {
                                                parameters.SetAutoConstantReal(index, def.AutoConstantType, f);
                                            }
                                        }
                                        catch
                                        {
                                            compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line, "setting of constant failed");
                                        }
                                    }
                                    else
                                    {
                                        if (i2 != null)
                                        {
                                            Real extraInfo = 0.0f;
                                            if (getReal(i2, out extraInfo))
                                            {
                                                try
                                                {
                                                    if (named)
                                                    {
                                                        parameters.SetNamedAutoConstantReal(name, def.AutoConstantType, extraInfo);
                                                    }
                                                    else
                                                    {
                                                        parameters.SetAutoConstantReal(index, def.AutoConstantType, extraInfo);
                                                    }
                                                }
                                                catch
                                                {
                                                    compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line, "setting of constant failed");
                                                }
                                            }
                                            else
                                            {
                                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line,
                                                                  "incorrect float argument definition in extra parameters");
                                            }
                                        }
                                        else
                                        {
                                            compiler.AddError(CompileErrorCode.NumberExpected, prop.File, prop.Line,
                                                              "extra parameters required by constant definition " + atom1.Value);
                                        }
                                    }
                                    break;

                                    #endregion Real
                                }
                            }
                            else
                            {
                                compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                            }
                        }
                        else
                        {
                            compiler.AddError(CompileErrorCode.InvalidParameters, prop.File, prop.Line);
                        }
                    }
                    break;

                        #endregion ID_PARAM_INDEXED_AUTO || ID_PARAM_NAMED_AUTO

                    default:
                        compiler.AddError(CompileErrorCode.UnexpectedToken, prop.File, prop.Line,
                                          "token \"" + prop.Name + "\" is not recognized");
                        break;
                    }
                }
            }