Fix GLES/EGL surface creation on older Mesa (Linux)#331
Open
guillaug wants to merge 1 commit into
Open
Conversation
Three issues prevented the GLES backend from working on Linux with older Mesa (tested: 21.2.6, Intel UHD, Vulkan 1.2 only): 1. EGL platform selection preferred surfaceless over native X11/Wayland, making window surface creation impossible (BadNativeWindow). Now tries Wayland (when WAYLAND_DISPLAY is set), then X11, then surfaceless as last resort. 2. XCB window ID was passed as a pointer instead of the raw XID value, causing BadAlloc in eglCreateWindowSurface. 3. EGL_SINGLE_BUFFER is rejected by some Mesa drivers with BadAlloc. Switch to BACK_BUFFER unconditionally.
kvark
reviewed
Apr 13, 2026
Owner
kvark
left a comment
There was a problem hiding this comment.
Nice work! A few suggestions to improve
| } else if let Some(egl1_5) = egl.upcast::<egl::EGL1_5>() { | ||
| if let Some(state) = try_create_gbm_display(egl1_5, &client_extensions) { | ||
| (state.0, Some(state.1)) | ||
| } else if std::env::var("WAYLAND_DISPLAY").is_ok() |
Owner
There was a problem hiding this comment.
Let's check X11 before wayland, otherwise this would potentially fail on XWayland.
Perhaps don't check wayland at all? If you are running wayland, chances are your platform already supports EGL-1.5
| temp_xcb_handle = handle.window; | ||
| &mut temp_xcb_handle as *mut _ as *mut ffi::c_void | ||
| } | ||
| Rwh::Xcb(handle) => handle.window.get() as usize as *mut ffi::c_void, |
| } else { | ||
| egl::SINGLE_BUFFER | ||
| }, | ||
| // Use BACK_BUFFER unconditionally: some Mesa drivers reject |
Owner
There was a problem hiding this comment.
I don't want to use BACK_BUFFER pessimistically on the main path where DMA-BUF is in effect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
first (when
WAYLAND_DISPLAYis set), then X11, then surfacelessas last resort
eglCreateWindowSurfaceEGL_BACK_BUFFERunconditionally — some Mesa drivers rejectEGL_SINGLE_BUFFERwithBadAllocTested on Debian Bullseye, Mesa 21.2.6, Intel UHD.
Fixes #330
Co-authored with Claude Code (Opus 4.6).