Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

OpenGL allows you to share the same shader between multiple programs. Aside from saving small amounts of memory and a shader handle, are there any GPU-side performance benefits to doing this?

share|improve this question
add comment

1 Answer

I doubt there is a GPU-side performance benefit.

When you bind a generic shader to a program for example, an efficient implementation should be able to remove unused attributes between that shader and the other shaders in that program and possibly even simplify the shader logic as a result. Of course, this is no real benefit over a hand-tuned shader combination, but it does help manage the complexity/combinatorics, and possibly reduce the number of compiles the driver has to do.

However, there may be drawbacks to doing this in terms of hitting inefficient driver-compiler implementations. And there are some out there, check: http://aras-p.info/blog/2010/09/29/glsl-optimizer/ for just some simple things that some implementations can get wrong.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.