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

Add Buffer::size() and Buffer::usage(). #2923

Merged
merged 3 commits into from
Aug 2, 2022

Conversation

kpreid
Copy link
Contributor

@kpreid kpreid commented Jul 30, 2022

Checklist

  • Run cargo clippy.
  • Run RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown if applicable.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Connections
Fixes #2904

Description
Implements size and usage from https://gpuweb.github.io/gpuweb/#buffer-interface

Testing
Added a unit test and ran the test suite. Since this does not interact with the backend at all, there should be no platform-specific testing needed.

https://gpuweb.github.io/gpuweb/#buffer-interface

Implementation note: it would save 8 bytes of memory to ask the backend
for the size, instead of storing it separately, since many backends have
the size stored anyway. But, that seemed like it would overcomplicate
the architecture for tiny memory savings, and `usage` is already stored
in the `wgpu::Buffer` anyway (though only used once, prior to now).
@kpreid kpreid marked this pull request as ready for review July 30, 2022 16:56
wgpu/tests/buffer.rs Outdated Show resolved Hide resolved
wgpu/src/lib.rs Show resolved Hide resolved
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.

Tysm!

@cwfitzgerald cwfitzgerald merged commit 780209d into gfx-rs:master Aug 2, 2022
@kpreid kpreid deleted the buffer-size branch September 27, 2022 02:43
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.

Expose readonly size/usage on wgpu::Buffer
2 participants