There's not too much deep information about them on the web.

How are they implemented and how they work under the hood? I'd like to know that they cause any performance overhead or not, especially in the case of multiple subroutines to decide what's the best practice to create different versions of shaders: subroutines or separate shaders.

Any info or advice?

  • \$\begingroup\$ I can't link the reference, but by my experience its as if all of them were inlined. \$\endgroup\$
    – akaltar
    Commented Jul 17, 2013 at 18:53
  • \$\begingroup\$ Don't you mean functions? They are inlined indeed. GLSL subroutines are a different concept. \$\endgroup\$
    – plasmacel
    Commented Jul 17, 2013 at 19:02
  • \$\begingroup\$ GLSL subroutines are like function pointers in C++. You can change the functionality of shaders from the host application without to recompile them. \$\endgroup\$
    – plasmacel
    Commented Jul 17, 2013 at 19:09
  • \$\begingroup\$ They're equivalent functionality to HLSL Shader Model 5.0 Interfaces, for which there is slightly more information available. Might help you find what you're looking for. In general, though, just profile and find out; whether they're super slow might depend on your target driver, hardware, etc. \$\endgroup\$ Commented Jul 18, 2013 at 1:07
  • \$\begingroup\$ Sorry, I indeed mixed up subroutines and functions. \$\endgroup\$
    – akaltar
    Commented Jul 18, 2013 at 9:56

1 Answer 1


Meanwhile I get a nice detailed answer from the OpenGL Forum here.

I think it will be useful for others too.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .