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);
        }
        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 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. 4
0
        /// <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 BindParameters(GpuProgramParameters parms)
        {
            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]);
                    }
                }
            }
        }
        public override void BindParameters(GpuProgramParameters parms)
        {
            // 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. 7
0
        /// <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);
                    }
                }
            }
        }
        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);
        }
        /// <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);
                    }
                }
            }
        }