2
\$\begingroup\$

I'm about to start work on implementing GLSL binary shader compilation and I was curious how to handle the cases when the shaders need to be recompiled, such as when the driver (or perhaps even the graphics card itself) changes. Are there any mechanisms out there to do these types of things, or is this just a "delete the shader cache folder if you update your driver" type of thing? I did a quick search on here and Google and didn't see anything that looked promising.

Edit: or am I just ignorant and GL will let me know when a recompile is necessary?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

INVALID_OPERATION will be returned by glProgramBinary if the binary code is rejected. If this happens, you must recompile the GLSL source code the usual way and then use glGetProgramBinary in order to grab the new binary shader.

So, basically, something like like this rough pseudo-source:

load_shader(path):
  binary := load_binary(path)
  if binary != null:
    glProgramBinary
    if glGetError() != GL_NO_ERROR:
      load_source(path)
  else:
    load_source(path)

load_source():
  source := load_text(path)
  glSource
  glLink
  glGetProgramBinary
  save_binary()
\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .