Best practice for setting Effect parameters in XNA
Posted
by
hichaeretaqua
on Game Development
See other posts from Game Development
or by hichaeretaqua
Published on 2012-10-15T12:49:42Z
Indexed on
2012/10/16
17:22 UTC
Read the original article
Hit count: 440
I want to ask if there is a best practice for setting Effect
parameters in XNA. Or in other words, what exactly happens when I call pass.Apply()
. I can imagine multiple scenarios:
- Each time
Apply
is called, all effect parameters are transferred to the GPU and therefor it has no real influence how often I set a parameter. - Each time
Apply
is called, only the parameters that got reset are transferred. So caching Set-operations that don't actually set a new value should be avoided. - Each time
Apply
is called, only the parameters that got changed are transferred. So caching Set-operations is useless. - This whole questions is bootless because no one of the mentions ways has any noteworthy impact on game performance.
So the final question: Is it useful to implement some caching of set operation like:
private Matrix _world;
public Matrix World
{
get{ return _world; }
set
{
if (value == world) return;
_effect.Parameters["xWorld"].SetValue(value);
_world = value;
}
}
Thanking you in anticipation.
© Game Development or respective owner