Skip to content

glam scalar-math (via feature unification) breaks 3D rendering: model_only_mesh_bind_group binding size 168 < 176 #26087

Closed

Description

@bcanfield

Bevy version

0.20.0 (glam 0.33.12), macOS arm64 (Metal). Works on 0.19.1, which used a different glam.

What went wrong

With glam's scalar-math feature enabled anywhere in the dependency graph, 3D rendering fails on the first frame:

model_only_mesh_bind_group: Binding size 168 of Buffer is less than minimum 176

In our case it is enabled indirectly: rapier3d-f64 enhanced-determinism → parry3d-f64 → glamx/scalar-math → glam/scalar-math. Bevy 0.20 is on glam 0.33 as well, so Cargo feature unification turns it on for Bevy too, and Vec4 becomes 4-byte instead of 16-byte aligned. A crate can't opt out of a unified feature, so any app that pulls in rapier/parry with enhanced-determinism hits this.

Likely cause

MeshUniform derives ShaderType; its WGSL/encase layout is 176 bytes, and the bind-group layout uses that (GpuArrayBuffer::<MeshUniform>::binding_layout, bevy_pbr/src/render/mesh_bindings.rs). The instance buffer is sized from Rust's size_of::<T>() instead (UninitBufferVec, bevy_render/src/render_resource/buffer_vec.rs, item_size: size_of::<T>()), which is 168 under scalar-math. The two agree only with SIMD alignment.

Suggested fix

Size UninitBufferVec/RawBufferVec items for ShaderType data from T::min_size(), as BufferVec already does. Or at least add a compile-time check that size_of::<T>() == T::min_size(), so the mismatch fails loudly.

Repro

Seen in a full app; a minimal repro is not yet built. The expected minimal case is a 0.20 app spawning one Mesh3d + MeshMaterial3d<StandardMaterial> and a Camera3d, with glam = { version = "0.33", features = ["scalar-math"] } added to [dependencies].

Activity

  1. added a commit that references this issue on Oct 12, 2026
    48ae9fc
  2. added a commit that references this issue on Oct 12, 2026
    b5a4b74
  3. added 2 commits that reference this issue on Oct 19, 2026
    6fa5f28
    6cb6dd0
  4. added a commit that references this issue on Oct 27, 2026
    8b6bc34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions