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;
}