public void GenerateConstantDefinitionArrayEntries( String paramName, GpuConstantDefinition baseDef )
			{
				// Copy definition for use with arrays
				var arrayDef = baseDef.Clone();
				arrayDef.ArraySize = 1;

				// Add parameters for array accessors
				// [0] will refer to the same location, [1+] will increment
				// only populate others individually up to 16 array slots so as not to get out of hand,
				// unless the system has been explicitly configured to allow all the parameters to be added

				// paramName[0] version will always exist
				var maxArrayIndex = 1;
				if ( baseDef.ArraySize <= 16 || GenerateAllConstantDefinitionArrayEntries )
				{
					maxArrayIndex = baseDef.ArraySize;
				}

				for ( var i = 0; i < maxArrayIndex; i++ )
				{
					var arrayName = string.Format( "{0}[{1}]", paramName, i );
					this.Map.Add( arrayName.ToLower(), arrayDef );
					// increment location
					arrayDef.PhysicalIndex += arrayDef.ElementSize;
				}
				// note no increment of buffer sizes since this is shared with main array def
			}
            public void GenerateConstantDefinitionArrayEntries(String paramName, GpuConstantDefinition baseDef)
            {
                // Copy definition for use with arrays
                var arrayDef = baseDef.Clone();

                arrayDef.ArraySize = 1;

                // Add parameters for array accessors
                // [0] will refer to the same location, [1+] will increment
                // only populate others individually up to 16 array slots so as not to get out of hand,
                // unless the system has been explicitly configured to allow all the parameters to be added

                // paramName[0] version will always exist
                var maxArrayIndex = 1;

                if (baseDef.ArraySize <= 16 || GenerateAllConstantDefinitionArrayEntries)
                {
                    maxArrayIndex = baseDef.ArraySize;
                }

                for (var i = 0; i < maxArrayIndex; i++)
                {
                    var arrayName = string.Format("{0}[{1}]", paramName, i);
                    this.Map.Add(arrayName.ToLower(), arrayDef);
                    // increment location
                    arrayDef.PhysicalIndex += arrayDef.ElementSize;
                }
                // note no increment of buffer sizes since this is shared with main array def
            }
            public void AddConstantDefinition(string name, GpuConstantType constType, int arrraySize)
            {
                if (this.NamedConstants.Map.ContainsKey(name))
                {
                    throw new Exception(string.Format("Constant entry with name '{0}' allready exists.", name));
                }

                var def = new GpuConstantDefinition
                {
                    ArraySize    = arrraySize,
                    ConstantType = constType,
                    // for compatibility we do not pad values to multiples of 4
                    // when it comes to arrays, user is responsible for creating matching defs
                    ElementSize = GpuConstantDefinition.GetElementSize(constType, false),
                    // not used
                    LogicalIndex = 0,
                    Variability  = GpuParamVariability.Global
                };

                if (def.IsFloat)
                {
                    def.PhysicalIndex = this.FloatConstants.Count;
                    this.FloatConstants.Resize(this.FloatConstants.Count + def.ArraySize * def.ElementSize);
                }
                else
                {
                    def.PhysicalIndex = this.IntConstants.Count;
                    this.IntConstants.Resize(this.IntConstants.Count + def.ArraySize * def.ElementSize);
                }
                this.NamedConstants.Map.Add(name, def);

                ++Version;
            }
Exemplo n.º 4
0
 public void generateConstantDefinitionArrayEntries(string paramName, GpuConstantDefinition baseDef)
 {
     OgrePINVOKE.GpuNamedConstants_generateConstantDefinitionArrayEntries(swigCPtr, paramName, GpuConstantDefinition.getCPtr(baseDef));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 5
0
        public GpuConstantDefinition getConstantDefinition(string name)
        {
            GpuConstantDefinition ret = new GpuConstantDefinition(OgrePINVOKE.GpuSharedParameters_getConstantDefinition(swigCPtr, name), false);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
            public GpuConstantDefinition Clone()
            {
                var result = new GpuConstantDefinition();

                result.ConstantType  = this.ConstantType;
                result.PhysicalIndex = PhysicalIndex;
                result.LogicalIndex  = this.LogicalIndex;
                result.ElementSize   = this.ElementSize;
                result.ArraySize     = this.ArraySize;
                result.Variability   = this.Variability;
                return(result);
            }
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(GpuConstantDefinition obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
 public GpuConstantDefinition Clone()
 {
     var result = new GpuConstantDefinition();
     result.ConstantType = ConstantType;
     result.PhysicalIndex = PhysicalIndex;
     result.LogicalIndex = LogicalIndex;
     result.ElementSize = ElementSize;
     result.ArraySize = ArraySize;
     result.Variability = Variability;
     return result;
 }
			public void AddConstantDefinition( string name, GpuConstantType constType, int arrraySize = 1 )
			{
				if ( NamedConstants.Map.ContainsKey( name ) )
				{
					throw new Exception( string.Format("Constant entry with name '{0}' allready exists.", name) );
				}

                var def = new GpuConstantDefinition
                          {
                              ArraySize = arrraySize,
                              ConstantType = constType,

                              // for compatibility we do not pad values to multiples of 4
                              // when it comes to arrays, user is responsible for creating matching defs
                              ElementSize = GpuConstantDefinition.GetElementSize( constType, false ),

                              // not used
                              LogicalIndex = 0,
                              Variability = GpuParamVariability.Global
                          };

				if ( def.IsFloat )
				{
					def.PhysicalIndex = FloatConstants.Count;
                    FloatConstants.Resize(FloatConstants.Count + def.ArraySize * def.ElementSize);
				}
				else
				{
					def.PhysicalIndex = IntConstants.Count;
                    IntConstants.Resize(IntConstants.Count + def.ArraySize * def.ElementSize);
				}
				NamedConstants.Map.Add( name, def );

				++Version;
			}
        /// <summary>
        /// Find a constant definition for a named parameter.
        /// <remarks>
        /// This method returns null if the named parameter did not exist, unlike
        /// <see cref="GetConstantDefinition" /> which is more strict; unless you set the 
        /// last parameter to true.
        /// </remarks>
        /// </summary>
        /// <param name="name">The name to look up</param>
        /// <param name="throwExceptionIfMissing"> If set to true, failure to find an entry
        /// will throw an exception.</param>
        public GpuConstantDefinition FindNamedConstantDefinition(string name, bool throwExceptionIfNotFound)
	    {

            if (namedParams == null)
		    {
                if (throwExceptionIfNotFound)
                    throw new AxiomException( "Named constants have not been initialised, perhaps a compile error." );
			    return null;
		    }

            int value;
            if (!namedParams.TryGetValue( name, out value ))
		    {
			    if (throwExceptionIfNotFound)
			        throw new AxiomException( "Parameter called " + name + " does not exist. " );
			    return null;
		    }
		    //else
	        {
                // temp hack (gotta update this mess)
	            var def = new GpuConstantDefinition();
	            def.LogicalIndex = value;
	            def.PhysicalIndex = value;
	            return def;
	            //return &(i->second);
	        }
	    }