bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
33.58k stars 3.26k forks source link

Unsupported GL_EXT_texture_shadow_lod causes panic in PBR pipeline #14045

Open ByteNybbler opened 1 week ago

ByteNybbler commented 1 week ago

Bevy version

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

Relevant system information

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)

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.

Maybe it's possible that this issue could be fixed by https://github.com/bevyengine/bevy/pull/12849?

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

janhohenheim commented 1 week ago

Am I understanding it correctly that this did not happen in 0.13 and is due to the wgpu update? Update: yes, https://github.com/gfx-rs/wgpu/pull/5171 is part of WGPU 0.20.0 which is first used by Bevy 0.14. As such, this is a regression: some older hardware can no longer run Bevy stuff.

Open question: is this important? How many machines are affected? I'd like to test this, but I don't know how to force WGPU to use my integrated GPU (other than physically removing my actual GPU of course).

Running the pbr example on OpenGL on my dedicated GPU at least renders fine but spams the following hundreds of times: image

I don't think this is related to this issue in particular, but worth noting.

JMS55 commented 1 week ago

Set the WGPU_ADAPTER_NAME environment variable to force a specific GPU: https://github.com/gfx-rs/wgpu?tab=readme-ov-file#environment-variables

ByteNybbler commented 1 week ago

Am I understanding it correctly that this did not happen in 0.13 and is due to the wgpu update? Update: yes, gfx-rs/wgpu#5171 is part of WGPU 0.20.0 which is first used by Bevy 0.14. As such, this is a regression: some older hardware can no longer run Bevy stuff.

I switched to v0.13.2 and tried WGPU_BACKEND=gl cargo run --example pbr and I still got the same 'GL_EXT_texture_shadow_lod' is not supported errors as above. This seems to prove that gfx-rs/wgpu#5171 is not the cause of this error, and therefore this doesn't seem to be a regression (as far as I can tell, anyway).

Open question: is this important? How many machines are affected?

I think my integrated GPU is around a decade old now. However, it can run almost every game I come across without issue. In order for Bevy to be truly competitive as a game engine, I would argue that it's important to try to maximize hardware compatibility (within reason, of course).

Running the pbr example on OpenGL on my dedicated GPU at least renders fine but spams the following hundreds of times:

That looks like #13115 which is probably only tangentially related to this issue.

janhohenheim commented 1 week ago

@ByteNybbler thanks for the info! Removing the milestone then.