Skip to content

Commit

Permalink
egl/display: workaround gbm platforms on EGL 1.4
Browse files Browse the repository at this point in the history
Some EGL drivers report the KHR extension with EGL 1.4, which doesn't
make any sense, however given that the constant for MESA and KHR is the
same, we can check for KHR in MESA branch, but still use the Ext
functions.

Fixes #1708.
  • Loading branch information
kchibisov committed Nov 12, 2024
1 parent d5edc13 commit 36770ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Added `NotCurrentContext::make_current_surfaceless(self)` and
`PossiblyCurrentContext::make_current_surfaceless(&self)` in the `Wgl`
implementation to allow the use of surfaceless contexts with WGL.
- Added workaround for EGL drivers reporting KHR_platform_gbm with EGL 1.4.


# Version 0.32.1
Expand Down
13 changes: 12 additions & 1 deletion glutin/src/api/egl/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,18 @@ impl Display {
handle.connection.map_or(egl::DEFAULT_DISPLAY as *mut _, |c| c.as_ptr()),
)
},
RawDisplayHandle::Gbm(handle) if extensions.contains("EGL_MESA_platform_gbm") => {
RawDisplayHandle::Gbm(handle)
// NOTE: Some drivers report that they support KHR extension with 1.4 EGL display, so
// workaround here by checking the KHR gbm display as well. The MESA and KHR has
// the same constant values, thus it'll work regardless.
//
// They do require EXT during the runtime as well, so we don't change the display
// to Khr here.
//
// See https://github.com/rust-windowing/glutin/issues/1708.
if extensions.contains("EGL_MESA_platform_gbm")
|| extensions.contains("EGL_KHR_platform_gbm") =>
{
(egl::PLATFORM_GBM_MESA, handle.gbm_device.as_ptr())
},
RawDisplayHandle::Drm(_) => {
Expand Down

0 comments on commit 36770ad

Please sign in to comment.