OpenGL Shader GLSL Version

I recently had some problems with GLSL shader versions on different computers. I know that each GPU can have different shader support, but I don't know how to make one shader that will work on all GPUs. If I write some shaders on my PC (GPU - AMD HD7770) I don't even need to specify the version, but on some old PC or PS with nVidia GPU it is stricter in the version, so I have to specify the version that the GPU supports ...

Now the real problem is. If I specify, for example, version 330 on my PC, it works as it should, but on another PC that needs to support version 330, it doesn't work. So I have to rewrite it and make it work. And if I go back to my PC with a newer GPU, it doesn't work either.

Does anyone know how I should write a shader so that it can run on all GPUs?

+3


source to share


1 answer


Writing portable OpenGL code is not as easy as you might like.

  • The nVidia drivers are solvable. You can get away with many things on nVidia drivers that you cannot avoid on other systems.

  • It's easy to accidentally use additional functions. For example, I wrote a program for a 3.2-wire profile, but used it GL_INT_2_10_10_10_REV

    as the vertex format. The symbol is GL_INT_2_10_10_10_REV

    defined in 3.2, but it is not allowed as a vertex format before 3.3, and you will not get error messages for using it accidentally.

  • Many people are running old drivers. ... According to a Steam survey in 2013, 38% of customers with OpenGL 3.x drivers did not have 3.3 support, although the hardware that 3.0 support should support 3.3.

  • You always need to test. This is an unfortunate reality.

My recommendations:



  • Always configure the main profile.

  • Always indicate the version of the shader language.

  • Check the driver version and abort if it is too old.

  • If you can, use OpenGL headers / bindings that only display characters in the targeting version.

  • Get a copy of the spec for the target version and use it as a link instead of the OpenGL man pages.

  • Write your code so it can work on OpenGL ES as well, if possible.

  • Testing on different systems. One PC probably isn't going to cut it. If you can dig a second computer with a graphics card from another vendor (don't forget Intel integrated graphics) that would be better. You can probably get an OpenGL 3.x desktop for a couple hundred dollars, or if you want to save money, ask to use a computer for quick testing. You can also buy a second graphics card (think under $ 40 for a low-end card with OpenGL 4.x support), just be careful when replacing them.

The main reason commercial games run on various systems is because they have a QA budget. If you can afford a QA team, do it! If you don't have a QA team, you have to do both QA and development - two jobs is more work, but that's the price you pay to fix bugs.

+4


source







All Articles