Skip to content

BufferSlice cleanup#21289

Merged
james7132 merged 2 commits intobevyengine:mainfrom
akimakinai:buffer_cleanup
Sep 30, 2025
Merged

BufferSlice cleanup#21289
james7132 merged 2 commits intobevyengine:mainfrom
akimakinai:buffer_cleanup

Conversation

@akimakinai
Copy link
Contributor

@akimakinai akimakinai commented Sep 30, 2025

Objective

  • Cleanup code by utilizing wgpu::BufferSlice::offset/size (added in wpgu 25).

This is technically a breaking change. bevy::BufferSlice::offset/size no longer exists, and .size() now returns wgpu::BufferSize = NonZeroU64 instead of wgpu::BufferAddress = u64.

Originally in PR #20468. I thought this is conflated and should be separated

@james7132 james7132 added A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change labels Sep 30, 2025
Copy link
Member

@james7132 james7132 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this isn't a breaking change, per se. BufferSlice's deref implementation should allow the identical functions on wgou's BufferSlice type to be called instead. Might be a breaking change if people were using turbofish notation for these functions, but I don't think that's an expected use case for these functions.

@james7132 james7132 added the D-Trivial Nice and easy! A great choice to get started with Bevy label Sep 30, 2025
@james7132 james7132 added this to the 0.18 milestone Sep 30, 2025
@james7132 james7132 added this pull request to the merge queue Sep 30, 2025
Merged via the queue into bevyengine:main with commit 523f40a Sep 30, 2025
43 checks passed
@akimakinai akimakinai deleted the buffer_cleanup branch September 30, 2025 01:29
github-merge-queue bot pushed a commit that referenced this pull request Sep 30, 2025
…20468)

# Objective

- `offset` argument is misleading as the argument is not actually passed
to wgpu (used only for memoization and logging). `BufferSlice` already
contains an offset.
- wgpu's `set_index_buffer` [sets the offset according to
BufferSlice::offset](https://github.com/gfx-rs/wgpu/blob/e990388af98e4b4dff9f7fcc09a4eb5d2f71d227/wgpu/src/api/render_pass.rs#L98-L105)
- `TrackedRenderPass::set_vertex_buffer` was made aware of slice size
(#14916) but missed `set_index_buffer` counterpart

## Solution

- Removed `offset` argument from `TrackedRenderPass::set_index_buffer`
- Apply fix from #14916 to `TrackedRenderPass::is_index_buffer_set`
- ~~Cleanup code by using the newly added `BufferSlice` getters~~ split
out to #21289

## Testing

- Ran a few examples
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-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants