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 upInitial implementation of GPUBuffer for WebGPU #25264
Conversation
highfive
commented
Dec 12, 2019
|
Heads up! This PR modifies the following files:
|
highfive
commented
Dec 12, 2019
| }, | ||
| _ => {}, | ||
| }; | ||
| if let Some(window) = self.global().downcast::<Window>() { |
This comment has been minimized.
This comment has been minimized.
jdm
Dec 12, 2019
Member
Since this method is called from the destructor, instead of getting the channel from the global we should hold on to the channel so we can use it directly.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
imiklos
Dec 16, 2019
Author
Contributor
I've saved the channel in the GPUBuffer so we can send requests directly.
| global.device_create_buffer_mapped(device.0, &descriptor, &mut arr_buff, id)); | ||
| let buffer = WebGPUBuffer(id); | ||
|
|
||
| if let Err(e) = sender.send((buffer, arr_buff as usize)) { |
This comment has been minimized.
This comment has been minimized.
jdm
Dec 12, 2019
Member
This sends a pointer over IPC, so this won't work with multiple processes. How do we deal with this? Do we need to copy the memory into a Vec and send that instead?
This comment has been minimized.
This comment has been minimized.
imiklos
Dec 16, 2019
Author
Contributor
Yes, you are right. I've copied the memory into a Vec as you mentioned.
| @@ -63,6 +75,74 @@ impl GPUDevice { | |||
| } | |||
| } | |||
|
|
|||
| impl GPUDevice { | |||
| fn resolve_create_buffer_mapped( | |||
This comment has been minimized.
This comment has been minimized.
jdm
Dec 12, 2019
Member
This should be marked unsafe, since it accepts an arbitrary integer, converts it to a pointer, and dereferences it by using it to create a slice.
| ); | ||
| unsafe { buff.to_jsval(*cx, js_gpu_buffer.handle_mut()) }; | ||
| let mut out = Vec::new(); | ||
| out.push(js_gpu_buffer.get()); |
This comment has been minimized.
This comment has been minimized.
jdm
Dec 12, 2019
Member
This can be ObjectValue(buff.reflector().get_jsobject().get()), and then we don't need js_gpu_buffer.
components/script/dom/gpubuffer.rs, line 32 at r1 (raw file):
usage and size shouldn't be mutable: they are set at creation and persist across the life time components/script/dom/gpubufferusage.rs, line 9 at r1 (raw file):
does this have to be an interface? components/script/dom/gpudevice.rs, line 190 at r1 (raw file):
if the GPU process is dead and the channel is not available, we should probably not pretend we are doing anything constructive here components/script/dom/gpudevice.rs, line 246 at r1 (raw file):
we can't pass around pointers between processes, as @jdm noted already |
components/script/dom/gpubuffer.rs, line 32 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Thank you! I will remove the Cell. components/script/dom/gpubufferusage.rs, line 9 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
I didn't find similar to components/script/dom/gpudevice.rs, line 190 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
You are right! I've just put an components/script/dom/gpudevice.rs, line 246 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Yes, I've copied the memory into a |
|
@kvark I get the following validation layer error on destruction:
I got the same result with explicitly call the |
This comes from |
|
|
Added WebIDL bindings for GPUBuffer, GPUBufferDescriptor, GPUBufferUsage Implemented the `createBuffer` and `createBufferMapped` functions of GPUDevice
|
@bors-servo r+ |
|
|
Initial implementation of GPUBuffer for WebGPU Added WebIDL bindings for `GPUBuffer`, `GPUBufferDescriptor`, `GPUBufferUsage`. Implemented the `createBuffer` and `createBufferMapped` functions of `GPUDevice`. --- <!-- 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 - [X] These changes addresses a part of #24706 <!-- 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. --> cc @kvark @jdm @zakorgy <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/25264) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
Initial implementation of GPUBuffer for WebGPU Added WebIDL bindings for `GPUBuffer`, `GPUBufferDescriptor`, `GPUBufferUsage`. Implemented the `createBuffer` and `createBufferMapped` functions of `GPUDevice`. --- <!-- 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 - [X] These changes addresses a part of #24706 <!-- 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. --> cc @kvark @jdm @zakorgy <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/25264) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
Initial implementation of GPUBuffer for WebGPU Added WebIDL bindings for `GPUBuffer`, `GPUBufferDescriptor`, `GPUBufferUsage`. Implemented the `createBuffer` and `createBufferMapped` functions of `GPUDevice`. --- <!-- 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 - [X] These changes addresses a part of #24706 <!-- 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. --> cc @kvark @jdm @zakorgy <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/25264) <!-- Reviewable:end -->
|
|
imiklos commentedDec 12, 2019
•
edited
Added WebIDL bindings for
GPUBuffer,GPUBufferDescriptor,GPUBufferUsage.Implemented the
createBufferandcreateBufferMappedfunctions ofGPUDevice../mach build -ddoes not report any errors./mach test-tidydoes not report any errorscc @kvark @jdm @zakorgy
This change is