Jump to content

  • Log In with Google      Sign In   
  • Create Account

Is setting a uniform variable persistent?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 schupf   Members   -  Reputation: 216

Like
0Likes
Like

Posted 09 April 2012 - 10:46 AM

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?

Sponsor:

#2 MJP   Moderators   -  Reputation: 11347

Like
0Likes
Like

Posted 09 April 2012 - 03:24 PM

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.

#3 schupf   Members   -  Reputation: 216

Like
0Likes
Like

Posted 09 April 2012 - 04:37 PM

So whats best practice? Lazy updating or uploading everything every frame?

#4 mhagain   Crossbones+   -  Reputation: 7975

Like
0Likes
Like

Posted 09 April 2012 - 06:23 PM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#5 MJP   Moderators   -  Reputation: 11347

Like
0Likes
Like

Posted 09 April 2012 - 11:20 PM

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.

#6 Hodgman   Moderators   -  Reputation: 30384

Like
0Likes
Like

Posted 09 April 2012 - 11:25 PM

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.

#7 Nik02   Crossbones+   -  Reputation: 2830

Like
2Likes
Like

Posted 10 April 2012 - 12:39 AM

...unless the device is lost.

Niko Suni


#8 mhagain   Crossbones+   -  Reputation: 7975

Like
0Likes
Like

Posted 10 April 2012 - 03:15 AM

...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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS