`wgsl` shaders without `@vertex`/`@fragment` entry point cause panic
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version
[v0.9.1](https://github.com/bevyengine/bevy/tree/v0.9.1)
## What you did
Hot-Reloading of `wgsl` shaders, triggering the reload by saving with vscode (on Windows 10).
## What went wrong
When vscode saves to disk, bevy seems to randomly pick up an empty file first, which is technically valid `wgsl` file, but misses an entry point. This missing entry point causes a panic (see error and backtrace below).
I also tried saving the shader in Notepad++ instead, which causes the same issue but seemingly more often (after very limited testing).
Finally I also tried Windows Notepad (the old Window 10 version) for the fun of it, but to my surprise, this one seems to work fine no matter how much I save (yes, I modified the content inbetween each save). Now if only Windows Notepad was a decent editor 😛
---
Is a panic considered as works-as-intended for this case in particular? I don't think so, but if it were, that would be a very unfortunate coincidence, considering that regular shader compilation errors do not panic and simply log the error and continue without the shader, making hot-reloading of shaders an absolute joy (as long as the empty-file issue doesn't occur).
## Error and Backtrace
```
2022-12-24T13:06:08.385322Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default
thread 'Compute Task Pool (2)' panicked at 'wgpu error: Validation Error
Caused by:
In Device::create_render_pipeline
note: label = `position_based_pbr_opaque_mesh_pipeline`
error matching VERTEX shader requirements against the pipeline
unable to find entry point 'vertex'
', D:\dev\Rust\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-0.14.2\src\backend\direct.rs:2403:5
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library\std\src\panicking.rs:575
1: core::panicking::panic_fmt
at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library\core\src\panicking.rs:65
2: <&T as core::fmt::Debug>::fmt
3: ::device_create_render_pipeline
4: wgpu::Device::create_render_pipeline
5: bevy_render::render_resource::pipeline_cache::PipelineCache::process_queue
6: as bevy_ecs::system::system::System>::run_unsafe
7: as core::future::future::Future>::poll
8: async_task::raw::RawTask::run
9: as core::future::future::Future>::poll
10: as core::future::future::Future>::poll
11: std::thread::local::LocalKey::with
12: std::thread::local::LocalKey::with
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', D:\dev\Rust\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_tasks-0.9.1\src\task_pool.rs:273:45
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library\std\src\panicking.rs:575
1: core::panicking::panic_fmt
at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library\core\src\panicking.rs:65
2: core::panicking::panic
at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library\core\src\panicking.rs:115
3: <&mut F as core::future::future::Future>::poll
4: std::thread::local::LocalKey::with
5: bevy_tasks::task_pool::TaskPool::scope
6: ::run_systems
7: ::run
8: ::from_world
9: bevy_app::app::App::update
10: winit::platform_impl::platform::event_loop::EventLoop::run_return::{{closure}}
11: as core::ops::function::FnOnce<()>>::call_once
12: winit::platform_impl::platform::event_loop::runner::EventLoopRunner::register_window
13: winit::platform_impl::platform::event_loop::runner::EventLoopRunner::move_state_to
14: as core::ops::function::FnOnce<()>>::call_once
15: winit::platform_impl::platform::event_loop::runner::EventLoopRunner::catch_unwind
16: winit::platform_impl::platform::event_loop::EventLoopThreadExecutor::execute_in_thread
17: CallWindowProcW
18: DispatchMessageW
19: SendMessageTimeoutW
20: KiUserCallbackDispatcher
21: NtUserDispatchMessage
22: DispatchMessageW
23: winit::platform_impl::platform::event_loop::EventLoop::run_return
24: winit::platform_impl::platform::event_loop::EventLoop::run
25: core::ptr::drop_in_place>
26: ::build
27: bevy_winit::winit_runner_with
28: core::ops::function::Fn::call
29: bevy_app::app::App::run
30: wgpu_core::device::queue::PendingWrites::dispose
```
Contributor guide
Assessment
This issue has not been assessed yet.