OpenGL » Driver workarounds

List of OpenGL driver workarounds used by Magnum.

Driver workarounds used by a particular app are listed in the engine startup log such as here:

Renderer: GeForce GT 740M/PCIe/SSE2 by NVIDIA Corporation
OpenGL version: 4.6.0 NVIDIA 390.25
Using optional features:
Using driver workarounds:

These identifiers correspond to the strings in the below listing. For debugging and diagnostic purpose it's possible to disable particular workarounds by passing their identifier string to the --magnum-disable-workarounds command-line option. See Command-line options for more information.

        #if !defined(MAGNUM_TARGET_GLES) && !defined(CORRADE_TARGET_APPLE)
        /* Creating core context with specific version on AMD and NV
           proprietary drivers on Linux/Windows and Intel drivers on Windows
           causes the context to be forced to given version instead of
           selecting latest available version */

        #if !defined(MAGNUM_TARGET_GLES) && defined(CORRADE_TARGET_WINDOWS)
        /* On Windows Intel drivers ARB_shading_language_420pack is exposed in
           GLSL even though the extension (e.g. binding keyword) is not
           supported */

        #ifndef MAGNUM_TARGET_GLES
        /* Forward-compatible GL contexts on Mesa still report line width range
           as [1, 7], but setting wide line width fails. According to the specs
           the max value on forward compatible contexts should be 1.0, so
           patching it. */

        #if !defined(MAGNUM_TARGET_GLES2) && defined(CORRADE_TARGET_WINDOWS)
        /* On Windows NVidia drivers the glTransformFeedbackVaryings() does not
           make a copy of its char* arguments so it fails at link time when the
           original char arrays are not in scope anymore. Enabling
           *synchronous* debug output circumvents this bug. Can be triggered by
           running TransformFeedbackGLTest with GL_KHR_debug extension
           disabled. */

        #ifndef MAGNUM_TARGET_GLES
        /* Layout qualifier causes compiler error with GLSL 1.20 on Mesa, GLSL
           1.30 on NVidia and 1.40 on macOS. Everything is fine when using
           newer GLSL version. */

        /* NVidia drivers (358.16) report compressed block size from internal
           format query in bits instead of bytes */

        /* NVidia drivers (358.16) report different compressed image size for
           cubemaps based on whether the texture is immutable or not and not
           based on whether I'm querying all faces (ARB_DSA) or a single face
           (non-DSA, EXT_DSA) */

        /* NVidia drivers (358.16) return only the first slice of compressed
           cube map image when querying all six slice using ARB_DSA API */

        /* NVidia drivers return 0 when asked for GL_CONTEXT_PROFILE_MASK,
           so it needs to be worked around by asking for GL_ARB_compatibility */

        /* (Headless) EGL contexts for desktop GL on NVidia 384 and 390 drivers
           don't have correct statically linked GL 1.0 and 1.1 functions (such
           as glGetString()) and one has to retrieve them explicitly using
           eglGetProcAddress(). Doesn't seem to happen on pre-384 and 396, but
           it's not possible to get driver version through EGL, so enabling
           this unconditionally on all EGL NV contexts. */

        #ifndef MAGNUM_TARGET_GLES
        /* SVGA3D (VMware host GL driver) glDrawArrays() draws nothing when the
           vertex buffer memory is initialized using glNamedBufferData() from
           ARB_DSA. Using the non-DSA glBufferData() works. */

        /* SVGA3D does out-of-bound writes in some cases of glGetTexSubImage(),
           leading to memory corruption on client machines. That's nasty, so the
           whole ARB_get_texture_sub_image is disabled. */

        /* SVGA3D has broken handling of glTex[ture][Sub]Image*D() for 1D
           arrays, 2D arrays, 3D textures and cube map textures where it
           uploads just the first slice in the last dimension. This is only
           with copies from host memory, not with buffer images. Seems to be
           fixed in Mesa 13, but I have no such system to verify that on.

        #if defined(CORRADE_TARGET_EMSCRIPTEN) && defined(__EMSCRIPTEN_PTHREADS__)
        /* Shader sources containing UTF-8 characters are converted to empty
           strings when running on Emscripten with -s USE_PTHREADS=1. Working
           around that by replacing all chars > 127 with spaces. Relevant code:

        #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
        /* Empty EGL_CONTEXT_FLAGS_KHR cause SwiftShader to fail
           context creation with EGL_BAD_ATTRIBUTE. Not sending the flags then.
           Relevant code: */

        /* SwiftShader crashes deep inside eglMakeCurrent() when using
           EGL_NO_SURFACE. Supplying a 32x32 PBuffer to work around that. */