Best practice settings 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/15 15:55 UTC
Read the original article Hit count: 375

Filed under:
|
|
|

I want to ask if there is a best practice settings effect parameters in XNA. Or in other words, what exactly happens when I call pass.Apply(). I can imagine multiple scenarios:

  1. 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.
  2. 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.
  3. Each time Apply() is called, only the parameters that got changed are transferred. So caching Set-operations is useless.
  4. 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

Related posts about XNA

Related posts about directx