diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 2e55bbf47c..c660c0648b 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -15,6 +15,7 @@ const EGL_PLATFORM_X11_KHR: u32 = 0x31D5; const EGL_PLATFORM_ANGLE_ANGLE: u32 = 0x3202; const EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE: u32 = 0x348F; const EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED: u32 = 0x3451; +const EGL_PLATFORM_SURFACELESS_MESA: u32 = 0x31DD; const EGL_GL_COLORSPACE_KHR: u32 = 0x309D; const EGL_GL_COLORSPACE_SRGB_KHR: u32 = 0x3089; @@ -168,11 +169,19 @@ fn choose_config( let tiers = [ ( "off-screen", - &[egl::RENDERABLE_TYPE, egl::OPENGL_ES2_BIT][..], + &[ + egl::SURFACE_TYPE, + egl::PBUFFER_BIT, + egl::RENDERABLE_TYPE, + egl::OPENGL_ES2_BIT, + ][..], ), - ("presentation", &[egl::SURFACE_TYPE, egl::WINDOW_BIT]), + ("presentation", &[egl::SURFACE_TYPE, egl::WINDOW_BIT][..]), #[cfg(not(target_os = "android"))] - ("native-render", &[egl::NATIVE_RENDERABLE, egl::TRUE as _]), + ( + "native-render", + &[egl::NATIVE_RENDERABLE, egl::TRUE as _][..], + ), ]; let mut attributes = Vec::with_capacity(9); @@ -666,8 +675,21 @@ impl crate::Instance for Instance { ) .unwrap(); (display, Some(Arc::new(library)), WindowKind::AngleX11) + } else if client_ext_str.contains("EGL_MESA_platform_surfaceless") { + log::info!("No windowing system present. Using surfaceless platform"); + let egl = egl + .upcast::() + .expect("Failed to get EGL 1.5 for surfaceless"); + let display = egl + .get_platform_display( + EGL_PLATFORM_SURFACELESS_MESA, + std::ptr::null_mut(), + &[egl::ATTRIB_NONE], + ) + .unwrap(); + (display, None, WindowKind::Unknown) } else { - log::info!("Using default platform"); + log::info!("EGL_MESA_platform_surfaceless not available. Using default platform"); let display = egl.get_display(egl::DEFAULT_DISPLAY).unwrap(); (display, None, WindowKind::Unknown) }; diff --git a/wgpu/examples/capture/main.rs b/wgpu/examples/capture/main.rs index cbf106c324..2f4b2a56a5 100644 --- a/wgpu/examples/capture/main.rs +++ b/wgpu/examples/capture/main.rs @@ -28,10 +28,12 @@ async fn create_red_image_with_dimensions( width: usize, height: usize, ) -> (Device, Buffer, BufferDimensions) { - let adapter = wgpu::Instance::new(wgpu::Backends::all()) - .request_adapter(&wgpu::RequestAdapterOptions::default()) - .await - .unwrap(); + let adapter = wgpu::Instance::new( + wgpu::util::backend_bits_from_env().unwrap_or_else(wgpu::Backends::all), + ) + .request_adapter(&wgpu::RequestAdapterOptions::default()) + .await + .unwrap(); let (device, queue) = adapter .request_device( diff --git a/wgpu/examples/skybox/main.rs b/wgpu/examples/skybox/main.rs index fa3c7d8653..a1608227cf 100644 --- a/wgpu/examples/skybox/main.rs +++ b/wgpu/examples/skybox/main.rs @@ -505,7 +505,7 @@ fn skybox_etc2() { optional_features: wgpu::Features::TEXTURE_COMPRESSION_ETC2, base_test_parameters: framework::test_common::TestParameters::default(), tolerance: 5, - max_outliers: 100, // Bounded by llvmpipe + max_outliers: 105, // Bounded by llvmpipe }); }