Skip to content

For each mesh instance, only store the previous frame's transform, not the entire MeshInputUniform.#23892

Open
pcwalton wants to merge 1 commit into
bevyengine:mainfrom
pcwalton:shrink-previous-mesh-uniform
Open

For each mesh instance, only store the previous frame's transform, not the entire MeshInputUniform.#23892
pcwalton wants to merge 1 commit into
bevyengine:mainfrom
pcwalton:shrink-previous-mesh-uniform

Conversation

@pcwalton
Copy link
Copy Markdown
Contributor

Currently, we copy the entire MeshInputUniform, which is 24 words, to the previous mesh instance buffer. This is wasteful, as we only ever use the transform for motion blur.

This patch fixes the issue by introducing a new type, PreviousMeshInputUniform, that contains only the transform. Not only does this improve performance, but it will also simplify future work to sparsely update only the MeshInputUniform fields that changed.

On bevy_city --no-cpu-culling, this commit reduces write_previous_input_buffers from a median time of 240.1 μs to 65.33 μs, a 3.68× speedup.

Screenshot 2026-04-20 003301

the entire `MeshInputUniform`.

Currently, we copy the entire `MeshInputUniform`, which is 24 words, to
the previous mesh instance buffer. This is wasteful, as we only ever use
the transform for motion blur.

This patch fixes the issue by introducing a new type,
`PreviousMeshInputUniform`, that contains only the transform.  Not only
does this improve performance, but it will also simplify future work to
sparsely update only the `MeshInputUniform` fields that changed.

On `bevy_city --no-cpu-culling`, this commit reduces
`write_previous_input_buffers` from a median time of 240.1 μs to 65.33
μs, a 3.68× speedup.
@pcwalton pcwalton added C-Performance A change motivated by improving speed, memory usage or compile times A-Rendering Drawing game state to the screen labels Apr 20, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Rendering Apr 20, 2026
@pcwalton pcwalton added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Apr 20, 2026
@cart cart closed this May 5, 2026
@github-project-automation github-project-automation Bot moved this from Needs SME Triage to Done in Rendering May 5, 2026
@cart cart reopened this May 5, 2026
@github-project-automation github-project-automation Bot moved this from Done to Needs SME Triage in Rendering May 5, 2026
@kfc35 kfc35 added D-Straightforward Simple bug fixes and API improvements, docs, test and examples D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes and removed D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels May 24, 2026
Copy link
Copy Markdown
Contributor

@kfc35 kfc35 left a comment

Choose a reason for hiding this comment

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

looks good to me

@kfc35
Copy link
Copy Markdown
Contributor

kfc35 commented May 24, 2026

just a note that you have to resolve some merge conflicts

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-Performance A change motivated by improving speed, memory usage or compile times D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

3 participants