Skip to content

Bevy 0.19 on WSL2: GL backend detects NVIDIA D3D12 adapter, then panics with PresentMode options [] #24756

Description

@webbiscuit

I am trying to run a minimal Bevy 0.19 app under WSL2/WSLg on a Windows 11 laptop with an NVIDIA RTX 5070 Ti Laptop GPU.

By default, Bevy selects llvmpipe via Vulkan. After enabling the GL backend and forcing Mesa’s D3D12 adapter selection, Bevy correctly detects the NVIDIA GPU through Mesa/D3D12, but then panics when choosing a present mode.

The panic is:

internal error: entered unreachable code: Fallback system failed to choose present mode. This is a bug. Mode: AutoNoVsync, Options: []

Environment
OS: Linux (Ubuntu 22.04) under WSL2
Kernel: 6.18.33.1-microsoft-standard-WSL2
CPU: Intel Core Ultra 9 275HX
GPU: NVIDIA GeForce RTX 5070 Ti Laptop GPU
Bevy: 0.19.0
wgpu: 29.0.3
Windows: Windows 11

WSL version info:

WSL version: 2.7.8.0
Kernel version: 6.18.33.1-1
WSLg version: 1.0.73.2
MSRDC version: 1.2.6676
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.26200.8655
Baseline behaviour

Without any override, Bevy starts using Vulkan but selects llvmpipe:

AdapterInfo {
name: "llvmpipe (LLVM 15.0.7, 256 bits)",
vendor: 65541,
device: 0,
device_type: Cpu,
driver: "llvmpipe",
driver_info: "Mesa 23.2.1-1ubuntu3.1~22.04.4 (LLVM 15.0.7)",
backend: Vulkan,
}

Bevy then warns:

The selected adapter is using a driver that only supports software rendering.
WSLg / Mesa GPU selection

nvidia-smi works inside WSL, and /dev/dxg exists.

Initially, glxinfo -B also reported llvmpipe. Setting the following fixed OpenGL acceleration:

export MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA

After that:

glxinfo -B

reports:

Vendor: Microsoft Corporation
Device: D3D12 (NVIDIA GeForce RTX 5070 Ti Laptop GPU)
Accelerated: yes
OpenGL renderer string: D3D12 (NVIDIA GeForce RTX 5070 Ti Laptop GPU)
OpenGL core profile version string: 4.2 (Core Profile) Mesa 23.2.1-1ubuntu3.1~22.04.4
Minimal Bevy setup

Cargo.toml:

[package]
name = "example"
version = "0.1.0"
edition = "2024"

[dependencies]
bevy = { version = "0.19", default-features = false, features = ["2d", "ui", "x11"] }
bevy_render = { version = "0.19", features = ["gles"] }
log = { version = "0.4", features = ["max_level_debug", "release_max_level_warn"] }

main.rs:

use bevy::prelude::*;
use bevy::render::{
    RenderPlugin,
    settings::{Backends, WgpuSettings},
};
use bevy::window::{PresentMode, WindowPlugin};

fn main() {
    App::new()
        .add_plugins(
            DefaultPlugins
                .set(RenderPlugin {
                    render_creation: WgpuSettings {
                        backends: Some(Backends::GL),
                        ..default()
                    }
                    .into(),
                    ..default()
                })
                .set(WindowPlugin {
                    primary_window: Some(Window {
                        title: "microworld".into(),
                        present_mode: PresentMode::AutoNoVsync,
                        ..default()
                    }),
                    ..default()
                }),
        )
        .run();
}

Run command:

MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA cargo run

I also tried:

MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA WINIT_UNIX_BACKEND=x11 cargo run

and different present modes including AutoVsync, AutoNoVsync, and default settings.

Result

Bevy successfully detects the NVIDIA/D3D12 adapter via the GL backend:

AdapterInfo {
name: "D3D12 (NVIDIA GeForce RTX 5070 Ti Laptop GPU)",
vendor: 0,
device: 0,
device_type: Other,
device_pci_bus_id: "",
driver: "",
driver_info: "4.2 (Core Profile) Mesa 23.2.1-1ubuntu3.1~22.04.4",
backend: Gl,
subgroup_min_size: 4,
subgroup_max_size: 128,
transient_saves_memory: false,
}

Then it panics:

thread 'Compute Task Pool (12)' panicked at /home/dan/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_render-0.19.0/src/view/window/mod.rs:502:13:
internal error: entered unreachable code: Fallback system failed to choose present mode. This is a bug. Mode: AutoNoVsync, Options: []

With AutoVsync, the same issue occurs:

internal error: entered unreachable code: Fallback system failed to choose present mode. This is a bug. Mode: AutoVsync, Options: []
Additional log line

This appears before the adapter is detected:

ERROR wgpu_hal::gles::egl: EGL 'eglInitialize' code 0x3001: DRI2: failed to load driver

Despite that, Bevy does then report the GL adapter as:

D3D12 (NVIDIA GeForce RTX 5070 Ti Laptop GPU)

Expected behaviour

Bevy should create the window successfully using the GL backend and the Mesa D3D12 adapter

The current panic suggests Bevy receives an empty present mode list and then hits an unreachable!() path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behaviorS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Needs SME Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions