Jump to content
  • Advertisement
Sign in to follow this  
schupf

Is setting a uniform variable persistent?

This topic is 2436 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello!

I made some tests but I am still not sure about this:
If I set a certain shader register (i.e. register c4 with mDevice->SetPixelShaderConstantF(4, data, 1))
Will register c4 now contain this value also the next frames or do I have to update c4 every frame even if the value never changes?

In other words: Should I upload everything every frame or upload all uniforms ONCE and then only update the ones that have been changed?

Share this post


Link to post
Share on other sites
Advertisement
It's definitely persistent for the duration of a frame, but I'm not sure if the state will survive across frames. PIX should be able to tell you really quickly.

Share this post


Link to post
Share on other sites
Updating everything every frame would seem better to me; it's more in line with the way constant buffers are used in D3D10/11 which would be more likely to be the optimal path on current and future hardware. But this is just a personal hunch - as usual, benchmark.

Share this post


Link to post
Share on other sites
I would just update constants every frame. Setting something once a frame shouldn't matter at all...it's setting constants many times during a frame that can hurt performance.

Share this post


Link to post
Share on other sites
In D3D9, I treat the shader constants as if they were a global cbuffer. When you set a constant, you're writing into that global cbuffer. The value will persist there until you write a new value over the top of it.

Share this post


Link to post
Share on other sites
...or you're using the Effects framework, in which case one constant may overwrite another.

Not relevant with SetPixelShaderConstantF of course, but something that the OP should be aware of nonetheless.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!