I want to use the same uniform buffer for different shader programs, some of which might not use certain variables of the buffer at all. The way I understand this description this should be possible with the (default) shared layout description.
Unfortunately glGetUniformIndices will not give usable results if the specified variable is not used in that particular program. How should I query the buffer offset for that particular variable. Would it work to check all programs until I find one that indeed does use the variable? Or is there a better way.
I believe it would also be possible to use the std140 layout and calculate the offsets by myself using the defined rules. I'm not particularly worried about the theoretically higher storage cost, but it seems much more complicated to calculate the offset by hand instead of querying with the API.