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

The Fate and Purpose of BufferSlice #6974

Open
cwfitzgerald opened this issue Jan 23, 2025 · 2 comments
Open

The Fate and Purpose of BufferSlice #6974

cwfitzgerald opened this issue Jan 23, 2025 · 2 comments
Labels
area: api Issues related to API surface type: enhancement New feature or request

Comments

@cwfitzgerald
Copy link
Member

There's been a bit of discussion in the community about the difficulties in the current BufferSlice api. As such, we have been thinking about removing it entirely. However there was some discussion about potential use cases of it in #6309, so we figured we should make an issue to discuss what the api of BufferSlice should be, if it is to exist at all.

cc @kpreid

Some Arguments Against the Current Api:

  • It is a deviation from the spec.
  • The name BufferSlice implies that you can access the data inside the buffer.
  • Users try to keep the BufferSlice around, but because of the strict lifetime, you can't keep it for more than a short period.
@cwfitzgerald cwfitzgerald added area: api Issues related to API surface type: enhancement New feature or request labels Jan 23, 2025
@kpreid
Copy link
Contributor

kpreid commented Jan 23, 2025

I’ll try to have some thoughts about what would be an “actually actively-good version of BufferSlice”, but I don't have them right now. Some comments:

It is a deviation from the spec.

Note that it's easier in JavaScript to create an ad-hoc object, copy or inherit properties, etc., so it may be easier to deal with not having useful predefined struct types there.

Users try to keep the BufferSlice around, but because of the strict lifetime, you can't keep it for more than a short period.

This could be fixed by making BufferSlice generic or Cow-ish to allow owning the buffer, now that wgpu objects are all Clone-with-refcounting.

@cwfitzgerald
Copy link
Member Author

Note no rush, this isn't a ticking timebomb, we'll let the discussion take its course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: api Issues related to API surface type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants