Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement GPUBuffer.mapAsync and update wgpu-core #27084
Conversation
highfive
commented
Jun 25, 2020
|
Heads up! This PR modifies the following files:
|
highfive
commented
Jun 25, 2020
|
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. |
|
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 |
|
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 |
|
Looks reasonable, thank you! |
|
@bors-servo r+ |
|
|
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
434466f
to
db2d313
|
@bors-servo r+ |
|
|
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. -->
|
|
|
@bors-servo retry |
|
|
kunalmohan commentedJun 25, 2020
•
edited
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