Browse Source

GL: harden extension list tests.

This uncovers a few important issues, yay!
pull/370/head
Vladimír Vondruš 7 years ago
parent
commit
742aec665d
  1. 40
      src/Magnum/GL/Test/ContextTest.cpp

40
src/Magnum/GL/Test/ContextTest.cpp

@ -23,6 +23,7 @@
DEALINGS IN THE SOFTWARE.
*/
#include <set>
#include <sstream>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h>
@ -95,7 +96,11 @@ void ContextTest::makeCurrentNoOp() {
void ContextTest::extensions() {
const char* used[GL::Implementation::ExtensionCount]{};
/* Check that all extension indices are unique */
std::set<std::string> unique;
/* Check that all extension indices are unique, are in correct lists, are
not compiled on versions that shouldn't have them, are listed just once
etc. */
for(Version version: {
#ifndef MAGNUM_TARGET_GLES
Version::GL300,
@ -133,6 +138,39 @@ void ContextTest::extensions() {
}
used[e.index()] = e.string();
if(!unique.insert(e.string()).second) {
Error{} << "Extension" << e.string() << "listed more than once";
CORRADE_VERIFY(false);
}
CORRADE_VERIFY(Int(e.coreVersion()) >= Int(e.requiredVersion()));
if(e.coreVersion() != version
#if defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)
/* These two are replaced by EXT_color_buffer_float for 2.0,
but aren't core in WebGL 2 */
&& e.index() != Extensions::EXT::color_buffer_half_float::Index
&& e.index() != Extensions::WEBGL::color_buffer_float::Index
#endif
) {
Error{} << "Extension" << e.string() << "should have core version"
<< version << "but has" << e.coreVersion();
CORRADE_VERIFY(false);
}
#ifdef MAGNUM_TARGET_GLES2
if(e.requiredVersion() != Version::GLES200) {
Error{} << "Extension" << e.string() << "should have required version"
<< Version::GLES200 << "but has" << e.requiredVersion();
CORRADE_VERIFY(false);
}
#endif
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2)
if(e.coreVersion() == Version::GLES300) {
Error{} << "Extension" << e.string() << "has core version" << e.coreVersion() << "on a GLES3 build -- it shouldn't be present at all";
CORRADE_VERIFY(false);
}
#endif
}
}

Loading…
Cancel
Save