Skip to content

Commit

Permalink
Use EGL surfaceless platform when windowing system is not found
Browse files Browse the repository at this point in the history
Falling back to egl::DEFAULT_DISPLAY usually results in X11 EGL platform being picked and then rejected because of unavailability on a head/GPU-less system. EGL_PLATFORM_SURFACELESS_MESA works with both radeonsi and llvmpipe/swrast when Xorg/Wayland sockets are being hidden from application. Needs to be tested in a truly GPU-less environment such as CI it is required to run in. Addresses gfx-rs#1551

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>
  • Loading branch information
dsseng committed Dec 31, 2021
1 parent a1251dc commit b7151c6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ fn choose_config(
) -> Result<(egl::Config, bool), crate::InstanceError> {
//TODO: EGL_SLOW_CONFIG
let tiers = [
("surfaceless", &[egl::SURFACE_TYPE, egl::PBUFFER_BIT][..]),
(
"off-screen",
&[egl::RENDERABLE_TYPE, egl::OPENGL_ES2_BIT][..],
Expand Down Expand Up @@ -618,8 +619,13 @@ impl crate::Instance<super::Api> for Instance {
.unwrap();
(display, Some(Arc::new(library)), WindowKind::AngleX11)
} else {
log::info!("Using default platform");
let display = egl.get_display(egl::DEFAULT_DISPLAY).unwrap();
log::info!("No windowing system present. Using surfaceless platform");
let egl = egl
.upcast::<egl::EGL1_5>()
.expect("Failed to get EGL 1.5 for surfaceless");
let display = egl
.get_platform_display(0x31DD, std::ptr::null_mut(), &[egl::ATTRIB_NONE]) // EGL_PLATFORM_SURFACELESS_MESA
.unwrap();
(display, None, WindowKind::Unknown)
};

Expand Down

0 comments on commit b7151c6

Please sign in to comment.