I've been googling around OpenGL binary formats and what they actually are/mean. So far I've not had much success. I know I can fetch the number and set of formats as follows:
::glGetIntegerv(GL_PROGRAM_BINARY_FORMATS, &values[0]);
, where values is a std::vector of integers of size:
::glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &value);
For the driver in my machine this returns a single binary format. It's just a number and is pretty meaningless to me otherwise.
So my questions are as follows:
(1) What do the format numbers/codes represent? (2) Are there standard ARB binary formats, or are they all vendor dependent? (3) Is there a common format between vendors? (4) If there are multiple formats, how are you supposed to choose between them?
I have a vague feeling I have to pre-compile and cache shaders on a given machine in order to take advantage of this. I mean it isn't like DX is it, where you can run the shader compiler as a post-build event and package them together and use them on any (Windows) machine with D3D.
(1) What do the format numbers/codes represent?
They represent unique identifiers.
(2) Are there standard ARB binary formats, or are they all vendor dependent?
They are all vendor specific.
(3) Is there a common format between vendors?
No.
(4) If there are multiple formats, how are you supposed to choose between them?
You don't. You don't get a choice of formats. When you call glGetProgramBinary
, you get binary data in a particular format decided by the driver. When you load that program later, you must pass that specific format with the binary data.
I have a vague feeling I have to pre-compile and cache shaders on a given machine in order to take advantage of this.
Yes, that's the purpose of the feature: to allow you to cache shader compilation. But you must always make sure that your program will work if the driver's shader version changes (and therefore is different from when you created the cached version). So you'll still need to be able to rebuild the shaders from the textual form.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With