No reasonable way to clean up from some classes of errors
Consider this change to mesa's libglvnd branch, in particular the XXX bits:
It's a valid point! If adding the map fails we should destroy the context, but I don't see a sane way to do that. The obvious way would be dd->staticDispatch.destroyContext(dpy, ctx)
, but that fails, because staticDispatch is opaque to the vendor library. __GLXapiExportsRec doesn't give you any way to look up a function other than by index, and there's no index for DestroyContext.
It doesn't work to call glXGetProcAddress
for this, precisely because adding the map failed: the top-level dispatch for glXDestroyContext
would have no idea which vendor to dispatch to, because the context wouldn't be recorded in the map. You have to dispatch directly back to the same vendor that just created the context.