• Advertisement
Sign in to follow this  

preshader or not?

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

If I want to write a shader library I can share a lots of variables (lights, view matrix) and pass them only one time to effect class. But there are someone else that I must recalculate every time like worldview matrix because world matrix changes for each object. Is a good idea to reduce the variables to pass to the effect and use preshader for calculate these matrix (example pass only world view e projection matrix to have all combinations)? Is there a limit to preshader length or incompatible issue with some kind of video cards like geforce3?

Share this post


Link to post
Share on other sites
Advertisement
Preshaders are executed in software inside the D3DX effect system. Because of this:

1) They consume CPU cycles to evaluate. This is one of those trade offs - save some GPU power by using some CPU power.

2) There aren't any compatibility issues; they'll work on all hardware, and as far as I know there aren't any size limits.

3) If the time the GPU spends with vertex shaders is a greater bottleneck than your CPU use, then preshaders will be beneficial to the performance of your application.

4) If on the other hand, your application is CPU bound rather than GPU (i.e. the greater bottleneck is CPU stuff), then preshaders can actually be bad for the performance of your application.

5) Most commercial 3D games are CPU bound; many demos, simple games and non-game apps are GPU bound. You'll have to profile your own app to know which is most applicable to you.

6) In summary, whether or not preshaders will be of benefit depends on what your application does. If vertex processing in the GPU is a bigger bottleneck, they'll help, but if CPU use is a bigger bottleneck, they might hurt (depending on what your shaders do).

Share this post


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

  • Advertisement