Ubuntu – AMD GL_EXT_gpu_shader4 extension


I have stumbled into a basic OpenGL driver bug and I'm not sure where to report them.

Here's how the driver identifies itself and how we create the RC:

OpenGL vendor: X.Org
OpenGL renderer: AMD CARRIZO (DRM 3.26.0, 4.18.0-13-generic, LLVM 7.0.0)
OpenGL version: 4.4 (Compatibility Profile) Mesa 18.2.2
v - using GL version 2.0 (core)

It has ARB_gpu_shader5 in its extension list but not EXT_gpu_shader4.

This shader fails to compile

#version 120
#extension GL_EXT_gpu_shader4: enable
uniform usampler2D u_stencilTexture;        

With this error:

interaction VFWARNING:CompileShader(glprogs/interaction.fs): FAILED
0:2(12): warning: extension `GL_EXT_gpu_shader4' unsupported in fragment shader
0:27(20): error: syntax error, unexpected NEW_IDENTIFIER, expecting '{'

So my question is: how do I get the version 120 shader with the usampler extension to build on seemingly Opengl-4.4 capable GPU/driver?

Preferably in a cross-platform, cross-vendor way.

Please note that the same shader compiles just fine on a wide range of devices/drivers on both Linux and Windows.

Best Answer

  • Your problem is that you are marking #Version 120 which would be GLS 1.20 or OpenGL 2.0. Ideally you should use at least #version 400

    That extension is technically designed for GLSL 4.0.x and later and OpenGL 4.0 It was optional in revised releases of OpenGL 4.0 and core in 4.2. To insure support you should use GLSL Version 4.20 (i.e. #version 420 NOT #version 120). It may operate in forward compatibility compliant shaders of 130+ but this is not guaranteed as it is implementation specific.

    As of recent chips and Mesa support you can see the overview over at http://www.mesamatrix.net

    As you can see, everything but, freedrino, very old nVidia chips and very old intel chips has support for at least GLSL version 4.20

    I would highly recommend playing it safe and using #version 420 for your shaders unless you plan on sharing code with older macs.