bevyengine / bevyengine/bevy

Linux with GLES <3.2: Bevy 3D rendering does not work, due to Cubemap Array Textures

Open
#8,789 5 comments 0 reactions 0 assignees View on GitHub
A-Rendering C-Bug D-Modest I-Crash O-Linux
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version

Current main, commit d6d25d8c7871f12681433b5454d52502ecc42457

## Relevant system information

Hardware: Apple M1 Pro, 14in MacBook Pro

OS: Asahi Linux
Drivers: mesa-asahi-edge-23.2.0_pre20230606-1
Kernel: linux-asahi-edge-6.3.asahi7-1

```
AdapterInfo { name: "Apple M1 Pro (G13S C0)", vendor: 65541, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Gl }

SystemInfo { os: "Linux Arch Linux ARM", kernel: "6.3.0-asahi-7-1-edge-ARCH", cpu: "Icestorm-M1-Pro", core_count: "10", memory: "31.0 GiB" }
```

## What you did

Run any bevy 3D example.

```
cargo r --features wayland --example load_gltf
```

(note: wayland is required, see #8788)

## What went wrong

Panic on wgpu error:

```
2023-06-08T09:29:29.451613Z ERROR wgpu_hal::gles::egl: GLES: [API/Error] ID 1 : GL_INVALID_OPERATION in unsupported function called (unsupported extension or deprecated function?)
2023-06-08T09:29:29.451670Z ERROR wgpu_hal::gles::egl: GLES: [API/Error] ID 1 : GL_INVALID_OPERATION in unsupported function called (unsupported extension or deprecated function?)
2023-06-08T09:29:29.539334Z ERROR wgpu::backend::direct: Shader translation error for stage ShaderStages(NONE | VERTEX): The selected version doesn't support CUBE_TEXTURES_ARRAY
2023-06-08T09:29:29.539366Z ERROR wgpu::backend::direct: Please report it to https://github.com/gfx-rs/naga
2023-06-08T09:29:29.539392Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default
thread 'Compute Task Pool (1)' panicked at 'wgpu error: Validation Error

Caused by:
In Device::create_render_pipeline
note: label = `alpha_blend_mesh_pipeline`
Internal error in ShaderStages(NONE | VERTEX) shader: The selected version doesn't support CUBE_TEXTURES_ARRAY

', /home/ida/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.16.1/src/backend/direct.rs:3019:5
```

The panic occurs on the frame when the first 3D entity is spawned, as that is when Bevy attempts to create the Render Pipeline via the Pipeline Cache. If running the `load_gltf` example, we can see that the app runs for a while, displaying an empty window, while waiting for the GLTF asset to load, and then the crash occurs.

## Additional information

Asahi Linux does not yet have a Vulkan driver, so Bevy has to run via the fallback GL wgpu backend, which uses GLES3. GLES 3.0 support was just added to the Asahi GPU drivers.

Cubemap Array Textures are an extension (`GL_OES_texture_cube_map_array`) that is included in GLES 3.2. As we can see in [Mesa Matrix](https://mesamatrix.net/#OpenGLES3.2_Extension_GL_OES_texture_cube_map_array), it is not supported on Asahi, and also in plenty of other drivers for that matter.

Bevy requiring cubemap array textures to do any kind of 3D rendering is *bad*, as it limits platform compatibility. It prevents Bevy 3D apps from running on any of these drivers. This also includes Raspberry Pis and other embedded/mobile hardware.

I think Bevy should relax this requirement. Cubemap Array Textures (whatever bevy uses them for, I don't know, I am assuming environment map lighting) should be made optional by putting them behind shader defs / pipeline specialization.

It should be possible for Bevy users to make 3D apps that can run on such platforms, as long as they don't use the fancy rendering features that need this texture type.

Bevy 2D rendering works fine on Asahi. I am able to successfully run 2D examples and apps.

---

Edit: no longer an issue on Asahi, since Asahi provides GLES 3.2 compliant drivers now and all the relevant features are supported. May still be an issue on other systems/hardware/drivers.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with the load_gltf example and tracing the Render Pipeline creation through the Pipeline Cache. Investigate the shader defs and pipeline specialization suggested in the issue, then verify that basic 3D rendering works on GLES below 3.2 while features requiring cubemap array textures remain optional.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.