0

I'm discovering shaders by use, and have come to a weird issue.

I need the ARB_robustness extension for my fragment shader to function properly. GLEW is positive that I have that extension :

assert(GLEW_ARB_robustness); // Passes

...however when I require it in my shader...

#extension GL_ARB_robustness : require

...the shader compiler does not recognize it.

0(3) : error C0202: extension ARB_robustness not supported

GLEW is correctly initialized, and everything works fine as long as I don't try to use that extension.

What could be the cause of this problem, and how could I solve it ? Thanks in advance.

Update: I'm poking at it on my side with the help of a friend, I ran glxinfo on his advice and the name of the extension does appear in the output.

Quentin
  • 62,093
  • 7
  • 131
  • 191
  • do you have assertions enabled? maybe replace the assert with an `if(GLEW_ARB_robustness)printf("I am robust!");` and check again – ratchet freak Nov 27 '14 at 21:09
  • @ratchetfreak Now my program happily boasts about being robust, then blows up the same way :p – Quentin Nov 27 '14 at 21:12

1 Answers1

5

GL_ARB_robustness is not a GLSL modifying extension. The intention of this extension is to make the interaction with the OpenGL API more robust in the sense that out-of-bound accesses to memory can be caught. Somewhat like the difference between sprintf and snprintf. Since this is not a shader extension it makes no sense to declare using it in the shaders.

EDIT Apart from that to actually have robustness support, the OpenGL context must be created with the robustness attribute enabled: See https://www.opengl.org/registry/specs/ARB/wgl_create_context_robustness.txt and https://www.opengl.org/registry/specs/ARB/glx_create_context_robustness.txt – with robustness actually enabled for the context, the shader may also pass.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • I found this extension while searching for a way of `texelFetch`ing out of the texture's bounds securely (returning pure black), so I supposed it was to be enabled in shaders. Could you expand a bit on how to create the context that way ? I'm currently using SDL2 on Linux, with `SDL_GL_CreateContext`. – Quentin Nov 28 '14 at 14:43
  • 1
    @Quentin: Use `SDL_GL_SetAttribute (SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG);` *before* calling `SDL_GL_CreateContext (...)`, see [here](https://wiki.libsdl.org/SDL_GLcontextFlag) for more details. – Andon M. Coleman Nov 28 '14 at 15:36
  • 1
    @datenwolf I seem to have mixed up robustness and robust_buffer_access_behavior. From [here](http://us.download.nvidia.com/opengl/specs/GL_ARB_robust_buffer_access_behavior.txt): "[...] if the context was created with robust buffer access enabled then instead of undefined behavior the result of the texel fetch is zero." – Quentin Nov 28 '14 at 16:59