Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test buffer contents on GLES3 & WebGL, fix global symbol duplication in GL test libraries #565

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mosra
Copy link
Owner

@mosra mosra commented May 25, 2022

Split off of #560, because it uncovered a deeper problem in how *TestLib libraries are built.

  • FooTestLib is mostly the same as Foo, except that it has CORRADE_GRACEFUL_ASSERT defined in order to be able to test assertion messages -- then an assert won't abort, but instead gracefully return, allowing the message to be captured.
  • MagnumGL has a global "current context" pointer, and then there's MagnumGLTestLib which has also a global "current context" pointer. To avoid having two copies of the same, a GL test should then link to either one or the other and never both.
  • To avoid duplication, there's also MagnumOpenGLTesterTestLib, which links to MagnumGLTestLib instead of MagnumGL. Unfortunately it does so only on Windows, which has to be fixed.
  • And because we're now using DebugTools::bufferData() to query buffer contents, there also needs to be (a subset of) DebugTools that links to MagnumGLTestLib instead of MagnumGL.

Things to do:

  • Test buffer contents on GLES3 (fix all cases of /** @todo How to verify the contents in ES? */)
  • Make MagnumOpenGLTesterTestLib link against MagnumGLTestLib everywhere, not just on Windows
  • Make a MagnumDebugToolsGLTestLibSubset linking to MagnumGLTestLib
    • Remove now-outdated info from the commit message

pezcode and others added 2 commits May 25, 2022 09:09
If a GL test library would link to MagnumOpenGLTesterTestLib (which has
CORRADE_GRACEFUL_ASSERT enabled to be able to verify assertions) and
then to MagnumDebugTools for DebugTools::bufferData(), it'd mean there's
one GL::Context global from MagnumGLTestLib and one from MagnumGL. Then,
depending on whatever random order the linker uses, different parts of
the library would see a different global, ultimately leading to a
dreaded

     GL::Context::current(): no current context

assertion. Right now this only manifested on the macOS static CI build,
but depending on a phase of the moon could happen for any platform in
any circumstance.

First attempt was to switch to linking to MagnumDebugToolsTestLib and
then making MagnumDebugToolsTestLib depend on MagnumGLTestLib instead of
MagnumGL, HOWEVER because DebugTools also depend on Primitives and
Shaders and whatnot for some features, it just moved the conflict
between MagnumGL and MagnumGLTestLib elsewhere -- and ASan started
loudly complaining about GL::defaultFramebuffer being duplicated.

So instead there's now a dedicated subset of DebugTools just for the GL
test themselves, containing currently just DebugTools::bufferData(), as
nothing else is needed ATM. It may grow further when needed, such as
with textureImage(), or CompareImage, etc.

But of course that wouldn't be enough -- MagnumOpenGLTesterTestLib
actually still links to MagnumGL for Other Reasons, meaning we have to
pass it last to prefer symbols from MagnumGLTestLib which have graceful
asserts enabled. Hopefully this works well enough, otherwise I'd have to
figure out yet another variant of the fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: TODO
Development

Successfully merging this pull request may close these issues.

2 participants