Repository navigation
Persistent Buffer Mapping #7290
Copy link
Copy link
Open
Labels
apiWebGPU APIWebGPU API
Milestone
Description
There have been many requests for persistent buffer mapping over the years. We've mostly not considered it due to portability issues (exposing race conditions), but it might be possible for us to choose to expose races. We should probably have another discussion - whether it's feasible, and useful enough to break rules for.
Here's a random assortment of points and references (I searched a bunch but not exhaustively):
- Persistent mapping is widely used in native.
- Can it be made secure?
- It's very related to UMA (Cannot upload/download to UMA storage buffer without an unnecessary copy and unnecessary memory use #2388) because it's another way to take advantage of the shared memory space, however I think it's largely orthogonal as dGPUs have DMA / Resizable BAR (ReBAR), and iGPU don't enable transparently sharing memory anyway.
- Note the discussion here about surprising performance of mappings without
HOST_CACHED_BIT | HOST_COHERENT_BIT.
- Note the discussion here about surprising performance of mappings without
- What would synchronization guarantees look like (flush, invalidate, barriers)?
- Could we solve people's needs with alternative features?
- Early proposals: MapAsync with subranges. #605, Proposal for a simple streaming API #154, and presumably others
- Some things can be done with
mapSync: mapSync on Workers - and possibly on the main thread #2217 - Read-only resources that just allow sharing some immutable data between CPU and GPU to save on memory usage (see also read-only ArrayBuffers in List of issues to discuss with TC39, WASM, JS engine teams #747)
- Persistent mapping fits nicely with Wasm mmap because it could avoid needing
mprotectwhich has significant overhead (and is complex to standardize). WebGPU mapping × WebAssembly "mmap" #6309- Would the
mprotectversion of that be useful in JS as well? That is, a pseudo-persistent mapping, with a persistent memory region but still usingmprotectto prevent races. (This requires making JS able to handle page faults. My understanding is this is harder than page faults in Wasm.)
- Would the
- Would a developer mode, e.g. emulating persistent mapping using copies, work well for portability testing?
Metadata
Metadata
Assignees
Labels
apiWebGPU APIWebGPU API
Activity