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

Properly support Wayland under EGL and Vulkan. #3358

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

mcourteaux
Copy link
Contributor

So, this fixes what #1679 should have done in the first place.

Summary:

  • The creation of a wl_egl_window is only necessary when working with OpenGL. Creating that under Vulkan is plain wrong.
  • In this PR, the EGL context now creates this wl_egl_window when the NativeWindowHandleType is set to Wayland.
  • This PR reverts the hack in the Vulkan renderer which extracts the original wl_surface out of an otherwise-unused wl_egl_surface.
  • This PR adds the window-resize glue code required to keep properly rendering, when EGL is using a Wayland window.
  • These changes clean up and unify the initialization of bgfx in terms of setting the ndh and nwh in bgfx::PlatformData.

This PR was constructed after a lot of reading and carefully examining what exactly SDL2 does when you ask it to create the GL context.

Tested these changes with:

  • examples with SDL entry, using GL and Vulkan
  • examples with glfw3 entry, using GL and Vulkan
  • SilverNode, using GL and Vulkan.

}
return (void*)(uintptr_t)win_impl;
struct wl_surface* surface = (struct wl_surface*)glfwGetWaylandWindow(_window);
return (void*)surface;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code there was added by @BlockoS, and it looks like he had some reason why it was more complex than just glfwGetWaylandWindow.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see below you moved that code in EGL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the main reason it should be in EGL is to link it up with the resizing events that need to get forwarded to wl_egl_window_resize.

@bkaradzic bkaradzic merged commit 3303b45 into bkaradzic:master Oct 1, 2024
11 checks passed
@mcourteaux
Copy link
Contributor Author

Long term, I think we should dlopen() libwayland-egl, to prevent a hard dependency on it for simply starting the application.

@bkaradzic
Copy link
Owner

I like that idea. PR is pre-approved. :)

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

Successfully merging this pull request may close these issues.

2 participants