Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is using multiple shaders for the same stage still a bad idea?

Tags:

opengl

I read that it's possible to attach multiple shaders to the same stage of a program in OpenGL, to create "libraries" of helper functions. I tried this and it worked well on my machine. However, the OpenGL Wiki warns

That being said, while this power is available, it is best not to use it. It usually works, but because most OpenGL applications don't do this, it doesn't get as thoroughly tested as other parts of the OpenGL API. So you're likely to run into more driver bugs this way. Generally stick to having one shader object per shader stage.

This section was written in 2013. Is this still true for reasonably modern hardware/drivers?

like image 331
Dan Avatar asked Nov 08 '22 22:11

Dan


1 Answers

IMHO the wiki note is totally opinable. Limiting the API because there is a possibility to encounter a bug? Come on, then just give up coding: no main(), no bugs.

Personally I've never encountered problems in splitting shaders in multiple objects, mainly on Nvidia, Amd and Intel. Maybe other platforms have limited drivers, but this can be worked around by processing multiple sources text.

Personally I don't see any valid reason to avoid multiple objects, however I would say that is quite rare the need of caching objects for linking it against multiple programs.

like image 161
Luca Avatar answered Dec 12 '22 01:12

Luca