Skip to content

fix UninitBufferVec to use shader's size for each entry instead of Ru… - #26090

Merged
mockersf merged 1 commit into
bevyengine:mainfrom
bcanfield:fix-uninit-buffer-vec-item-size
Oct 12, 2026
Merged

mockersf merged 1 commit into
bevyengine:mainfrom
bcanfield:fix-uninit-buffer-vec-item-size

Conversation

@bcanfield

Copy link
Copy Markdown
Contributor

…st's

Objective

  • Fixes glam scalar-math (via feature unification) breaks 3D rendering: model_only_mesh_bind_group binding size 168 < 176 #26087
  • Bevy keeps a GPU buffer of per-mesh dataa (MeshUniform). The shader expects each entry to be 176 bytes. Bevy worked out each entry's size by asking Rust how big the struct is, not how big the shader says it is. Normally both answers are 176, but w/ glam's scalar-math feature on, Rust packs the struct tighter, to 168 bytes. If a render phase draws exactly one mesh, the buffer comes out 168 bytes when the shader needs at least 176, and wgpu throws the binding-size error. With two or more meshes the buffer happens to be big enough, so the bug stays hidden.

Solution

  • UninitBufferVec now uses the shader's size for each entry instead of Rust's (one line change boi)

Testing

  • A unit test with a struct that's 12 bytes in Rust but 16 in a shader. It fails before the fix and passes after.

@github-actions

Copy link
Copy Markdown
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide, as well as our policy regarding AI usage, and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added this to the 0.20.1 milestone Oct 12, 2026
@stuartparmenter stuartparmenter added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen labels Oct 12, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Rendering Oct 12, 2026
@mockersf
mockersf added this pull request to the merge queue Oct 12, 2026
Merged via the queue into bevyengine:main with commit 48ae9fc Oct 12, 2026
54 checks passed
@github-project-automation github-project-automation Bot moved this from Needs SME Triage to Done in Rendering Oct 12, 2026
erickpiva pushed a commit to erickpiva/bevy that referenced this pull request Oct 12, 2026
bevyengine#26090)

…st's

# Objective

- Fixes bevyengine#26087 
- Bevy keeps a GPU buffer of per-mesh dataa (MeshUniform). The shader
expects each entry to be 176 bytes. Bevy worked out each entry's size by
asking Rust how big the struct is, not how big the shader says it is.
Normally both answers are 176, but w/ glam's scalar-math feature on,
Rust packs the struct tighter, to 168 bytes. If a render phase draws
exactly one mesh, the buffer comes out 168 bytes when the shader needs
at least 176, and wgpu throws the binding-size error. With two or more
meshes the buffer happens to be big enough, so the bug stays hidden.

## Solution

- UninitBufferVec now uses the shader's size for each entry instead of
Rust's (one line change boi)

## Testing

- A unit test with a struct that's 12 bytes in Rust but 16 in a shader.
It fails before the fix and passes after.
barafael pushed a commit to barafael/bevy that referenced this pull request Oct 19, 2026
bevyengine#26090)

…st's

# Objective

- Fixes bevyengine#26087
- Bevy keeps a GPU buffer of per-mesh dataa (MeshUniform). The shader
expects each entry to be 176 bytes. Bevy worked out each entry's size by
asking Rust how big the struct is, not how big the shader says it is.
Normally both answers are 176, but w/ glam's scalar-math feature on,
Rust packs the struct tighter, to 168 bytes. If a render phase draws
exactly one mesh, the buffer comes out 168 bytes when the shader needs
at least 176, and wgpu throws the binding-size error. With two or more
meshes the buffer happens to be big enough, so the bug stays hidden.

## Solution

- UninitBufferVec now uses the shader's size for each entry instead of
Rust's (one line change boi)

## Testing

- A unit test with a struct that's 12 bytes in Rust but 16 in a shader.
It fails before the fix and passes after.

(cherry picked from commit 48ae9fc)
barafael added a commit to barafael/kernel-panic-bevy that referenced this pull request Oct 19, 2026
Launches sometimes died in the menu with "Binding size 168 of Buffer …
MeshUniform … is less than minimum 176" (bevyengine/bevy#26087): with
glam's `scalar-math`, which the workspace turns on for deterministic
math, `MeshUniform` is 168 bytes in Rust and 176 in WGSL, and
`UninitBufferVec` sized its buffer by the Rust size. #26090 (merged into
main after 0.20.0) sizes entries by the shader layout; the
`kernel-panic-0.20` fork branch now carries it (6fa5f2878). 40 launches
afterwards: no render errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
unleashed pushed a commit to unleashed/bevy that referenced this pull request Oct 27, 2026
bevyengine#26090)

…st's

# Objective

- Fixes bevyengine#26087 
- Bevy keeps a GPU buffer of per-mesh dataa (MeshUniform). The shader
expects each entry to be 176 bytes. Bevy worked out each entry's size by
asking Rust how big the struct is, not how big the shader says it is.
Normally both answers are 176, but w/ glam's scalar-math feature on,
Rust packs the struct tighter, to 168 bytes. If a render phase draws
exactly one mesh, the buffer comes out 168 bytes when the shader needs
at least 176, and wgpu throws the binding-size error. With two or more
meshes the buffer happens to be big enough, so the bug stays hidden.

## Solution

- UninitBufferVec now uses the shader's size for each entry instead of
Rust's (one line change boi)

## Testing

- A unit test with a struct that's 12 bytes in Rust but 16 in a shader.
It fails before the fix and passes after.
sri443 pushed a commit to sri443/bevy that referenced this pull request Nov 10, 2026
# Objective

- Noticed while reviewing bevyengine#26090
- we store a comp time value in a structure field and only use it
internally

## Solution

- Directly use the comp time value everywhere
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-Bug An unexpected or incorrect behavior S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

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

5 participants