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

EGL backend changes the current context behind app's back #2928

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Closed

EGL backend changes the current context behind app's back #2928

SDLBugzilla opened this issue Feb 11, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.1
Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2018-06-14 06:12:12 +0000, Tomeu Vizoso wrote:

Created attachment 3261
fix

SDL_EGL_DeleteContext calls SDL_EGL_MakeCurrent(_this, NULL, NULL); right before calling eglDestroyContext.

If the context to be destroyed isn't the current one, any context tracking that the app is doing will be broken.

If the context to be destroyed is the current one, SDL_GL_DeleteContext will have unset it already.

This patch brings the behavior of the EGL backend in line with the one in the GLX one.

On 2018-06-15 03:36:22 +0000, Sam Lantinga wrote:

The context needs to no longer be current:
If the EGL rendering context context is not current to any thread, eglDestroyContext destroys it immediately. Otherwise, context is destroyed when it becomes not current to any thread.

The GLX code does the same thing:
_this->gl_data->glXMakeCurrent(display, None, NULL);
_this->gl_data->glXDestroyContext(display, context);

If there's a way to tell whether the context is current, that would be the right thing to do.

On 2018-06-15 04:53:16 +0000, Tomeu Vizoso wrote:

(In reply to Sam Lantinga from comment # 1)

The context needs to no longer be current:
If the EGL rendering context context is not current to any thread,
eglDestroyContext destroys it immediately. Otherwise, context is destroyed
when it becomes not current to any thread.

The GLX code does the same thing:
_this->gl_data->glXMakeCurrent(display, None, NULL);
_this->gl_data->glXDestroyContext(display, context);

I see that in X11_GL_InitExtensions, but not in X11_GL_DeleteContext.

If there's a way to tell whether the context is current, that would be the
right thing to do.

SDL_GL_DeleteContext already takes care of that:

if (SDL_GL_GetCurrentContext() == context) {
    SDL_GL_MakeCurrent(NULL, NULL);
}

_this->GL_DeleteContext(_this, context);

On 2018-06-25 05:48:39 +0000, Ryan C. Gordon wrote:

Tomeu is right, this patch is now https://hg.libsdl.org/SDL/rev/8aa5a79c8805

Thanks!

--ryan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant