Good day all, I'm new to HLSL/XNA and C#, and here's a rather silly question for y'all. Taking "Effect.fx" that came with the XNA documentation, I see the following "global" declarations:
uniform extern float4x4 WorldViewProj : WORLDVIEWPROJECTION;
uniform extern texture UserTexture;
... and say if I were to add one CurrentTime variable for animation, it'll look something like this:
uniform extern float4x4 WorldViewProj : WORLDVIEWPROJECTION;
uniform extern texture UserTexture;
uniform extern float CurrentTime;
From within my game code I do this to update game time for animation:
protected override void Draw(GameTime gameTime)
{
float fCurrTime = ((float)gameTime.ElapsedTime.Millisecond);
effect.Parameters["CurrentTime"].SetValue(fCurrTime);// Other render stuff goes here...
}
Now my animation seems working well right now and by right I shouldn't be worrying. But then I realized what the XNA document says (EffectParameter.SetValue):
"Setting the value of an effect parameter is a slow operation. Avoid high frequency calls."
Hang on a sec, that's exactly what I'm doing!! Ever since then, the more new parameters are added to my shader code the more worried I am. But looking at the CPU usage it's currently 3% (yah I'm not doing too much at the moment), so I'm wondering should I be worrying about the performance at all Is my case considered "high frequency" one Are there any read-backs from the GPU for this operation Is there any alternative to setting shader parameters
Thanks a lot, in advance.
_Ben.