Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero Copy Mesh #15569

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Zero Copy Mesh #15569

wants to merge 10 commits into from

Conversation

atlv24
Copy link
Contributor

@atlv24 atlv24 commented Oct 1, 2024

Objective

Solution

  • Instead of allocating a Vec and then having wgpu copy it into a staging buffer, write directly into the staging buffer.
  • gets rid of another hidden copy, in pad_to_alignment.

future work:

  • why is there a gcd implementation in here (and its subpar, use binary_gcd. its in the hot path, run twice for every mesh, every frame i think?) make it better and put it in bevy_math
  • zero-copy custom mesh api to avoid having to write out a Mesh from a custom rep

Testing

  • lighting and many_cubes run fine (and slightly faster. havent benchmarked though)

Showcase

  • look ma... no copies

at least when RenderAssetUsage is GPU only :3

@atlv24 atlv24 added C-Performance A change motivated by improving speed, memory usage or compile times A-Rendering Drawing game state to the screen labels Oct 1, 2024
@alice-i-cecile alice-i-cecile added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Oct 1, 2024
Copy link
Contributor

@IceSentry IceSentry left a comment

Choose a reason for hiding this comment

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

I haven't tested it yet, but the code LGTM

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 S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants