UBOs aren't a GL 4.5 feature - they're core since 3.1; this may influence your decision on how to handle this.
Shader Permutations
Yup, no idea where you got from UBOs are a 4.5 feature.
In GL 3.3 you got UBOs and glBindBufferRange, you got TBOs also. Unless you're messing with draw indirect, you wont be missing anything from GL 4+ when dealing with this stuff.
GL2 - individual uniforms, set on program (such silly).
D3D11 - uniform buffers set on device.
GL3/GL4 - can mix GL2 and D3D11 approaches.
Vulkan/D3D12 - can mix D3D9 and D3D11 approaches.
When using uniform buffers, you can use the location keyword (register keyword in D3D) to associate the shader variable with a particular integer binding location. This lets all the permutations use the same buffer binding logic. What you do need is some kind of bitmask that specifies whether a particular UBO binding slot / location exists for a permutation or not so that you don't try to preform an invalid operation or simply waste time binding unused data (unused uniform declarations are optimized out).
Alternatively, yes, without your shaders explicitly declaring UBO locations, you'd need a big dictionary where you could look up how to bind a buffer based on the shader variablr name and the current permutation...
D3D9 - individual uniforms, set on device.
GL2 - individual uniforms, set on program (such silly).
D3D11 - uniform buffers set on device.
GL3/GL4 - can mix GL2 and D3D11 approaches.
Vulkan/D3D12 - can mix D3D9 and D3D11 approaches.
When using uniform buffers, you can use the location keyword (register keyword in D3D) to associate the shader variable with a particular integer binding location. This lets all the permutations use the same buffer binding logic. What you do need is some kind of bitmask that specifies whether a particular UBO binding slot / location exists for a permutation or not so that you don't try to preform an invalid operation or simply waste time binding unused data (unused uniform declarations are optimized out).
Alternatively, yes, without your shaders explicitly declaring UBO locations, you'd need a big dictionary where you could look up how to bind a buffer based on the shader variablr name and the current permutation...
Thank you, this is what I needed to know.
Don't know where I got UBOs being in 4.5, must have been something else I was looking at..
EDIT: I remember what it was now... I was looking at compute shaders, which are only available on 4.3+
Thanks