Large-object slab creation fails for index buffers whose size is not a multiple of 4

Open
#26,457 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
rust
Domain
backend

Research direction

Start in slab_allocator.rs at the Slab::LargeObject branch around line 1050 and compare its buffer sizing with the general slab path. Check how COPY_BUFFER_ALIGNMENT is applied, then reproduce with an odd number of u16 indices and mapped-at-creation buffers. Done means large-object slab buffers satisfy the 4-byte alignment requirement and the reported validation failure is covered.

Written by the indexing model from the issue text.

Description

A-Rendering C-Bug S-Needs-Review

Version: bevy 0.20.1 (slab_allocator.rs, Slab::LargeObject branch, about line 1050).

What happens: with SlabAllocatorSettings { large_threshold: 0, .. }, or any mesh above
the threshold with an odd number of u16 indices, create_buffer with
mapped_at_creation: true fails validation: "Buffers that are mapped at creation have to be
aligned to COPY_BUFFER_ALIGNMENT". The next line, get_mapped_range_mut().unwrap(), then
panics: MapRangeError(... Buffer with 'large mesh slab N (index buffer)' label is invalid).

Suggested fix: round the buffer size up to COPY_BUFFER_ALIGNMENT (4) when creating
large-object slabs, as the general slabs presumably do.

Dominant language
Rust
Stars
49.8k
Forks
5.1k
Avg merge
3d 4h
Merged PRs (30d)
136

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bevyengine/bevy

All issues in bevyengine/bevy

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.