Detecting the Shader Model
OpenGL does not follow the Direct3D Shader Model format; it has its own way to expose specific sets of functionality to the user. The OpenGL version number and the presence of extensions is a better test for what features are available on the hardware.
However, if you must equate GL functionality with Direct3D Shader Model versions, here is how to do so. It differs for different shading languages.
OpenGL Shading Language
Query the version of with
glGetString(GL_SHADING_LANGUAGE_VERSION). The version is formatted as
<version number><space><vendor-specific information>, where
<version number> is a
MAJOR.MINOR format, with an optional release number.
Shading language versions 1.3 is equivalent to much of Shader Model 4.0. Version 1.4 introduces uniform buffers and a few other features. Version 1.5 introduces geometry shaders; this version could be said to be feature-identical to Shader Model 4.
All versions less than 1.3 are equivalent to Shader Models 2 and 3. Because GLSL is a high-level language, many of the differences between SM 2 and 3 are not exposed to the user.
ARB Assembly Language
These are done through testing the presence of extensions. You should test them in this order:
- GL_NV_gpu_program4: SM 4.0 or better.
- GL_NV_vertex_program3: SM 3.0 or better.
- GL_ARB_fragment_program: SM 2.0 or better.
ATI does not support higher than SM 2.0 functionality in assembly shaders.