Fix setting EGL swap interval under native Wayland too (PR #23909)

107 views
Skip to first unread message

VZ

unread,
Sep 27, 2023, 8:45:46 AM9/27/23
to wx-...@googlegroups.com, Subscribed

See #23512.


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/23909

Commit Summary

  • c9bbc7e Check if eglSwapInterval() failed and log a message in this case
  • 6e8fc23 Make Wayland frame callback a wxGLCanvasEGL member function
  • 6475641 Call eglSwapInterval() when it can succeed

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23909@github.com>

VZ

unread,
Sep 30, 2023, 9:25:26 AM9/30/23
to wx-...@googlegroups.com, Subscribed

Merged #23909 into master.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23909/issue_event/10517355996@github.com>

Joan Bruguera

unread,
Oct 27, 2023, 1:32:26 PM10/27/23
to wx-...@googlegroups.com, Subscribed

There's a problem using eglSwapInterval here because it depends on the currently selected EGL context (from wxGLContext::SetCurrent / eglMakeCurrent) and there's no guarantee that the appropriate context is bound inside wxGLCanvasEGL::OnWLFrameCallback(). This may be a problem if the application is using multiple OpenGL contexts (not as strange as one may think since using e.g. wxWebView creates a context).

The failure you observed in #23512 (comment) is probably due to the same reason, the right context was not selected.

This should probably be moved inside wxGLContext::SwapBuffers (like in #23898) since we can be sure that the right context is selected there.

The call to eglSwapInterval


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23909/c1783272214@github.com>

VZ

unread,
Oct 28, 2023, 1:17:42 PM10/28/23
to wx-...@googlegroups.com, Subscribed

There's a problem using eglSwapInterval here because it depends on the currently selected EGL context (from wxGLContext::SetCurrent / eglMakeCurrent) and there's no guarantee that the appropriate context is bound inside wxGLCanvasEGL::OnWLFrameCallback.

Oops.

The failure you observed in #23512 (comment) is probably due to the same reason, the right context was not selected.

If so, it seems like we ought to do this in wxGLContext::SetCurrent()? But I am not sure that it fails because the right context isn't selected: why would it fail for this other context? I.e. I'd understand if it didn't work, in the sense that it didn't change the swap interval, but the function actually failed, with an error.

This should probably be moved inside wxGLContext::SwapBuffers (like in #23898) since we can be sure that the right context is selected there.

But this is what we had started with and it didn't work. I'm not sure if it's because the context wasn't current or some other reason, but I don't know how to make it work there. If you do, please let me know!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23909/c1783874727@github.com>

Joan Bruguera

unread,
Oct 29, 2023, 2:02:40 PM10/29/23
to wx-...@googlegroups.com, Subscribed

The failure you observed in #23512 (comment) is probably due to the same reason, the right context was not selected.

If so, it seems like we ought to do this in wxGLContext::SetCurrent()? But I am not sure that it fails because the right context isn't selected: why would it fail for this other context? I.e. I'd understand if it didn't work, in the sense that it didn't change the swap interval, but the function actually failed, with an error.

This should probably be moved inside wxGLContext::SwapBuffers (like in #23898) since we can be sure that the right context is selected there.

But this is what we had started with and it didn't work. I'm not sure if it's because the context wasn't current or some other reason, but I don't know how to make it work there. If you do, please let me know!

As far as I can see, on Wayland, we never called eglSwapInterval from wxGLContext::SwapBuffers, but rather from wxGLCanvasEGL::CreateSurface. Calling eglSwapInterval from there has be same problem, there's no guarantee that the right EGL context is current. In particular, for simple applications, if you try to call eglSwapInterval from wxGLCanvasEGL::CreateSurface it will fail with error EGL_BAD_CONTEXT because no context has been set yet.

Calling eglSwapInterval from either wxGLContext::SetCurrent and wxGLContext::SwapBuffers should work.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23909/c1784184033@github.com>

VZ

unread,
Oct 29, 2023, 2:47:48 PM10/29/23
to wx-...@googlegroups.com, Subscribed

I thought I tried calling from SwapBuffers() too but maybe you're right and I didn't. Anyhow, it's not difficult to call it from there and it looks preferable to call it from the same place for X11 and Wayland cases anyhow, so I've done it now in #24014.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23909/c1784194942@github.com>

Reply all
Reply to author
Forward
0 new messages