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

Don’t copy buffer data back to JS if unnecessary, in WebGPU backend. #7007

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

kpreid
Copy link
Contributor

@kpreid kpreid commented Jan 27, 2025

Connections
Fixes a problem I mentioned in passing in #6202, making that actual bug harder to hit…

Description
Currently, the WebGPU backend unnecessarily copies all mapped ranges back from Wasm to JS memory, even if it was read-only, and even if it was not actually written. This change copies the data only if an &mut [u8] was actually taken.

Testing
My understanding is that wgpu currently has no automated tests for the WebGPU backend, so I patched the change into my application and tested that it doesn’t break.

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@kpreid kpreid requested a review from a team as a code owner January 27, 2025 16:24
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

Nice!

@cwfitzgerald cwfitzgerald merged commit 321ee42 into gfx-rs:trunk Jan 27, 2025
31 checks passed
@kpreid kpreid deleted the no-copy-readonly branch January 27, 2025 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants