cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

tramboi
Journeyman III

Is it true that I can't glShaderBinary in OpenGL 4.2 on recent hardware?

Jump to solution

Hello, everybody.

getting GL_NUM_SHADER_BINARY_FORMATS gives me 0 supported binary formats on my HD7900.

Is it normal?  GL_NUM_SHADER_BINARY_FORMATS is 1, though.

But I make heavy use of generating GLSL, compiling it and linking the objects with a potential very big combinatory...

Can somebody confirm this?

0 Likes
1 Solution

Accepted Solutions
gsellers
Staff
Staff

Re: Is it true that I can't glShaderBinary in OpenGL 4.2 on recent hardware?

Jump to solution

Hi,

GL_NUM_SHADER_BINARY_FORMATS is part of the GL_ARB_ES2_compatibility extension, which is designed to improve source-level portability from OpenGL-ES 2.0. This is the number of binary formats supported for shader binaries. However, it's not mandatory for any driver (even in OpenGL-ES 2.0) to support any binary formats for shaders at all and so it may return zero in this case.

If you are running on desktop OpenGL, it's best to use program binaries as opposed to shader binaries. This allows you to get the binary for a fully linked monolithic program object. It works the same way as OpenGL-ES's shader binaries, except that you query GL_NUM_PROGRAM_BINARY_FORMATS and use glGetProgramBinary/glProgramBinary to retrieve and set the binary for the whole program object. This should work on any recent AMD driver.

Cheers,

Graham

View solution in original post

0 Likes
4 Replies
gsellers
Staff
Staff

Re: Is it true that I can't glShaderBinary in OpenGL 4.2 on recent hardware?

Jump to solution

Hi,

GL_NUM_SHADER_BINARY_FORMATS is part of the GL_ARB_ES2_compatibility extension, which is designed to improve source-level portability from OpenGL-ES 2.0. This is the number of binary formats supported for shader binaries. However, it's not mandatory for any driver (even in OpenGL-ES 2.0) to support any binary formats for shaders at all and so it may return zero in this case.

If you are running on desktop OpenGL, it's best to use program binaries as opposed to shader binaries. This allows you to get the binary for a fully linked monolithic program object. It works the same way as OpenGL-ES's shader binaries, except that you query GL_NUM_PROGRAM_BINARY_FORMATS and use glGetProgramBinary/glProgramBinary to retrieve and set the binary for the whole program object. This should work on any recent AMD driver.

Cheers,

Graham

View solution in original post

0 Likes
tramboi
Journeyman III

Re: Is it true that I can't glShaderBinary in OpenGL 4.2 on recent hardware?

Jump to solution

Hello and thanks for your very fast answer, Graham!

As I mentioned, I have a huge potential database of  variants to link, so caching the programs is not very efficient, if I want to bound the cache size.

Seems I have no choice though...

Is GL_NUM_PROGRAM_BINARY_FORMATS guaranteed to be non-zero in any way or is it just AMD specific?

0 Likes
gsellers
Staff
Staff

Re: Is it true that I can't glShaderBinary in OpenGL 4.2 on recent hardware?

Jump to solution

Hi,

To deal with the combinatorial explosion of shaders, link your programs in separate-shader mode (set GL_PROGRAM_SEPERABLE to GL_TRUE with glProgramParameteri). This allows you to create a separate program for each stage of the pipeline (vertex and fragment, for example) and query their binaries. If you're using geometry shaders or tessellation, you could get a program binary for the front end (vertex and geometry shaders, for instance) and a separate binary for the fragment shader.

tramboi wrote:

Is GL_NUM_PROGRAM_BINARY_FORMATS guaranteed to be non-zero in any way or is it just AMD specific?

I don't believe there's any guarantee here, but all vendors that support program binaries support at least one format, as far as I know.

Cheers,

Graham

0 Likes
tramboi
Journeyman III

Re: Is it true that I can't glShaderBinary in OpenGL 4.2 on recent hardware?

Jump to solution

Thanks again Graham, for the very precise and fast answers.

A real treat!

Cheers,

Bertrand

0 Likes