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

Update README.md #89

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update README.md #89

wants to merge 1 commit into from

Conversation

alphastrata
Copy link

@alphastrata alphastrata commented Mar 15, 2025

Add a note to the README because the VERSION of a --feature='xyz' crate is important.

Example: a glam::Vec3 on version 0.30.0 is a distinct and entirely different type from glam::Vec3 on 0.29.0 and the version encase is using will be the only one the appropriate stuff is implemented via the fancy macros on.

I imagine I'm not the first to encounter this.

An Extended Example:

  1. See this in the examples:
#[derive(ShaderType)]
struct Positions {
    length: ArrayLength,
    #[size(runtime)]
    positions: Vec<mint::Point3<f32>>
}

0 problems.

  1. See that glam is a feature, so slap it in there!

Cargo.toml

#... snipping...
encase = { version = "0.10.0", features = ["glam"] }
glam = "0.30.0" # Here is the problem you may not see coming, as glam was already a dep in this project...
#[derive(ShaderType)]
struct Positions {
    length: ArrayLength,
    #[size(runtime)]
    positions: Vec<glam::Vec3>
}
  1. Get an error.
error[E0277]: the trait bound `Vec3: ShaderSize` is not satisfied
  --> src/gpu_image.rs:27:16
   |
27 |     positions: Vec<Vec3>,
   |                ^^^^^^^^^ the trait `ShaderSize` is not implemented for `Vec3`
   |
   = help: the following other types implement trait `ShaderSize`:
             &T
             &mut T
             Arc<T>
             AtomicI32
             AtomicU32
             Box<T>
             Cell<T>
             Cow<'_, T>
           and 22 others
   = note: required for `Vec<Vec3>` to implement `ShaderType`
  1. Faff about for halfa until you realise encase is using glam = "0.29.0"
  2. Use the same version as encase.

Cargo.toml

#... snipping...
encase = { version = "0.10.0", features = ["glam"] }
glam = "0.29.0" 
  1. code compiles fine.

The insidious thing here is that obviously rust-analyzer or rustc won't tell you that it's a distinct types from differing versions of crates issue.

Add that the VERSION of the crate is important, because a glam::Vec3 on version 0.30.0 is a distinct and entirely different type from glam::Vec3 on 0.29.0 and the version encase is using will be the only one the appropriate stuff is implemented via the fancy macros on.
@alphastrata
Copy link
Author

@teoxoy sup with the pipeline? Surely changing the readme doesn't break it... No?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant