Skip to content

Conversation

cwfitzgerald
Copy link
Member

@cwfitzgerald cwfitzgerald commented Aug 21, 2025

Connections

None

Description

This adds various functions for making dealing with mapping and other callbacks easier. Often you are working with a command buffer then want to map a buffer or do something when that command buffer is submitted. Normally you need to build some kind of infrastructure for this (I have many times) but this can be really easily be done by wgpu itself for very little cost.

image

Testing

Told GPT-5 to put together some tests as an experiment. I think it did okay.

Squash or Rebase?

Rebase me pls

Checklist

  • Baseline implementation
  • Improved code documentation
  • Validation tests
  • Better verbiage
  • Changelog

@cwfitzgerald cwfitzgerald force-pushed the cw/deferred-mapping branch 3 times, most recently from e910b48 to e42ba38 Compare August 22, 2025 03:03
@cwfitzgerald cwfitzgerald marked this pull request as ready for review August 22, 2025 03:03
@cwfitzgerald cwfitzgerald requested a review from a team as a code owner August 22, 2025 03:03
Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

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

neat!
I think it's rather unfortunate to have this kind of extension in wgpu proper rather than an extension to it. Makes me wonder whether those deferred commands could be more generic and then we expose the concrete buffer extension as a utility.... but I don't want to throw a wrench into a perfectly good feature that is really hard to get into the ecosystem if we don't put it in here. So overall slight scope creep concerns, but let's ship this anyways!


/// A deferred buffer mapping request captured during encoding (or a pass)
/// and executed later when the command buffer is submitted.
pub(crate) struct BufferMapping {
Copy link
Member

Choose a reason for hiding this comment

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

let's call it DeferredBufferMapping to make clear to anyone stumbling over this type that regular buffer mapping operations don't go through this

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.

3 participants