From 4e218d3f24466eb25b1173b625f98e81c1f78916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 21 Aug 2019 02:33:19 +0200 Subject: [PATCH] Platform: new nv-egl-forward-compatible-context-unhappy workaround. SIGH. WHY CAN'T WE HAVE NICE THINGS. --- doc/changelog.dox | 5 +++++ src/Magnum/GL/Implementation/driverSpecific.cpp | 6 ++++++ src/Magnum/Platform/WindowlessEglApplication.cpp | 12 ++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 23fd67dfd..a53a38635 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -303,6 +303,11 @@ See also: would assume a zero-sized framebuffer. This behavior is no longer silent but advertised as a @cpp "apitrace-zero-initial-viewport" @ce workaround. See @ref opengl-workarounds for more information. +- Added a @cpp "nv-egl-forward-compatible-context-unhappy" @ce workaround + that removes @ref Platform::WindowlessEglApplication::Configuration::Flag::ForwardCompatible + from flags passed to `eglCreateContext()` as that otherwise causes NVidia + to fail with `EGL_BAD_MATCH`. See @ref opengl-workarounds for more + information. @subsubsection changelog-latest-changes-math Math library diff --git a/src/Magnum/GL/Implementation/driverSpecific.cpp b/src/Magnum/GL/Implementation/driverSpecific.cpp index 8bd9d7025..ee036c895 100644 --- a/src/Magnum/GL/Implementation/driverSpecific.cpp +++ b/src/Magnum/GL/Implementation/driverSpecific.cpp @@ -105,6 +105,12 @@ namespace { possible to get driver version through EGL, so enabling this unconditionally on all EGL NV contexts. */ "nv-egl-incorrect-gl11-function-pointers", + +/* NVidia is unhappy when EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR is + present among attributes passed to eglCreateContext(), blowing up with + EGL_BAD_MATCH. This flag is enabled by default, wiping it away to make the + context creation work. */ +"nv-egl-forward-compatible-context-unhappy", #endif #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Platform/WindowlessEglApplication.cpp b/src/Magnum/Platform/WindowlessEglApplication.cpp index 7cfe81edb..3b3ca5704 100644 --- a/src/Magnum/Platform/WindowlessEglApplication.cpp +++ b/src/Magnum/Platform/WindowlessEglApplication.cpp @@ -169,6 +169,16 @@ WindowlessEglContext::WindowlessEglContext(const Configuration& configuration, G flags |= Configuration::Flag::Debug; #endif + #ifndef MAGNUM_TARGET_GLES + /* NVidia doesn't like EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR for + some reason, failing eglCreateContext() with EGL_BAD_MATCH. If this flag + is set, wipe it away. */ + const char* vendor = eglQueryString(_display, EGL_VENDOR); + if((flags & Configuration::Flag::ForwardCompatible) && vendor && std::strcmp(vendor, "NVIDIA") == 0 && (!magnumContext || !magnumContext->isDriverWorkaroundDisabled("nv-egl-forward-compatible-context-unhappy"))) { + flags &= ~Configuration::Flag::ForwardCompatible; + } + #endif + #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_WEBGL) const /* Is modified below to work around a SwiftShader limitation */ #endif @@ -197,8 +207,6 @@ WindowlessEglContext::WindowlessEglContext(const Configuration& configuration, G #ifdef MAGNUM_TARGET_WEBGL static_cast(configuration); - #endif - #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_WEBGL) static_cast(magnumContext); #endif