On current SDL2 compiled from source code, on OSX only, I’m running into a weird problem, possibly only in OSX Mojave (I don’t have a non-Mojave OSX machine to test on, and Windows and Linux builds are fine)
What I’m seeing looks for all the world like a simple low frame rate; as if my game was running at perhaps 5-10fps. But my frame timings show that I’m running at almost 60fps on my test machine; it’s just that most of those frames aren’t making it to the screen? If I glReadPixels() back the pixels, I can capture frames that were never visibly displayed on the window.
It could well be a problem in my code. I haven’t yet set up a minimal test case to try to track down the issue, and that’s probably my next step. But I figured I’d ask around first, to see if anybody had any immediate ideas about issues I might be hitting.
The big unusual thing in my codebase: I have two shared OpenGL contexts. One is used for rendering, the other is used for loading data into the shared context from a background thread.
At some point since updating to Mojave, rendering to the window started to fail utterly; I was left with a completely empty window. Previously, I did this:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
g_sdlWindow = SDL_CreateWindow("", x, y, width, height, videoFlags);
m_sdlGlContext = SDL_GL_CreateContext(g_sdlWindow);
if ( !m_sdlGlContext )
{
vsLog("Failed to create OpenGL context??");
exit(1);
}
m_loadingGlContext = SDL_GL_CreateContext(g_sdlWindow);
if ( !m_loadingGlContext )
{
vsLog("Failed to create OpenGL context for loading??");
exit(1);
}
SDL_GL_MakeCurrent( g_sdlWindow, m_sdlGlContext ); // set back to the main context
With this code, none of my drawing would reach the screen ever.
If I switched things around so that I created the loading context first, and then the regular sdl context later, so that I didn’t have to call SDL_GL_MakeCurrent() that one time, then everything worked fine.
I’m… kind of hoping that this weirdness with the call to SDL_GL_MakeCurrent() resulting in no output to the window ever might be a thread to pull on which leads to the weird “rendered OpenGL framebuffer doesn’t make it to the screen most of the time” problem? Interested in whether all this means anything to anybody else, or suggests an avenue I might investigate. Again, I’m on absolute latest SDL code from the repository; am entirely happy to go hacking on the code itself.