C# Class Axiom.Graphics.GpuProgramParameters

Collects together the program parameters used for a GpuProgram.
Gpu program state includes constant parameters used by the program, and bindings to render system state which is propagated into the constants by the engine automatically if requested.

GpuProgramParameters objects should be created through the GpuProgramManager and may be shared between multiple GpuProgram instances. For this reason they are managed using a shared pointer, which will ensure they are automatically deleted when no program is using them anymore.

Different types of GPU programs support different types of constant parameters. For example, it's relatively common to find that vertex programs only support floating point constants, and that fragment programs only support integer (fixed point) parameters. This can vary depending on the program version supported by the graphics card being used. You should consult the documentation for the type of low level program you are using, or alternatively use the methods provided on Capabilities to determine the options.

Another possible limitation is that some systems only allow constants to be set on certain boundaries, e.g. in sets of 4 values for example. Again, see Capabilities for full details.

Inheritance: DisposableObject
Show file Open project: mono-soc-2011/axiom Class Usage Examples

Protected Properties

Property Type Description
AutoConstantDictionary AutoConstantDefinition[]
autoAddParamName bool
autoConstantList AutoConstantEntryList
floatConstants FloatConstantEntryList
ignoreMissingParameters bool
intConstants IntConstantEntryList
namedParams AxiomCollection
paramTypeList List
tmpVals float[]
transposeMatrices bool

Private Properties

Property Type Description
SetLogicalIndexes void

Public Methods

Method Description
AddParameterToDefaultsList ( GpuProgramParameterType type, string name ) : void
ClearAutoConstantType ( ) : void

Clears all the existing automatic constants.

Clone ( ) : GpuProgramParameters
CopyConstantsFrom ( GpuProgramParameters source ) : void

Copies the values of all constants (including auto constants) from another GpuProgramParameters object.

CopyMatchingNamedConstantsFrom ( GpuProgramParameters source ) : void
FindNamedConstantDefinition ( string name, bool throwExceptionIfNotFound ) : GpuConstantDefinition

Find a constant definition for a named parameter. This method returns null if the named parameter did not exist, unlike GetConstantDefinition which is more strict; unless you set the last parameter to true.

GetAutoConstantDefinition ( int idx, AutoConstantDefinition &def ) : bool

gets the auto constant definition using an index into the auto constant definition array. If the index is out of bounds then false is returned;

GetAutoConstantDefinition ( string name, AutoConstantDefinition &def ) : bool

Gets the auto constant definition associated with name if found else returns false

GetFloatConstant ( int i ) : FloatConstantEntry

GetFloatPointer ( int physicalIndex ) : float[]
GetIntConstant ( int i ) : IntConstantEntry

GetIntPointer ( int physicalIndex ) : int[]
GetNameByIndex ( int index ) : string

Given an index, this function will return the name of the parameter at that index.

GetNamedFloatConstant ( string name ) : FloatConstantEntry

Gets a Named Float Constant entry if the name is found otherwise returns a null.

GetNamedIntConstant ( string name ) : IntConstantEntry

Gets a Named Int Constant entry if the name is found otherwise returns a null.

GetParamIndex ( string name ) : int

Gets the constant index of the specified named param.

GpuProgramParameters ( ) : System

Default constructor.

IncPassIterationNumber ( ) : void
MapParamNameToIndex ( string name, int index ) : void

Maps a parameter name to the specified constant index.

SetAutoConstant ( AutoConstantEntry entry ) : void

Overloaded method.

SetAutoConstant ( int index, AutoConstantType type ) : void

Sets up a constant which will automatically be updated by the engine.

Vertex and fragment programs often need parameters which are to do with the current render state, or particular values which may very well change over time, and often between objects which are being rendered. This feature allows you to set up a certain number of predefined parameter mappings that are kept up to date for you.

SetAutoConstant ( int index, AutoConstantType type, float extraInfo ) : void

Overloaded method.

SetAutoConstant ( int index, AutoConstantType type, int extraInfo ) : void

Overloaded method.

SetConstant ( int index, ColorEx color ) : void

Sends 4 packed floating-point RGBA color values to the program.

SetConstant ( int index, Matrix4 val ) : void

Sends a multiple value constant floating-point parameter to the program.

This method is made virtual to allow GpuProgramManagers, or even individual GpuProgram implementations to supply their own implementation if need be. An example would be where a Matrix needs to be transposed to row-major format before passing to the hardware.

SetConstant ( int index, Matrix4 matrices, int count ) : void

Sends a multiple matrix values to the program.

SetConstant ( int index, Vector3 val ) : void

Sends 3 packed floating-point values to the program.

SetConstant ( int index, Vector4 val ) : void

Sends 4 packed floating-point values to the program.

SetConstant ( int index, float value ) : void

Provides a way to pass in a single float

SetConstant ( int index, float f0, float f1, float f2, float f3 ) : void

Optimize the most common case of setting constant consisting of four floats

SetConstant ( int index, int ints ) : void

Sets an array of int values starting at the specified index.

SetConstantFromTime ( int index, float factor ) : void

SetIntConstant ( int index, int value ) : void

Provides a way to pass in the technique pass number

SetNamedAutoConstant ( string name, AutoConstantType type ) : void
SetNamedAutoConstant ( string name, AutoConstantType type, int extraInfo ) : void

Sets up a constant which will automatically be updated by the engine.

Vertex and fragment programs often need parameters which are to do with the current render state, or particular values which may very well change over time, and often between objects which are being rendered. This feature allows you to set up a certain number of predefined parameter mappings that are kept up to date for you.

SetNamedConstant ( string name, ColorEx color ) : void

Sends 4 packed floating-point RGBA color values to the program.

SetNamedConstant ( string name, Matrix4 val ) : void

Sends a multiple value constant floating-point parameter to the program.

SetNamedConstant ( string name, Matrix4 matrices, int count ) : void

Sends multiple matrices into a program.

SetNamedConstant ( string name, Vector3 val ) : void

Sends 3 packed floating-point values to the program.

SetNamedConstant ( string name, Vector4 val ) : void

Sends 4 packed floating-point values to the program.

SetNamedConstant ( string name, float val ) : void
SetNamedConstant ( string name, int val ) : void
SetNamedConstantFromTime ( string name, float factor ) : void

SetNamedConstants ( GpuNamedConstants constantDefs ) : void
UpdateAutoParams ( AutoParamDataSource source, GpuParamVariability mask ) : void

Update automatic parameters.

UpdateAutoParamsLightsOnly ( AutoParamDataSource source ) : void

Updates the automatic light parameters based on the details provided.

UpdateAutoParamsNoLights ( AutoParamDataSource source ) : void

Updates the automatic parameters (except lights) based on the details provided.

Private Methods

Method Description
SetLogicalIndexes ( GpuLogicalBufferStruct floatIndexMap, GpuLogicalBufferStruct intIndexMap ) : void

Method Details

AddParameterToDefaultsList() public method

public AddParameterToDefaultsList ( GpuProgramParameterType type, string name ) : void
type GpuProgramParameterType
name string
return void

ClearAutoConstantType() public method

Clears all the existing automatic constants.
public ClearAutoConstantType ( ) : void
return void

Clone() public method

public Clone ( ) : GpuProgramParameters
return GpuProgramParameters

CopyConstantsFrom() public method

Copies the values of all constants (including auto constants) from another GpuProgramParameters object.
public CopyConstantsFrom ( GpuProgramParameters source ) : void
source GpuProgramParameters Set of params to use as the source.
return void

CopyMatchingNamedConstantsFrom() public method

public CopyMatchingNamedConstantsFrom ( GpuProgramParameters source ) : void
source GpuProgramParameters
return void

FindNamedConstantDefinition() public method

Find a constant definition for a named parameter. This method returns null if the named parameter did not exist, unlike GetConstantDefinition which is more strict; unless you set the last parameter to true.
public FindNamedConstantDefinition ( string name, bool throwExceptionIfNotFound ) : GpuConstantDefinition
name string The name to look up
throwExceptionIfNotFound bool
return GpuConstantDefinition

GetAutoConstantDefinition() public static method

gets the auto constant definition using an index into the auto constant definition array. If the index is out of bounds then false is returned;
public static GetAutoConstantDefinition ( int idx, AutoConstantDefinition &def ) : bool
idx int The auto constant index
def AutoConstantDefinition
return bool

GetAutoConstantDefinition() public static method

Gets the auto constant definition associated with name if found else returns false
public static GetAutoConstantDefinition ( string name, AutoConstantDefinition &def ) : bool
name string The name of the auto constant
def AutoConstantDefinition
return bool

GetFloatConstant() public method

public GetFloatConstant ( int i ) : FloatConstantEntry
i int
return FloatConstantEntry

GetFloatPointer() public method

public GetFloatPointer ( int physicalIndex ) : float[]
physicalIndex int
return float[]

GetIntConstant() public method

public GetIntConstant ( int i ) : IntConstantEntry
i int
return IntConstantEntry

GetIntPointer() public method

public GetIntPointer ( int physicalIndex ) : int[]
physicalIndex int
return int[]

GetNameByIndex() public method

Given an index, this function will return the name of the parameter at that index.
public GetNameByIndex ( int index ) : string
index int Index of the parameter to look up.
return string

GetNamedFloatConstant() public method

Gets a Named Float Constant entry if the name is found otherwise returns a null.
public GetNamedFloatConstant ( string name ) : FloatConstantEntry
name string Name of the constant to retreive.
return FloatConstantEntry

GetNamedIntConstant() public method

Gets a Named Int Constant entry if the name is found otherwise returns a null.
public GetNamedIntConstant ( string name ) : IntConstantEntry
name string Name of the constant to retreive.
return IntConstantEntry

GetParamIndex() public method

Gets the constant index of the specified named param.
public GetParamIndex ( string name ) : int
name string /// Name of the param. ///
return int

GpuProgramParameters() public method

Default constructor.
public GpuProgramParameters ( ) : System
return System

IncPassIterationNumber() public method

public IncPassIterationNumber ( ) : void
return void

MapParamNameToIndex() public method

Maps a parameter name to the specified constant index.
public MapParamNameToIndex ( string name, int index ) : void
name string Name of the param.
index int Constant index of the param.
return void

SetAutoConstant() public method

Overloaded method.
public SetAutoConstant ( AutoConstantEntry entry ) : void
entry AutoConstantEntry
return void

SetAutoConstant() public method

Sets up a constant which will automatically be updated by the engine.
Vertex and fragment programs often need parameters which are to do with the current render state, or particular values which may very well change over time, and often between objects which are being rendered. This feature allows you to set up a certain number of predefined parameter mappings that are kept up to date for you.
public SetAutoConstant ( int index, AutoConstantType type ) : void
index int /// The location in the constant list to place this updated constant every time /// it is changed. Note that because of the nature of the types, we know how big the /// parameter details will be so you don't need to set that like you do for manual constants. ///
type AutoConstantType The type of automatic constant to set.
return void

SetAutoConstant() public method

Overloaded method.
public SetAutoConstant ( int index, AutoConstantType type, float extraInfo ) : void
index int /// The location in the constant list to place this updated constant every time /// it is changed. Note that because of the nature of the types, we know how big the /// parameter details will be so you don't need to set that like you do for manual constants. ///
type AutoConstantType The type of automatic constant to set.
extraInfo float If the constant type needs more information (like a light index) put it here.
return void

SetAutoConstant() public method

Overloaded method.
public SetAutoConstant ( int index, AutoConstantType type, int extraInfo ) : void
index int /// The location in the constant list to place this updated constant every time /// it is changed. Note that because of the nature of the types, we know how big the /// parameter details will be so you don't need to set that like you do for manual constants. ///
type AutoConstantType The type of automatic constant to set.
extraInfo int If the constant type needs more information (like a light index) put it here.
return void

SetConstant() public method

Sends 4 packed floating-point RGBA color values to the program.
public SetConstant ( int index, ColorEx color ) : void
index int Index of the contant register.
color Axiom.Core.ColorEx Structure containing 4 packed RGBA color values.
return void

SetConstant() public method

Sends a multiple value constant floating-point parameter to the program.
This method is made virtual to allow GpuProgramManagers, or even individual GpuProgram implementations to supply their own implementation if need be. An example would be where a Matrix needs to be transposed to row-major format before passing to the hardware.
public SetConstant ( int index, Matrix4 val ) : void
index int Index of the contant register.
val Axiom.Math.Matrix4 Structure containing 3 packed float values.
return void

SetConstant() public method

Sends a multiple matrix values to the program.
public SetConstant ( int index, Matrix4 matrices, int count ) : void
index int Index of the contant register.
matrices Axiom.Math.Matrix4 Values to set.
count int Number of matrices to set
return void

SetConstant() public method

Sends 3 packed floating-point values to the program.
public SetConstant ( int index, Vector3 val ) : void
index int Index of the contant register.
val Vector3 Structure containing 3 packed float values.
return void

SetConstant() public method

Sends 4 packed floating-point values to the program.
public SetConstant ( int index, Vector4 val ) : void
index int Index of the contant register.
val Vector4 Structure containing 4 packed float values.
return void

SetConstant() public method

Provides a way to pass in a single float
public SetConstant ( int index, float value ) : void
index int Index of the contant register to start at.
value float
return void

SetConstant() public method

Optimize the most common case of setting constant consisting of four floats
public SetConstant ( int index, float f0, float f1, float f2, float f3 ) : void
index int Index of the contant register to start at.
f0 float The floats.
f1 float The floats.
f2 float The floats.
f3 float The floats.
return void

SetConstant() public method

Sets an array of int values starting at the specified index.
public SetConstant ( int index, int ints ) : void
index int Index of the contant register to start at.
ints int Array of ints.
return void

SetConstantFromTime() public method

public SetConstantFromTime ( int index, float factor ) : void
index int
factor float
return void

SetIntConstant() public method

Provides a way to pass in the technique pass number
public SetIntConstant ( int index, int value ) : void
index int Index of the contant register to start at.
value int Value of the constant.
return void

SetNamedAutoConstant() public method

public SetNamedAutoConstant ( string name, AutoConstantType type ) : void
name string
type AutoConstantType
return void

SetNamedAutoConstant() public method

Sets up a constant which will automatically be updated by the engine.
Vertex and fragment programs often need parameters which are to do with the current render state, or particular values which may very well change over time, and often between objects which are being rendered. This feature allows you to set up a certain number of predefined parameter mappings that are kept up to date for you.
public SetNamedAutoConstant ( string name, AutoConstantType type, int extraInfo ) : void
name string /// Name of the param. ///
type AutoConstantType /// The type of automatic constant to set. ///
extraInfo int /// Any extra information needed by the auto constant (i.e. light index, etc). ///
return void

SetNamedConstant() public method

Sends 4 packed floating-point RGBA color values to the program.
public SetNamedConstant ( string name, ColorEx color ) : void
name string Name of the param.
color Axiom.Core.ColorEx Structure containing 4 packed RGBA color values.
return void

SetNamedConstant() public method

Sends a multiple value constant floating-point parameter to the program.
public SetNamedConstant ( string name, Matrix4 val ) : void
name string Name of the param.
val Axiom.Math.Matrix4 Structure containing 3 packed float values.
return void

SetNamedConstant() public method

Sends multiple matrices into a program.
public SetNamedConstant ( string name, Matrix4 matrices, int count ) : void
name string Name of the param.
matrices Axiom.Math.Matrix4 Array of matrices.
count int
return void

SetNamedConstant() public method

Sends 3 packed floating-point values to the program.
public SetNamedConstant ( string name, Vector3 val ) : void
name string Name of the param.
val Vector3 Structure containing 3 packed float values.
return void

SetNamedConstant() public method

Sends 4 packed floating-point values to the program.
public SetNamedConstant ( string name, Vector4 val ) : void
name string Name of the contant register.
val Vector4 Structure containing 4 packed float values.
return void

SetNamedConstant() public method

public SetNamedConstant ( string name, float val ) : void
name string
val float
return void

SetNamedConstant() public method

public SetNamedConstant ( string name, int val ) : void
name string
val int
return void

SetNamedConstantFromTime() public method

public SetNamedConstantFromTime ( string name, float factor ) : void
name string
factor float
return void

SetNamedConstants() public method

public SetNamedConstants ( GpuNamedConstants constantDefs ) : void
constantDefs GpuNamedConstants
return void

UpdateAutoParams() public method

Update automatic parameters.
public UpdateAutoParams ( AutoParamDataSource source, GpuParamVariability mask ) : void
source AutoParamDataSource The source of the parameters
mask GpuParamVariability A mask of GpuParamVariability which identifies which autos will need updating
return void

UpdateAutoParamsLightsOnly() public method

Updates the automatic light parameters based on the details provided.
public UpdateAutoParamsLightsOnly ( AutoParamDataSource source ) : void
source AutoParamDataSource /// A source containing all the updated data to be made available for auto updating /// the GPU program constants. ///
return void

UpdateAutoParamsNoLights() public method

Updates the automatic parameters (except lights) based on the details provided.
public UpdateAutoParamsNoLights ( AutoParamDataSource source ) : void
source AutoParamDataSource /// A source containing all the updated data to be made available for auto updating /// the GPU program constants. ///
return void

Property Details

AutoConstantDictionary protected static property

protected static AutoConstantDefinition[] AutoConstantDictionary
return AutoConstantDefinition[]

autoAddParamName protected property

Flag to indicate if names not found will be automatically added.
protected bool autoAddParamName
return bool

autoConstantList protected property

List of automatically updated parameters.
protected AutoConstantEntryList autoConstantList
return AutoConstantEntryList

floatConstants protected property

Table of Vector4 constants by index.
protected FloatConstantEntryList floatConstants
return FloatConstantEntryList

ignoreMissingParameters protected property

protected bool ignoreMissingParameters
return bool

intConstants protected property

Packed list of integer constants
protected IntConstantEntryList intConstants
return IntConstantEntryList

namedParams protected property

Lookup of constant indicies for named parameters.
protected AxiomCollection namedParams
return AxiomCollection

paramTypeList protected property

protected List paramTypeList
return List

tmpVals protected property

Temp array for use when passing constants around.
protected float[] tmpVals
return float[]

transposeMatrices protected property

Specifies whether matrices need to be transposed prior to being sent to the hardware.
protected bool transposeMatrices
return bool