Browse Source

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.
pull/118/head
Vladimír Vondruš 11 years ago
parent
commit
81f227bae1
  1. 13
      src/Magnum/Platform/Sdl2Application.cpp
  2. 16
      src/Magnum/Platform/WindowlessGlxApplication.cpp

13
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<const char*>(glGetString(GL_VENDOR)), nvidiaVendorString, sizeof(nvidiaVendorString)) == 0
/* Sorry about the UGLY code, HOPEFULLY THERE WON'T BE MORE WORKAROUNDS */
|| (vendorString = reinterpret_cast<const char*>(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

16
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<const char*>(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<const char*>(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

Loading…
Cancel
Save