2

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.

Anton Duzenko
  • 283
  • 3
  • 9

1 Answers1

0

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.

  • Eventually we moved to 3.1 as minimum requirement and that solved it. – Anton Duzenko Dec 13 '19 at 07:11
  • Make sure you change your #version string, BTW.

    Anyhow, you don't happen to be working on ARK Survival Evolved. That game has a stray old #version 120 in one of it's config files that could be causing problems. Some other Unreal Engine 3 and Unreal Engine 4 games have the same problem.

    This is likely stray cruft from when early Unreal Engine 4 was using ToGL instead of GLSLang as it's HLSL to GLSL translation layer. It likely never got removed from many games.

    Either way, using #Version 330 should solve the issue entirely.

    – Robert Wm Ruedisueli Dec 14 '19 at 06:02
  • The issue is that many GL drivers use substantially different compilers for GLSL versions before #130 in order to handle incompatible functions.

    1.30 through 1.50 have a compatability mode that removes forward compatability in favor of backwards compatability.

    Compatability and core shaders can't directly interact. You can use them together, though. You need to put their output to a buffer and have them operate on separate stages to pipeline them together. Each stage must be either compatability or core.

    – Robert Wm Ruedisueli Dec 14 '19 at 06:10
  • I would highly recommend targeting OpenGL 4.2 instead. I don't know of anyone with a system old enough not to support it.

    At least not if your software is solely targetting PC. (Freedrino which targets ARM only supports OpenGL 3.1)

    – Robert Wm Ruedisueli Dec 14 '19 at 06:46
  • Intel 2000\3000, as well as anything pre-DX11 on AMD/nVidia – Anton Duzenko Dec 14 '19 at 11:43
  • You might want to recheck the link I gave you.

    Linux drivers have added features to boards that did not ship with them.

    This includes everything Radeon HD2400 and later in AMD (i.e. back before ATI was sold to AMD), and anything Kaby Lake or later in Intel processors.

    Anything below that won't run SM4 at all. So really you have two choices. Either provide an alternative fallback shader for GLSL 3.3 (which will support everything that runs on x86_64)

    "Older" nVidia not supported by would be before the GT(X)600

    – Robert Wm Ruedisueli Dec 15 '19 at 11:59
  • To summarize the last comment. Just because Windows doesn't support it, doesn't mean Linux won't. Linux drivers are Open Source and receive feature updates long after Windows drivers stop getting them. – Robert Wm Ruedisueli Dec 15 '19 at 12:01
  • Additionally, because the Linux drivers tie SM4 to SM5 support, none of the GPUs you mentioned will support it.

    Instead you need to create a fallback render path and fallback shaders for older cards. This isn't a big deal.

    Simply put, you can't support SM4 on OpenGL 3.1 chipsets in Linux. It won't work. You need an OpenGL 4 capable chipset.

    – Robert Wm Ruedisueli Dec 15 '19 at 12:16