GLSL Performance vs Maintainability

Hello, so I’ve been going back and forth between many shader files and constantly have to change, tweak and remove parameters in that order.

I’ve already modified my parser to allow #include support so common functionality can be in one file which is just great but wondered if I’d get a performance hit by doing the same to my uniform (UBO’s) because it would mean that some shader files will include UBO’s it never uses?

Furthermore, if you have any optimisation tips I’d LOVE to hear them :wink:

Well, if they’re std140 UBOs, and they have bindings specified in-shader, then that could cause the implementation to reserve space for them even if they go unused. Then again, maybe not.

If you want to be more certain about these things, declare structs in your included files, but define the actual UBOs in the sources that use them. So your UBO would just be layout(...) uniform Name {StructName data;};, with all of the parameter modifications happening in the structs.

[QUOTE=Alfonse Reinheart;1282393]Well, if they’re std140 UBOs, and they have bindings specified in-shader, then that could cause the implementation to reserve space for them even if they go unused. Then again, maybe not.

If you want to be more certain about these things, declare structs in your included files, but define the actual UBOs in the sources that use them. So your UBO would just be layout(...) uniform Name {StructName data;};, with all of the parameter modifications happening in the structs.[/QUOTE]

Yes I’m using both qualifiers. That’s exactly what I was looking for thank you, works like a charm :smiley:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.