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

wgpu: Use write_buffer_with rather than write_buffer #576

Open
waywardmonkeys opened this issue May 13, 2024 · 2 comments
Open

wgpu: Use write_buffer_with rather than write_buffer #576

waywardmonkeys opened this issue May 13, 2024 · 2 comments
Labels
Performance Improvements to rendering performance

Comments

@waywardmonkeys
Copy link
Contributor

This can be a performance improvement due to reduced data copying.

From the updated (post 0.20) docs:

    /// Write to a buffer via a directly mapped staging buffer.
    ///
    /// Return a [`QueueWriteBufferView`] which, when dropped, schedules a copy
    /// of its contents into `buffer` at `offset`. The returned view
    /// dereferences to a `size`-byte long `&mut [u8]`, in which you should
    /// store the data you would like written to `buffer`.
    ///
    /// This method may perform transfers faster than [`Queue::write_buffer`],
    /// because the returned [`QueueWriteBufferView`] is actually the staging
    /// buffer for the write, mapped into the caller's address space. Writing
    /// your data directly into this staging buffer avoids the temporary
    /// CPU-side buffer needed by `write_buffer`.
    ///
    /// Reading from the returned view is slow, and will not yield the current
    /// contents of `buffer`.
    ///
    /// Note that dropping the [`QueueWriteBufferView`] does *not* submit the
    /// transfer to the GPU immediately. The transfer begins only on the next
    /// call to [`Queue::submit`] after the view is dropped. To get a set of
    /// scheduled transfers started immediately, it's fine to call `submit` with
    /// no command buffers at all:
@waywardmonkeys waywardmonkeys added this to the Vello 0.2 release milestone May 13, 2024
@DasLixou DasLixou added the Performance Improvements to rendering performance label May 13, 2024
@waywardmonkeys
Copy link
Contributor Author

(This is partly a reminder to myself. I planned to do this and keep forgetting.)

@waywardmonkeys waywardmonkeys removed this from the Vello 0.2 release milestone May 16, 2024
@waywardmonkeys
Copy link
Contributor Author

Not sure if this actually an improvement, need to ask upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Improvements to rendering performance
Projects
None yet
Development

No branches or pull requests

2 participants