AnthonyTornetta / bevy_easy_compute

App compute plugin for Bevy
21 stars 4 forks source link

Getting Started doesn't work #16

Closed utensil closed 2 weeks ago

utensil commented 3 weeks ago

Hi, thanks for this great plugin!

Following "Getting Started" and examples (mostly I'm trying multi_pass) in main won't work, not even if following them in tag 0.14.

It will cause the following error:

TL;DR: The error contains a lots of type mismatches, hints on `naga::Module` and `wgpu::naga::Module` have similar names, but are actually distinct types, perhaps two different versions of crate `naga_oil` are being used? ``` Compiling bevy_easy_compute v0.14.0 error[E0061]: this method takes 1 argument but 2 arguments were supplied --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_easy_compute-0.14.0/src/pipeline_cache.rs:99:33 | 99 | let composer = composer.with_capabilities(capabilities, ShaderStages::COMPUTE); | ^^^^^^^^^^^^^^^^^ --------------------- unexpected argument #2 of type `naga::valid::ShaderStages` | note: method defined here --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/naga_oil-0.15.0/src/compose/mod.rs:1420:12 | 1420 | pub fn with_capabilities(self, capabilities: naga::valid::Capabilities) -> Self { | ^^^^^^^^^^^^^^^^^ help: remove the extra argument | 99 - let composer = composer.with_capabilities(capabilities, ShaderStages::COMPUTE); 99 + let composer = composer.with_capabilities(capabilities); | error[E0277]: the trait bound `ComposableModuleDescriptor<'_>: From<&bevy::prelude::Shader>` is not satisfied --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_easy_compute-0.14.0/src/pipeline_cache.rs:128:59 | 128 | composer.add_composable_module(shader.into())?; | ^^^^ the trait `From<&bevy::prelude::Shader>` is not implemented for `ComposableModuleDescriptor<'_>`, which is required by `&bevy::prelude::Shader: Into<_>` | = note: required for `&bevy::prelude::Shader` to implement `Into>` error[E0277]: `?` couldn't convert the error to `PipelineCacheError` --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_easy_compute-0.14.0/src/pipeline_cache.rs:128:66 | 128 | composer.add_composable_module(shader.into())?; | ^ the trait `From` is not implemented for `PipelineCacheError`, which is required by `std::result::Result<(), PipelineCacheError>: FromResidual>` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the trait `From` is implemented for `PipelineCacheError` = help: for that trait implementation, expected `naga_oil::compose::error::ComposerError`, found `ComposerError` = note: required for `std::result::Result<(), PipelineCacheError>` to implement `FromResidual>` error[E0277]: the trait bound `NagaModuleDescriptor<'_>: From<&bevy::prelude::Shader>` is not satisfied --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_easy_compute-0.14.0/src/pipeline_cache.rs:221:42 | 221 | ... ..shader.into() | ^^^^ the trait `From<&bevy::prelude::Shader>` is not implemented for `NagaModuleDescriptor<'_>`, which is required by `&bevy::prelude::Shader: Into<_>` | = note: required for `&bevy::prelude::Shader` to implement `Into>` error[E0277]: `?` couldn't convert the error to `PipelineCacheError` --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_easy_compute-0.14.0/src/pipeline_cache.rs:223:26 | 223 | )?; | ^ the trait `From` is not implemented for `PipelineCacheError`, which is required by `std::result::Result: FromResidual>` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the trait `From` is implemented for `PipelineCacheError` = help: for that trait implementation, expected `naga_oil::compose::error::ComposerError`, found `ComposerError` = note: required for `std::result::Result` to implement `FromResidual>` error[E0271]: type mismatch resolving `::Owned == Module` --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_easy_compute-0.14.0/src/pipeline_cache.rs:225:50 | 225 | wgpu::ShaderSource::Naga(Cow::Owned(naga)) | ^^^^^^^^^^^^^^^^ expected `wgpu::naga::Module`, found `naga::Module` | = note: `naga::Module` and `wgpu::naga::Module` have similar names, but are actually distinct types note: `naga::Module` is defined in crate `naga` --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba1[500](https://github.com/utensil/native-land/actions/runs/11287642371/job/31393913372#step:8:501)1f/naga-22.1.0/src/lib.rs:2236:1 | 2236 | pub struct Module { | ^^^^^^^^^^^^^^^^^ note: `wgpu::naga::Module` is defined in crate `naga` --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/naga-0.20.0/src/lib.rs:2144:1 | 2144 | pub struct Module { | ^^^^^^^^^^^^^^^^^ = note: perhaps two different versions of crate `naga` are being used? error[E0308]: mismatched types --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_easy_compute-0.14.0/src/pipeline_cache.rs:418:63 | 418 | let error_detail = err.emit_to_string(&self.shader_cache.composer); | -------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `naga_oil::compose::Composer`, found `Composer` | | | arguments to this method are incorrect | = note: `Composer` and `naga_oil::compose::Composer` have similar names, but are actually distinct types note: `Composer` is defined in crate `naga_oil` --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/naga_oil-0.15.0/src/compose/mod.rs:317:1 | 317 | pub struct Composer { | ^^^^^^^^^^^^^^^^^^^ note: `naga_oil::compose::Composer` is defined in crate `naga_oil` --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/naga_oil-0.14.0/src/compose/mod.rs:319:1 | 319 | pub struct Composer { | ^^^^^^^^^^^^^^^^^^^ = note: perhaps two different versions of crate `naga_oil` are being used? note: method defined here --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/naga_oil-0.14.0/src/compose/error.rs:166:12 | 166 | pub fn emit_to_string(&self, composer: &Composer) -> String { | ^^^^^^^^^^^^^^ Some errors have detailed explanations: E0061, E0271, E0277, E0308. For more information about an error, try `rustc --explain E0061`. error: could not compile `bevy_easy_compute` (lib) due to 7 previous errors ```

After some fiddling, I came up with the following TOML that works:

# https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html
[dependencies]
log = { version = "*", features = ["max_level_debug", "release_max_level_warn"] }
bevy_easy_compute = { git = "https://github.com/AnthonyTornetta/bevy_easy_compute", rev = "bbaa8b83472e96e035008bb06c88333023f63503" }

[dependencies.bevy]
version = "0.14.2"
default-features = false
# See https://github.com/bevyengine/bevy/blob/main/docs/cargo_features.md
features = [
  "bevy_core_pipeline",
  "multi_threaded",
  "x11",
]

The key is to use git version of this plugin, and enable feature like how bevy_easy_compute did it but keep it minimal.

Strangely, if x11 is not enabled, update system test will run only once, and the worker returns not ready. With x11, it works the same as the example multi_pass. I'm on MacBookPro M1.

AnthonyTornetta commented 2 weeks ago

Yes, sorry about that! I've just published an updated version to crates.io (0.14.1) that you can use instead of pulling from github.