wgpu
wgpu copied to clipboard
Error in Surface::configure: invalid surface
Description The open GL Backend fails to create a surface. Here is the code in question.
let size = window.inner_size();
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::Backends::GL);
// let instance = wgpu::Instance::new(wgpu::Backends::all());
let surface = unsafe { instance.create_surface(window) };
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::default(),
compatible_surface: Some(&surface),
force_fallback_adapter: false,
})
.await
.unwrap();
let (device, queue) = adapter
.request_device(
&wgpu::DeviceDescriptor {
label: None,
features: wgpu::Features::empty(),
// WebGL doesn't support all of wgpu's features, so if
// we're building for the web we'll have to disable some.
limits: if cfg!(target_arch = "wasm32") {
wgpu::Limits::downlevel_webgl2_defaults()
} else {
wgpu::Limits::default()
},
},
Some(&std::path::Path::new("trace")), // Trace path
// None,
)
.await
.unwrap();
let config = wgpu::SurfaceConfiguration {
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
format: surface.get_preferred_format(&adapter).unwrap(),
width: size.width,
height: size.height,
present_mode: wgpu::PresentMode::Fifo,
};
surface.configure(&device, &config);
Repro steps
You need to be on the v0.12 branch.
Here is a trace.ron
that replicates the issue.
[
Init(
desc: (
label: None,
features: 0,
limits: (
maxTextureDimension1d: 8192,
maxTextureDimension2d: 8192,
maxTextureDimension3d: 2048,
maxTextureArrayLayers: 256,
maxBindGroups: 4,
maxDynamicUniformBuffersPerPipelineLayout: 8,
maxDynamicStorageBuffersPerPipelineLayout: 4,
maxSampledTexturesPerShaderStage: 16,
maxSamplersPerShaderStage: 16,
maxStorageBuffersPerShaderStage: 8,
maxStorageTexturesPerShaderStage: 8,
maxUniformBuffersPerShaderStage: 12,
maxUniformBufferBindingSize: 65536,
maxStorageBufferBindingSize: 134217728,
maxVertexBuffers: 8,
maxVertexAttributes: 16,
maxVertexBufferArrayStride: 2048,
maxPushConstantSize: 0,
minUniformBufferOffsetAlignment: 256,
minStorageBufferOffsetAlignment: 256,
maxInterStageShaderComponents: 60,
maxComputeWorkgroupStorageSize: 16352,
maxComputeInvocationsPerWorkgroup: 256,
maxComputeWorkgroupSizeX: 256,
maxComputeWorkgroupSizeY: 256,
maxComputeWorkgroupSizeZ: 64,
maxComputeWorkgroupsPerDimension: 65535,
),
),
backend: Gl,
),
ConfigureSurface(Id(0, 1, Empty), (
usage: 16,
format: r#bgra8unorm-srgb,
width: 800,
height: 600,
present_mode: Fifo,
)),
]
Expected vs observed behavior WGPU should create a surface using the GL backend
Extra materials
Running the trace with RUST_LOG=INFO
:
RUST_LOG=INFO cargo run -p player --features winit -- ../learn-wgpu/trace/
Finished dev [unoptimized + debuginfo] target(s) in 0.05s
Running `target/debug/play ../learn-wgpu/trace/`
[2022-02-26T18:45:47Z INFO play] Loading trace '"../learn-wgpu/trace/"'
[2022-02-26T18:45:47Z INFO play] Found 2 actions
[2022-02-26T18:45:47Z INFO play] Creating a window
[2022-02-26T18:45:47Z INFO winit::platform_impl::platform::x11::window] Guessed window scale factor: 1
[2022-02-26T18:45:47Z WARN wgpu_hal::vulkan::instance] Unable to find layer: VK_LAYER_KHRONOS_validation
[2022-02-26T18:45:47Z INFO wgpu_hal::vulkan::instance] Instance version: 0x4020a2
[2022-02-26T18:45:47Z INFO wgpu_hal::vulkan::instance] Enabling debug utils
[2022-02-26T18:45:47Z INFO wgpu_hal::vulkan::instance] Enabling device properties2
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::egl] Loading Wayland library to get the current display
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::egl] Loading X11 library to get the current display
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::egl] Using default platform
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::egl] Enabling EGL debug output
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::egl] Display vendor "Mesa Project", version (1, 5)
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::egl] EGL surface: +srgb
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::egl] Trying native-render
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::egl] EGL context: +debug
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::egl] EGL context: +robust access
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::egl] EGL context: +surfaceless
[2022-02-26T18:45:47Z INFO play] Initializing the device for backend: Gl
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::egl] Max label length: 256
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::egl] Enabling GLES debug output
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::adapter] Vendor: AMD
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::adapter] Renderer: AMD RENOIR (DRM 3.42.0, 5.15.5-76051505-generic, LLVM 12.0.1)
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::adapter] Version: OpenGL ES 3.2 Mesa 21.2.2
[2022-02-26T18:45:47Z INFO wgpu_hal::gles::adapter] SL version: OpenGL ES GLSL ES 3.20
[2022-02-26T18:45:47Z INFO wgpu_core::instance] Adapter Gl AdapterInfo { name: "AMD RENOIR (DRM 3.42.0, 5.15.5-76051505-generic, LLVM 12.0.1)", vendor: 4098, device: 0, device_type: DiscreteGpu, backend: Gl }
[2022-02-26T18:45:47Z INFO play] Picked 'AMD RENOIR (DRM 3.42.0, 5.15.5-76051505-generic, LLVM 12.0.1)'
[2022-02-26T18:45:47Z INFO play] Executing actions
[2022-02-26T18:45:47Z INFO play] Configuring the surface
[2022-02-26T18:45:47Z INFO wgpu_core::device] configuring surface with SurfaceConfiguration { usage: RENDER_ATTACHMENT, format: Bgra8UnormSrgb, width: 800, height: 600, present_mode: Fifo }
[2022-02-26T18:45:47Z ERROR wgpu_hal::gles::egl] EGL 'eglCreateWindowSurface' code 0x3003: dri3_surface_create
[2022-02-26T18:45:47Z WARN wgpu_hal::gles::egl] Error in create_window_surface: BadAlloc
thread 'main' panicked at 'InvalidSurface', player/src/bin/play.rs:132:37
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[2022-02-26T18:45:47Z INFO wgpu_core::hub] Dropping Global
[2022-02-26T18:45:47Z INFO wgpu_core::device] Destroying 0 command encoders
Platform Wgpu v0.12 (from crates.io) Pop!_OS 21.10 cargo 1.57.0 (b2e52d7ca 2021-10-21) rustc 1.57.0 (f1edd0429 2021-11-29) rustup 1.24.3 (ce5817a94 2021-05-31)