From 81f227bae1c2c6686759053ad31687a208d158b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 2 Nov 2015 23:35:02 +0100 Subject: [PATCH] Platform: do the core context workaround also for AMD. AMD is behaving the same as NVidia (at least on Windows) -- when creating core context with minimum specified version set to 3.1, it forces that version instead of going with the largest available version, which, again, is pretty useless behavior. Enabling that on both Linux and Windows, the behavior is confirmed on Windows but I bet it's doing the same on Linux. --- src/Magnum/Platform/Sdl2Application.cpp | 13 ++++++++++--- src/Magnum/Platform/WindowlessGlxApplication.cpp | 16 ++++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index 8cf2ce093..ddd286dfe 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -176,13 +176,20 @@ bool Sdl2Application::tryCreateContext(const Configuration& configuration) { #ifndef MAGNUM_TARGET_GLES /* Fall back to (forward compatible) GL 2.1, if version is not user-specified and either core context creation fails or we are on - binary NVidia drivers on Linux/Windows. NVidia, instead of creating - forward-compatible context with highest available version, forces the + binary NVidia/AMD drivers on Linux/Windows. Instead of creating forward- + compatible context with highest available version, they force the version to the one specified, which is completely useless behavior. */ + #ifndef CORRADE_TARGET_APPLE constexpr static const char nvidiaVendorString[] = "NVIDIA Corporation"; + constexpr static const char amdVendorString[] = "ATI Technologies Inc."; + const char* vendorString; + #endif if(configuration.version() == Version::None && (!_glContext #ifndef CORRADE_TARGET_APPLE - || std::strncmp(reinterpret_cast(glGetString(GL_VENDOR)), nvidiaVendorString, sizeof(nvidiaVendorString)) == 0 + /* Sorry about the UGLY code, HOPEFULLY THERE WON'T BE MORE WORKAROUNDS */ + || (vendorString = reinterpret_cast(glGetString(GL_VENDOR)), + (std::strncmp(vendorString, nvidiaVendorString, sizeof(nvidiaVendorString)) == 0 || + std::strncmp(vendorString, amdVendorString, sizeof(amdVendorString)) == 0)) #endif )) { /* Don't print any warning when doing the NV workaround, because the diff --git a/src/Magnum/Platform/WindowlessGlxApplication.cpp b/src/Magnum/Platform/WindowlessGlxApplication.cpp index 0155e91d2..1ebaa0c3b 100644 --- a/src/Magnum/Platform/WindowlessGlxApplication.cpp +++ b/src/Magnum/Platform/WindowlessGlxApplication.cpp @@ -109,14 +109,22 @@ bool WindowlessGlxApplication::tryCreateContext(const Configuration&) { #ifndef MAGNUM_TARGET_GLES /* Fall back to (forward compatible) GL 2.1, if version is not user-specified and either core context creation fails or we are on - binary NVidia drivers on Linux. NVidia, instead of creating - forward-compatible context with highest available version, forces the + binary NVidia/AMD drivers on Linux/Windows. Instead of creating forward- + compatible context with highest available version, they force the version to the one specified, which is completely useless behavior. */ + #ifndef CORRADE_TARGET_APPLE constexpr static const char nvidiaVendorString[] = "NVIDIA Corporation"; + constexpr static const char amdVendorString[] = "ATI Technologies Inc."; + const char* vendorString; + #endif if(!_glContext #ifndef CORRADE_TARGET_APPLE - /* We need to make the context current first, sorry about the ugly code */ - || (glXMakeContextCurrent(_display, _pbuffer, _pbuffer, _glContext) && std::strncmp(reinterpret_cast(glGetString(GL_VENDOR)), nvidiaVendorString, sizeof(nvidiaVendorString)) == 0) + /* We need to make the context current first, sorry about the UGLY code + and HOPEFULLY THERE WON'T BE MORE WORKAROUNDS */ + || (glXMakeContextCurrent(_display, _pbuffer, _pbuffer, _glContext) && + (vendorString = reinterpret_cast(glGetString(GL_VENDOR)), + (std::strncmp(vendorString, nvidiaVendorString, sizeof(nvidiaVendorString)) == 0 || + std::strncmp(vendorString, amdVendorString, sizeof(amdVendorString)) == 0))) #endif ) { /* Don't print any warning when doing the NV workaround, because the