bevyengine / bevyengine/bevy

Unsupported GL_EXT_texture_shadow_lod causes panic in PBR pipeline

Open
#14,045 6 comments 0 reactions 0 assignees View on GitHub
A-glTF A-Rendering C-Bug I-Crash O-OpenGL
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version

So far this panic has been reproduced on the following versions of Bevy:

- v0.13.2
- v0.14.0-rc.3
- v0.15.3
- v0.16.0

## Relevant system information

- `SystemInfo { os: "Windows 10 Home", kernel: "19045", cpu: "Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz", core_count: "4", memory: "15.9 GiB" }`
- `AdapterInfo { name: "Intel(R) HD Graphics 4600", vendor: 32902, device: 0, device_type: IntegratedGpu, driver: "OpenGL", driver_info: "4.3.0 - Build 20.19.15.4531", backend: Gl }`
- `cargo 1.79.0 (ffa9cf99a 2024-06-03)`

## What you did

`WGPU_BACKEND=gl cargo run --example pbr`

I've also noticed this same error on the `3d_shapes` and `load_gltf` examples. Maybe any PBR scene will cause this issue?

## What went wrong

Bevy does not seem to gracefully handle `GL_EXT_texture_shadow_lod` not being supported by the render device, and this causes shader compilation failures. This essentially makes many 3D Bevy games unplayable on older graphics hardware when using OpenGL.

```
2024-06-27T04:56:36.395669Z ERROR log: GLES: [ShaderCompiler/Error] ID 0 : SHADER_ID_COMPILE error has been generated. GLSL compile failed for shader 21, "": ERROR: 0:4: '#extension' : 'GL_EXT_texture_shadow_lod' is not supported
ERROR: 0:585: 'textureLod' : no matching overloaded function found (using implicit conversion)
ERROR: 0:660: 'textureLod' : no matching overloaded function found (using implicit conversion)

2024-06-27T04:56:36.395730Z ERROR log: Shader compilation failed: ERROR: 0:4: '#extension' : 'GL_EXT_texture_shadow_lod' is not supported
ERROR: 0:585: 'textureLod' : no matching overloaded function found (using implicit conversion)
ERROR: 0:660: 'textureLod' : no matching overloaded function found (using implicit conversion)

2024-06-27T04:56:36.396042Z ERROR log: Device::create_render_pipeline error: Internal error in ShaderStages(FRAGMENT) shader: ERROR: 0:4: '#extension' : 'GL_EXT_texture_shadow_lod' is not supported
ERROR: 0:585: 'textureLod' : no matching overloaded function found (using implicit conversion)
ERROR: 0:660: 'textureLod' : no matching overloaded function found (using implicit conversion)

2024-06-27T04:56:36.396070Z ERROR log: Shader translation error for stage ShaderStages(FRAGMENT): ERROR: 0:4: '#extension' : 'GL_EXT_texture_shadow_lod' is not supported
ERROR: 0:585: 'textureLod' : no matching overloaded function found (using implicit conversion)
ERROR: 0:660: 'textureLod' : no matching overloaded function found (using implicit conversion)

2024-06-27T04:56:36.396082Z ERROR log: Please report it to https://github.com/gfx-rs/wgpu
2024-06-27T04:56:36.396123Z ERROR log: Handling wgpu errors as fatal by default
thread 'Async Compute Task Pool (1)' panicked at C:\Users\bytenybbler\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.20.1\src\backend\wgpu_core.rs:2996:5:
wgpu error: Validation Error

Caused by:
In Device::create_render_pipeline
note: label = `pbr_opaque_mesh_pipeline`
Internal error in ShaderStages(FRAGMENT) shader: ERROR: 0:4: '#extension' : 'GL_EXT_texture_shadow_lod' is not supported
ERROR: 0:585: 'textureLod' : no matching overloaded function found (using implicit conversion)
ERROR: 0:660: 'textureLod' : no matching overloaded function found (using implicit conversion)

Encountered a panic in system `bevy_render::render_resource::pipeline_cache::PipelineCache::process_pipeline_queue_system`!
```

## Additional information

wgpu devs say that it is downstream's responsibility to handle missing `GL_EXT_texture_shadow_lod` gracefully, perhaps by using a downlevel flag: https://github.com/gfx-rs/wgpu/issues/5344#issuecomment-1983324065

https://github.com/gfx-rs/wgpu/pull/5171 introduced a new dependency on the `GL_EXT_texture_shadow_lod` feature, but upon testing older Bevy versions, it appears to be unrelated to this issue.

I found this bug while I was trying to test https://github.com/bevyengine/bevy/issues/8789.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with `WGPU_BACKEND=gl cargo run --example pbr`, then compare the same behavior in the `3d_shapes` and `load_gltf` examples. Start by tracing the PBR render pipeline through `PipelineCache::process_pipeline_queue_system` and review the linked wgpu issue about missing `GL_EXT_texture_shadow_lod`; done means unsupported hardware no longer causes shader compilation to panic.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.