Beispiel #1
0
        /// <summary>
        ///     Binds named parameters to fp30 programs.
        /// </summary>
        /// <param name="parms"></param>
        public override void BindProgramParameters(GpuProgramParameters parms, GpuProgramParameters.GpuParamVariability mask)
        {
            throw new NotImplementedException();

            /*
             *          if ( parms.HasFloatConstants )
             *          {
             *                  for ( int index = 0; index < parms.FloatConstantCount; index++ )
             *                  {
             *                          string name = parms.GetNameByIndex( index );
             *
             *                          if ( name != null )
             *                          {
             *                                  using (var entry = parms.GetFloatPointer( index ))
             *                              {
             *
             *                                  // send the params 4 at a time
             *                                  throw new AxiomException( "Update this!" );
             *                                  Gl.glProgramNamedParameter4fvNV( programId, name.Length, System.Text.Encoding.ASCII.GetBytes( name ),
             *                                                                   entry.Pointer ); // TAO 2.0
             *                                  //Gl.glProgramNamedParameter4fvNV( programId, name.Length, name, entry.val );
             *                              }
             *                          }
             *                  }
             *          }
             */
        }
Beispiel #2
0
        /// <summary>
        /// </summary>
        /// <param name="type"> </param>
        /// <param name="index"> </param>
        /// <param name="variability"> default is .All </param>
        /// <param name="suggestedName"> </param>
        /// <param name="size"> Default is 0 </param>
        /// <returns> </returns>
        public UniformParameter ResolveParameter(Axiom.Graphics.GpuProgramParameters.GpuConstantType type, int index,
                                                 GpuProgramParameters.GpuParamVariability variability,
                                                 string suggestedName, int size)
        {
            UniformParameter param = null;

            if (index == -1)
            {
                index = 0;

                //find the next availalbe index of the target type
                for (int i = 0; i < this.parameters.Count; i++)
                {
                    if (this.parameters[i].Type == type && this.parameters[i].IsAutoConstantParameter == false)
                    {
                        index++;
                    }
                }
            }
            else
            {
                //Check if parameter already exits
                param = GetParameterByType(type, index);
                if (param != null)
                {
                    return(param);
                }
            }
            //Create new parameter.
            param = ParameterFactory.CreateUniform(type, index, (int)variability, suggestedName, size);
            AddParameter(param);

            return(param);
        }
Beispiel #3
0
        public override void BindProgramParameters(GpuProgramParameters parms, GpuProgramParameters.GpuParamVariability mask)
        {
            var type = programType;

            // only supports float constants
            var floatStruct = parms.FloatLogicalBufferStruct;

            foreach (var i in floatStruct.Map)
            {
                if ((i.Value.Variability & mask) != 0)
                {
                    var logicalIndex = i.Key;
                    var pFloat       = parms.GetFloatConstantList();
                    var ptr          = i.Value.PhysicalIndex;
                    {
                        for (var j = 0; j < i.Value.CurrentSize; j += 4)
                        {
                            var x = pFloat[ptr + j];
                            var y = pFloat[ptr + j + 1];
                            var z = pFloat[ptr + j + 2];
                            var w = pFloat[ptr + j + 3];
                            Gl.glProgramLocalParameter4fARB(type, logicalIndex, x, y, z, w);
                            ++logicalIndex;
                        }
                    }
                }
            }
        }
Beispiel #4
0
        public override void BindProgramParameters(GpuProgramParameters parms, GpuProgramParameters.GpuParamVariability mask)
        {
            // Register combiners uses 2 constants per texture stage (0 and 1)
            // We have stored these as (stage * 2) + const_index in the physical buffer
            // There are no other parameters in a register combiners shader
            var floatList = parms.GetFloatConstantList();
            var index     = 0;

            for (var i = 0; i < floatList.Length; ++i, ++index)
            {
                var combinerStage = Gl.GL_COMBINER0_NV + (index / 2);
                var pname         = Gl.GL_CONSTANT_COLOR0_NV + (index % 2);

                Gl.glCombinerStageParameterfvNV(combinerStage, pname, ref floatList[i]);
            }
        }
Beispiel #5
0
        public override void BindProgramParameters(GpuProgramParameters parms, GpuProgramParameters.GpuParamVariability mask)
        {
            try
            {
                // activate the link program object
                GLSLLinkProgram linkProgram = GLSLLinkProgramManager.Instance.ActiveLinkProgram;

                // pass on parameters from params to program object uniforms
                linkProgram.UpdateUniforms(parms, mask, Type);
            }
            catch (Exception e)
            {
                LogManager.Instance.Write("Remove this when validated");
                Debugger.Break();
            }
        }
Beispiel #6
0
 /// <summary>
 ///     Binds params by index to the vp30 program.
 /// </summary>
 /// <param name="parms"></param>
 public override void BindProgramParameters(GpuProgramParameters parms, GpuProgramParameters.GpuParamVariability mask)
 {
     //TODO
     //if ( parms.HasFloatConstants )
     //{
     //    for ( int index = 0; index < parms.FloatConstantCount; index++ )
     //    {
     //        using (var entry = parms.GetFloatPointer( index ))
     //        {
     //            // send the params 4 at a time
     //            throw new AxiomException( "Update this!" );
     //            Gl.glProgramParameter4fvNV( programType, index, entry.Pointer.Pin() );
     //            entry.Pointer.UnPin();
     //        }
     //    }
     //}
 }
        public override void BindProgramParameters(GpuProgramParameters parms, GpuProgramParameters.GpuParamVariability mask)
        {
            // only supports float constants
            var floatStruct = parms.FloatLogicalBufferStruct;

            foreach (var i in floatStruct.Map)
            {
                if ((i.Value.Variability & mask) != 0)
                {
                    var logicalIndex = i.Key;
                    var pFloat       = parms.GetFloatPointer(i.Value.PhysicalIndex).Pointer;
                    // Iterate over the params, set in 4-float chunks (low-level)
                    for (var j = 0; j < i.Value.CurrentSize; j += 4)
                    {
                        Gl.glSetFragmentShaderConstantATI(Gl.GL_CON_0_ATI + logicalIndex, pFloat.Pin());
                        pFloat.UnPin();
                        pFloat += 4;
                        ++logicalIndex;
                    }
                }
            }
        }
Beispiel #8
0
 public UniformParameter ResolveParameter(Axiom.Graphics.GpuProgramParameters.GpuConstantType type, int index,
                                          GpuProgramParameters.GpuParamVariability variability,
                                          string suggestedName)
 {
     return(ResolveParameter(type, index, variability, suggestedName, 0));
 }
Beispiel #9
0
        /// <summary>
        ///		Updates program object uniforms using data from GpuProgramParameters.
        ///		normally called by GLSLGpuProgram.BindParameters() just before rendering occurs.
        /// </summary>
        /// <param name="parameters">GPU Parameters to use to update the uniforms params.</param>
        public void UpdateUniforms(GpuProgramParameters parameters, GpuProgramParameters.GpuParamVariability mask,
                                   GpuProgramType fromProgType)
        {
            foreach (var currentUniform in this.uniformReferences)
            {
                // Only pull values from buffer it's supposed to be in (vertex or fragment)
                // This method will be called twice, once for vertex program params,
                // and once for fragment program params.
                if (fromProgType == currentUniform.SourceProgType)
                {
                    var def = currentUniform.ConstantDef;

                    if ((def.Variability & mask) != 0)
                    {
                        var glArraySize = def.ArraySize;

                        // get the index in the parameter real list
                        switch (def.ConstantType)
                        {
                        case GpuProgramParameters.GpuConstantType.Float1:
                            using (var ptr = parameters.GetFloatPointer(def.PhysicalIndex))
                            {
                                Gl.glUniform1fvARB(currentUniform.Location, glArraySize, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Float2:
                            using (var ptr = parameters.GetFloatPointer(def.PhysicalIndex))
                            {
                                Gl.glUniform2fvARB(currentUniform.Location, glArraySize, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Float3:
                            using (var ptr = parameters.GetFloatPointer(def.PhysicalIndex))
                            {
                                Gl.glUniform3fvARB(currentUniform.Location, glArraySize, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Float4:
                            using (var ptr = parameters.GetFloatPointer(def.PhysicalIndex))
                            {
                                Gl.glUniform4fvARB(currentUniform.Location, glArraySize, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Matrix_2X2:
                            using (var ptr = parameters.GetFloatPointer(def.PhysicalIndex))
                            {
                                Gl.glUniformMatrix2fvARB(currentUniform.Location, glArraySize, 1, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Matrix_2X3:
                            using (var ptr = parameters.GetFloatPointer(def.PhysicalIndex))
                            {
                                Gl.glUniformMatrix2x3fv(currentUniform.Location, glArraySize, 1, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Matrix_2X4:
                            using (var ptr = parameters.GetFloatPointer(def.PhysicalIndex))
                            {
                                Gl.glUniformMatrix2x4fv(currentUniform.Location, glArraySize, 1, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Matrix_3X2:
                            using (var ptr = parameters.GetFloatPointer(def.PhysicalIndex))
                            {
                                Gl.glUniformMatrix3x2fv(currentUniform.Location, glArraySize, 1, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Matrix_3X3:
                            using (var ptr = parameters.GetFloatPointer(def.PhysicalIndex))
                            {
                                Gl.glUniformMatrix3fv(currentUniform.Location, glArraySize, 1, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Matrix_3X4:
                            using (var ptr = parameters.GetFloatPointer(def.PhysicalIndex))
                            {
                                Gl.glUniformMatrix3x4fv(currentUniform.Location, glArraySize, 1, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Matrix_4X2:
                            using (var ptr = parameters.GetFloatPointer(def.PhysicalIndex))
                            {
                                Gl.glUniformMatrix4x2fv(currentUniform.Location, glArraySize, 1, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Matrix_4X3:
                            using (var ptr = parameters.GetFloatPointer(def.PhysicalIndex))
                            {
                                Gl.glUniformMatrix4x3fv(currentUniform.Location, glArraySize, 1, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Matrix_4X4:
                            using (var ptr = parameters.GetFloatPointer(def.PhysicalIndex))
                            {
                                Gl.glUniformMatrix4fv(currentUniform.Location, glArraySize, 1, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Int1:
                            using (var ptr = parameters.GetIntPointer(def.PhysicalIndex))
                            {
                                Gl.glUniform1ivARB(currentUniform.Location, glArraySize, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Int2:
                            using (var ptr = parameters.GetIntPointer(def.PhysicalIndex))
                            {
                                Gl.glUniform2ivARB(currentUniform.Location, glArraySize, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Int3:
                            using (var ptr = parameters.GetIntPointer(def.PhysicalIndex))
                            {
                                Gl.glUniform3ivARB(currentUniform.Location, glArraySize, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Int4:
                            using (var ptr = parameters.GetIntPointer(def.PhysicalIndex))
                            {
                                Gl.glUniform4ivARB(currentUniform.Location, glArraySize, ptr.Pointer.Pin());
                            }
                            break;

                        case GpuProgramParameters.GpuConstantType.Sampler1D:
                        case GpuProgramParameters.GpuConstantType.Sampler1DShadow:
                        case GpuProgramParameters.GpuConstantType.Sampler2D:
                        case GpuProgramParameters.GpuConstantType.Sampler2DShadow:
                        case GpuProgramParameters.GpuConstantType.Sampler3D:
                        case GpuProgramParameters.GpuConstantType.SamplerCube:
                            var value = parameters.GetIntConstant(def.PhysicalIndex);
                            Gl.glUniform1iARB(currentUniform.Location, value);
                            break;

                        case GpuProgramParameters.GpuConstantType.Unknown:
                            break;
                        } // end switch
                        GLSLHelper.CheckForGLSLError("GLSLLinkProgram::updateUniforms", 0);
                    }     // variability & mask
                }         // fromProgType == currentUniform->mSourceProgType
            }             // end for
        }
Beispiel #10
0
 public virtual void BindProgramParameters(GpuProgramParameters parms, GpuProgramParameters.GpuParamVariability mask)
 {
     // do nothing
 }