| Summary: | [Patch] SDL_GL_MakeCurrent backend code inefficient in OS X | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Alex Szpakowski <amaranth72> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | minor | ||
| Priority: | P2 | ||
| Version: | HG 2.0 | ||
| Hardware: | x86_64 | ||
| OS: | Mac OS X 10.8 | ||
| Attachments: | Patch to fix SDL_GL_MakeCurrent's OSX performance | ||
The higher-level call, SDL_GL_MakeCurrent(), in SDL/src/video/SDL_video.c, already checks that we're not setting the same context, before calling Cocoa_GL_MakeCurrent(). Are we hitting this performance problem on Mac OS X, despite that? (I've applied the patch, because it's a little extra robustness in any case, but I'm just curious. The patch is now hg changeset b4f6a86e8523, thanks!) --ryan. Well, the higher level check is actually technically wrong, since GL contexts are current on a per-thread basis rather than globally (although that's something to discuss in a separate bug report or mailing list thread, I think. There are several issues that stem from the fact that SDL assumes a context that is made current in one thread is current in all threads.) In any case, since the context can still be made current on a different thread without switching the window its attached to (e.g. by calling SDL_GL_MakeCurrent(NULL, NULL) in one thread, then SDL_GL_MakeCurrent(window, context) in another - which probably should be done when using a single context in multiple threads anyway), the performance of MakeCurrent was still impacted by the unnecessary function calls. Thanks! |
Created attachment 1206 [details] Patch to fix SDL_GL_MakeCurrent's OSX performance The Cocoa / OS X backend code for SDL_GL_MakeCurrent does unnecessary work which makes it *much* (up to orders of magnitude) less performant than it should be. The backend code sets the context's view to the provided window's view without checking whether it's actually different from the context's current view (this is all independent of the actual NSOpenGL MakeCurrent call.) I have attached a patch which fixes the issue.