bevyengine / bevyengine/bevy

Illegal path when importing embedded wesl shaders

Open
#20,285 0 comments 0 reactions 0 assignees View on GitHub
A-Rendering C-Bug D-Shaders S-Needs-Investigation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version

0.16.0

## What you did

I am using two wesl shaders, loaded as embedded assets in my library crate.
I register them for the asset server:
```rust
impl Plugin for RenderGraphPlugin {
fn build(&self, app: &mut bevy::app::App) {
embedded_asset!(app, "tesselate_pass.wesl");
embedded_asset!(app, "view.wesl");

std::mem::forget(
app.world_mut()
.resource_mut::()
.load::("embedded://my_plugin/render_graph/view.wesl"),
);

```
And within the tesselate shader I import the view shader
```rust
import super::view;

@group(0) @binding(0) var v: view::View;
```

## What went wrong

This panicked with the very unwelcoming message:
```
The application panicked (crashed).
Message: called `Result::unwrap()` on an `Err` value: ParseError { message: "expected `;`, found \":\"", labels: [(Span { start: 54, end: 55 }, "expected `;`")], notes: [] }
Location: /home/nionidh/projects/bevy-tomfoolery/bevy/crates/bevy_render/src/render_resource/pipeline_cache.rs:308
```

When looking at the compiled wesl sources, via a `println!("{}", &compiled.to_string());` here:
https://github.com/bevyengine/bevy/blob/f8082163950d1708a91313e4f46a57ed7c93d90b/crates/bevy_render/src/render_resource/pipeline_cache.rs#L315-L324

I can see that it's compiled to something like this:
```
@group(0) @binding(0)
var v: package_embedded:__2my_plugin__1render_graph_view_View;
```

Which has a colon `:` in the identifier part, and definitely is not valid wgsl.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the embedded WESL import with the two shader snippets, then inspect crates/bevy_render/src/render_resource/pipeline_cache.rs around lines 308-324 and print the compiled source. Trace where the embedded module path becomes `package_embedded:__2my_plugin__1render_graph_view_View`; done means the imported shader produces valid WGSL and no parse panic.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.