Archived

This topic is now archived and is closed to further replies.

Are all vertex shader constants equal?

This topic is 5009 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

Or are some more equal than others? What I really want to know is should I be doing anything special with vertex shader constants. Like restricting the range of constants I use, or not resending constants that haven't changed. Should I send batches of constants and not single constants? Is there a penalty if I use constants 0,10,54 and 140 rather than 0,1,2 and 3? And so on. In general, how much work should I do at my end with vertex constant management to keep the graphics speed up. Any help would be greatly appreciated. [edited by - DBX on March 26, 2004 10:21:05 AM]

Share this post


Link to post
Share on other sites
TO be a little clearer, I''m not talking about reducing drawprimitive calls because the change in shader will be forcing these changes. I''m just wondering about the constants on top of that (i.e. in use by each shader).

Share this post


Link to post
Share on other sites
Changing the shader constants should be something that you want to minimise too I think, if you''re on the DX9 beta there is part of the SDK documentation that now details relative performance cost of D3D calls, and IIRC setting shader constants isn''t all that cheap, so managing them is something that might benefit you (if it turns out to be a bottleneck).

I don''t know about ''some being more equal thn others'', or about restricting the range of constants you use. I''d *expect* using fewer constants might improve performance simply because you accessing the memory less or perhaps in a more cache-friendly pattern, but I don''t have any concrete proof of that at all.

-Mezz

Share this post


Link to post
Share on other sites
You want to reduce the number of calls to Set*Constant(), basically. To my knowledge, there''s no pref hit for not packing the ocnstants you use, but in general there''s no reason not to (just in case). But, I believe all registers are created equal in the shader hardware. There''s no concept of shader constant cache, to my knowledge, so no need to worry about concurrency.

In general, prefer to set as many constants in one call as you can. Setting float arrays and matrix arrays are better than setting individual floats.

I like pie.

Share this post


Link to post
Share on other sites
I''m pretty sure there is no penalty to use some shader constants over others. It''s possible that using constants 0 and 3 would result in 1 and 2 being wasted. It depends on the hardware implementation. Hardware vendors have shader compilers though and I''m pretty sure they will pack constants for you if that is a performance improvement. It''s easy for a compiler to do.

--
http://www.zmgames.com/

Share this post


Link to post
Share on other sites