I added the DirectX tag, on the basis that this is lower-level functionality than XNA.
–
Andrew RussellOct 15 '12 at 13:20

I have found proof that the topic at hand is VERY viable. It looks like if you are clever with how you set your effect parameters, you can increase the number of draw calls (that is how fast they are processed on the CPU) more than twice. I am still in the process of testing this, you can read my question here: gamedev.stackexchange.com/questions/66932/…
–
cubrmanDec 9 '13 at 10:45

2 Answers
2

This all happens on the CPU side, so if caching were a useful feature, then I would speculate that the graphics driver would implement it itself. Adding your own caching layer is unnecessary.

My understanding is that whenever you set a parameter, and whenever you call Apply, these calls are passed to DirectX largely as-is, and in turn passed to the user-mode GPU driver as-is. The user-mode driver can then do whatever the hell it wants. All three of your scenarios are possible.

(Because scenario #2 is a possibility, it's probably best not to run around deliberately re-setting parameters that don't change.)

To be honest, I'm not really sure what a typical driver does. Mostly because it's never really come up as an issue. I've never heard of anyone having effect-parameter setting as a bottleneck. Maybe it could be, in theory. But there are so many more common things to worry about.

Interesting point that driver should care about this. Thanks for the link (and re-links).
–
0xBADF00DOct 15 '12 at 14:36

I recently came across the geometry instancing example from msdn. Resetting the same renderstates (with same values) multiple times per frame significantly slows down the rendering process by two or three times. So state batching is deferentially useful. Unfortunately I'm not sure weather this situation applies to setting effect parameters, too. But I would like to share my information.
–
0xBADF00DNov 21 '12 at 10:07

You can use the Parameters indexed property on Effect to access any
effect parameter, but this is slower than using EffectParameters. For
this reason, you should create an EffectParameter for each effect
parameter that changes frequently.

and

Creating and assigning a EffectParameter instance for each technique
in your Effect is significantly faster than using the Parameters
indexed property on Effect.

That means that _effect.Parameters["xWorld"].SetValue(value); is noticeably slower than wordlParam.SetValue(value);