Ensure compatibility with GLSL

How can we guarantee that GLSL shaders are compatible with most modern cards?

I have software where I use the GLSL code from here . But even if I added #version 120 to the beginning of my final shader and made sure that it compiles, they get shader compilation errors on some users' computers (although they support OpenGL 3.2).

Is there any tool I can use to “test” or try compiling with different “shader compilers”?

+6
source share
2 answers

There is no tool to test the shader. Even if that were the case, it would not be useful for you because it is a good shader that is "valid" if it does not work on the right hardware? You may be right, whatever you want, but if your equipment rejects it, even if you are technically right, your shader will still not work.

If a shader of a certain version is compiled for one target (call it A), and not to another (call it B), this may be caused by one of the following problems:

  • Target A does not perform GLSL properly. This allowed you to compile what the specification does not allow. A more compatible target B (or at least in some ways incompatible) rejects your shader because your shader does not meet the specification.
  • Target B is out of specification. You feed it a legal shader and reject it.
  • Target B does not support the version of GLSL used by your shader (this is unlikely), unless:
  • Target B uses the OpenGL kernel specification version 3.2 or higher. GLSL 1.20 shaders cannot be launched based on 3.2 OpenGL implementations.

# 1 is likely to happen if you develop exclusively on NVIDIA hardware. NVIDIA is a little fast and free using the OpenGL specification. They will accept several privileges here and there, smoothing out some of the unpleasant things that are mentioned in the specification. This provides a smoother developer experience, but also helps support suppliers using NVIDIA hardware if shaders do not work on competitors;)

# 3 practically does not exist, with the exception noted. You are associated with the Photoshop shader, so I understand that you do not control the creation and management of the OpenGL context. However, I highly doubt that Photoshop will use the main context; they have too many shaders that need backward compatibility.

The best way to handle this is to test on both AMD hardware and NVIDIA (and Intel if you need to run there). You may not need to test all possible combinations of systems, but choose a Radeon HD card and a GeForce 200 or better. They do not even have to be high-end.

+6
source

The problem is that all hardware manufacturers write their own GLSL compiler implementations in their drivers. Despite the fact that the language is defined quite well, this leads to inconsistency in the analysis of shaders. For example, Nvidia drivers often “forgive” some small bugs that are caught by ATI.

A reasonable solution, I think, is to use Nvidia Cg instead ( http://developer.nvidia.com/cg-toolkit ) - this way you will make your shader hardware, agnostic and make sure that they work on all hardware.

-2
source

Source: https://habr.com/ru/post/894790/


All Articles