🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Separation of shaders

Started by
1 comment, last by turanszkij 5 years, 1 month ago

Hello! There was a question about performance. I tried to combine (if possible) the shaders into one for rendering in one pass. For example, SSR and Bloom (search for bright areas), blur: DOF and Bloom. But now there is a need to put the output in textures of different sizes. This raises the question: if I split all the shaders (postprocessing) and render the image in several passes (for example, ssr → bloom → blur bloom → blur dof instead of screenspace (ssr and bloom) → blur (bloom and dof)), how much performance can suffer? And in general, merging shaders for rendering in one pass, good practice? I will be grateful for the answer

Advertisement

It depends on several things and combining multiple shaders into one can be worse in some cases. In your case, if you want to output into different resolutions, it is likely better to have separate shaders.

Combining multiple shaders into one will be helpful if you are bottlenecked by texture sampling/writing bandwidth. Otherwise, it will increase register usage in the shader and that can affect negatively how the GPU can parallelize the wavefronts (group of threads running a single shader). Because if one shader uses a lot of registers, then it will limit the amount of concurrent shaders that can be started on the GPU at the same time (this is called occupancy). 

To determine your bottleneck, you should use a GPU profiling tool such as Nvidia Nsight, AMD's GPU Perfstudio or Intel's Graphics Performance Analyzer.

This topic is closed to new replies.

Advertisement