GetFloatConstant() public method

public GetFloatConstant ( int i ) : FloatConstantEntry
i int
return FloatConstantEntry
        public void SetConstantFloatArray()
        {
            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, expected );

            Assert.IsTrue( parameters.GetFloatConstant( 0 ).isSet );
            actual = parameters.GetFloatConstant( 0 ).val;
            Assert.AreEqual( expected, actual );
        }
        /// <summary>
        ///     Binds named parameters to fp30 programs.
        /// </summary>
        /// <param name="parms"></param>
        public override void BindParameters(GpuProgramParameters parms)
        {
            if(parms.HasFloatConstants) {
                for(int index = 0; index < parms.FloatConstantCount; index++) {
                    string name = parms.GetNameByIndex(index);

                    if(name != null) {
                        GpuProgramParameters.FloatConstantEntry entry = parms.GetFloatConstant(index);

                        // send the params 4 at a time
                        Gl.glProgramNamedParameter4fvNV(programId, name.Length, name, entry.val);
                    }
                }
            }
        }
        /// <summary>
        ///     Called to pass parameters to the Nvparse program.
        /// </summary>
        /// <param name="parms"></param>
        public override void BindParameters(GpuProgramParameters parms)
        {
            // Register combiners uses 2 constants per texture stage (0 and 1)
            // We have stored these as (stage * 2) + const_index
            if(parms.HasFloatConstants) {
                for(int index = 0; index < parms.FloatConstantCount; index++) {
                    GpuProgramParameters.FloatConstantEntry entry = parms.GetFloatConstant(index);

                    if(entry.isSet) {
                        int combinerStage = Gl.GL_COMBINER0_NV + (index / 2);
                        int pname = Gl.GL_CONSTANT_COLOR0_NV + (index % 2);

                        // send the params 4 at a time
                        Gl.glCombinerStageParameterfvNV(combinerStage, pname, entry.val);
                    }
                }
            }
        }
        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 );
        }
Esempio n. 5
0
        public override void BindGpuProgramParameters(GpuProgramType gptype, GpuProgramParameters parms, GpuProgramParameters.GpuParamVariability variability)
        {
            // special case pass iteration
            if (variability == GpuProgramParameters.GpuParamVariability.PassIterationNumber)
            {
                BindGpuProgramPassIterationParameters(gptype);
                return;
            }

            if ((variability & GpuProgramParameters.GpuParamVariability.Global) != 0)
            {
                // D3D9 doesn't support shared constant buffers, so use copy routine
                parms.CopySharedParams();
            }

            switch ( gptype )
            {
                case GpuProgramType.Vertex:
                    activeVertexGpuProgramParameters = parms;

                    if ( parms.HasFloatConstants )
                    {
                        for ( var index = 0; index < parms.FloatConstantCount; index++ )
                        {
                            var entry = parms.GetFloatConstant( index );

                            if ( entry.isSet )
                            {
                                ActiveD3D9Device.SetVertexShaderConstant(index, entry.val, 0, 1);
                            }
                        }
                    }
                    if (parms.HasIntConstants)
                    {
                        for (var index = 0; index < parms.IntConstantCount; index++)
                        {
                            var entry = parms.GetIntConstant(index);

                            if (entry.isSet)
                            {
                                ActiveD3D9Device.SetVertexShaderConstant(index, entry.val, 0, 1);
                            }
                        }
                    }

                    break;

                case GpuProgramType.Fragment:
                    activeFragmentGpuProgramParameters = parms;

                    if (parms.HasFloatConstants)
                    {
                        for (var index = 0; index < parms.FloatConstantCount; index++)
                        {
                            var entry = parms.GetFloatConstant(index);

                            if (entry.isSet)
                            {
                                ActiveD3D9Device.SetPixelShaderConstant(index, entry.val, 0, 1);
                            }
                        }
                    }
                    if ( parms.HasIntConstants )
                    {
                        for ( var index = 0; index < parms.IntConstantCount; index++ )
                        {
                            var entry = parms.GetIntConstant( index );

                            if ( entry.isSet )
                            {
                                ActiveD3D9Device.SetPixelShaderConstant(index, entry.val, 0, 1);
                            }
                        }
                    }

                    
                    break;
            }
        }
Esempio n. 6
0
        public override void BindProgramParameters(GpuProgramParameters parms, GpuProgramParameters.GpuParamVariability mask)
		{
			if ( !IsSupported )
				return;
			if ( parms.HasFloatConstants )
			{
				for ( int index = 0; index < parms.FloatConstantCount; index++ )
				{
					GpuProgramParameters.FloatConstantEntry entry = parms.GetFloatConstant( index );

					if ( entry.isSet )
					{
						// MONO: the 4fv version does not work
						float[] vals = entry.val;
						Gl.glProgramLocalParameter4fARB( programType, index, vals[ 0 ], vals[ 1 ], vals[ 2 ], vals[ 3 ] );
					}
				}
			}
		}
        /// <summary>
        ///     Binds params by index to the vp30 program.
        /// </summary>
        /// <param name="parms"></param>
        public override void BindParameters(GpuProgramParameters parms)
        {
            if(parms.HasFloatConstants) {
                for(int index = 0; index < parms.FloatConstantCount; index++) {
                    GpuProgramParameters.FloatConstantEntry entry = parms.GetFloatConstant(index);

                    if(entry.isSet) {
                        // send the params 4 at a time
                        Gl.glProgramParameter4fvNV(programType, index, entry.val);
                    }
                }
            }
        }
        public override void BindProgramParameters(GpuProgramParameters parms, GpuProgramParameters.GpuParamVariability mask)
		{
			// program constants done internally by compiler for local
			if ( parms.HasFloatConstants )
			{
				for ( int index = 0; index < parms.FloatConstantCount; index++ )
				{
					GpuProgramParameters.FloatConstantEntry entry = parms.GetFloatConstant( index );

					if ( entry.isSet )
					{
						// send the params 4 at a time
						Gl.glSetFragmentShaderConstantATI( Gl.GL_CON_0_ATI + index, entry.val );
					}
				}
			}
		}
Esempio n. 9
0
		/// <summary>
		///     Binds named parameters to fp30 programs.
		/// </summary>
		/// <param name="parms"></param>
        public override void BindProgramParameters(GpuProgramParameters parms, GpuProgramParameters.GpuParamVariability mask)
		{
			if ( parms.HasFloatConstants )
			{
				for ( int index = 0; index < parms.FloatConstantCount; index++ )
				{
					string name = parms.GetNameByIndex( index );

					if ( name != null )
					{
						GpuProgramParameters.FloatConstantEntry entry = parms.GetFloatConstant( index );

						// send the params 4 at a time
						Gl.glProgramNamedParameter4fvNV( programId, name.Length, System.Text.Encoding.ASCII.GetBytes( name ), entry.val ); // TAO 2.0
						//Gl.glProgramNamedParameter4fvNV( programId, name.Length, name, entry.val );
					}
				}
			}
		}