mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Use EGL surfaceless platform when windowing system is not found (#2339)
* Use EGL surfaceless platform when windowing system is not found 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 #1551 Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Set backend for capture by environment variables Useful for testing surfaceless Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Check for EGL_MESA_platform_surfaceless extension before using surfaceless platform Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Format Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Unify types for GLES config tiers Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Remove red.png Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Enable GL backend for CI * Bump outliers count for skybox_etc2 due to llvmpipe test (102) * Add SURFACE_TYPE PBUFFER_BIT requirement to off-screen surface tier * Re-nix GL Backend on CI Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
This commit is contained in:
committed by
GitHub
parent
bfcdcd6486
commit
70db03dc99
@@ -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<super::Api> 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::<egl::EGL1_5>()
|
||||
.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)
|
||||
};
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user