Implement GPUBuffer.mapAsync and update wgpu-core#27084
Implement GPUBuffer.mapAsync and update wgpu-core#27084bors-servo merged 5 commits intoservo:masterfrom
Conversation
|
Heads up! This PR modifies the following files:
|
|
r?@kvark |
That's technically fine, but a bit scary nonetheless. In Gecko, we are polling the devices every 100ms, which is supposed to be configurable in the future, see code. Might be worth doing something like this in Servo. |
kvark
left a comment
There was a problem hiding this comment.
Very nice! Just a few notes here
|
I have addressed most of the review comments. I am still unsure about the last one- about how that would be done. I'll try to dig into it but maybe it will be better to solve that along with (This line count of PR increased just because of new TAB space for the full block of code inside |
kvark
left a comment
There was a problem hiding this comment.
We had a chat about this on "#wgpu:matrix.org", and it looks like the PR is on the right track:)
|
@kvark I have changed the Unmapping process to use |
|
@bors-servo r+ |
|
📌 Commit 183a43d has been approved by |
checks failed. I didn't get this on my system earlier, but on a rebase against master I can see it failing now. I'll rectify this and push the changes. |
183a43d to
434466f
Compare
434466f to
db2d313
Compare
|
@bors-servo r+ |
|
📌 Commit db2d313 has been approved by |
Implement GPUBuffer.mapAsync and update wgpu-core <!-- Please describe your changes on the following line: --> This PR covers the following- 1. update wgpu-core to use serializable `RenderPass` and `ComputePass`. Implement `DispatchIndirect`. 2. Implement `GPUBuffer.mapAsync()`. The `mapAsync()` methods has the following flow- 1. A new promise is created in `mapAsync()` and a message sent to the server-side. This returns a promise. 2. On the server-side, a `struct BufferMapInfo` object stores the relevant info required to send data to the client-side on completion of mapping. This object is stored in a `buffer_maps: HashMap<id::BufferId, BufferMapInfo<'a>>,` in `WGPU`. `buffers_maps` basically stores the data for buffers with pending mapping. 3. `buffer_map_async()` command is issued with a callback responsible to send the data back to the client. 4. All the devices are polled every time the server receives a new message. 5. The data is sent back on completion and promise resolved through `AsyncWGPUListener` (similar to how the `requestDevice()` and `RequestAdapter` are processed). 6. On receiving the data, the client sends back a `BufferMapComplete` message to the server to remove the entry from `buffer_maps` hashmap. I intended to implement `getMappedRange()`, too, in this PR but it's quite a task in itself (implementing intersecting ArrayBuffers). This already being a 500+ line PR, I thought it best to get this model approved first (also it will probably be easier to review this and `getMappedRange` separately). `getMappedRange` would come up in the next one. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
|
💔 Test failed - status-taskcluster |
|
☀️ Test successful - status-taskcluster |
This PR covers the following-
RenderPassandComputePass. ImplementDispatchIndirect.GPUBuffer.mapAsync().The
mapAsync()methods has the following flow-mapAsync()and a message sent to the server-side. This returns a promise.struct BufferMapInfoobject stores the relevant info required to send data to the client-side on completion of mapping. This object is stored in abuffer_maps: HashMap<id::BufferId, BufferMapInfo<'a>>,inWGPU.buffers_mapsbasically stores the data for buffers with pending mapping.buffer_map_async()command is issued with a callback responsible to send the data back to the client.AsyncWGPUListener(similar to how therequestDevice()andRequestAdapterare processed).BufferMapCompletemessage to the server to remove the entry frombuffer_mapshashmap.I intended to implement
getMappedRange(), too, in this PR but it's quite a task in itself (implementing intersecting ArrayBuffers). This already being a 500+ line PR, I thought it best to get this model approved first (also it will probably be easier to review this andgetMappedRangeseparately).getMappedRangewould come up in the next one../mach build -ddoes not report any errors./mach test-tidydoes not report any errors