mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
webgpu: Implement onSubmittedWorkDone (#31772)
* Implement onSubmittedWorkDone * Use rust closures for callback & actually remove entries from hashmap. * Remove hashmap * Fix warnings * Update expectations * clean flaky crashes * re * Update components/script/dom/gpuqueue.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
08ef158d4e
commit
62a916ce5c
6 changed files with 1442 additions and 3109 deletions
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use log::{error, warn};
|
||||
use wgpu::device::queue::SubmittedWorkDoneClosure;
|
||||
use wgpu::gfx_select;
|
||||
pub use {wgpu_core as wgpu, wgpu_types as wgt};
|
||||
|
||||
|
@ -69,6 +70,7 @@ pub enum WebGPUResponse {
|
|||
descriptor: wgt::DeviceDescriptor<Option<String>>,
|
||||
},
|
||||
BufferMapAsync(IpcSharedMemory),
|
||||
SubmittedWorkDone,
|
||||
}
|
||||
|
||||
pub type WebGPUResponseResult = Result<WebGPUResponse, String>;
|
||||
|
@ -257,6 +259,10 @@ pub enum WebGPURequest {
|
|||
size: wgt::Extent3d,
|
||||
data: IpcSharedMemory,
|
||||
},
|
||||
QueueOnSubmittedWorkDone {
|
||||
sender: IpcSender<Option<WebGPUResponseResult>>,
|
||||
queue_id: id::QueueId,
|
||||
},
|
||||
}
|
||||
|
||||
struct BufferMapInfo<'a, T> {
|
||||
|
@ -1249,6 +1255,18 @@ impl<'a> WGPU<'a> {
|
|||
));
|
||||
self.send_result(queue_id, scope_id, result);
|
||||
},
|
||||
WebGPURequest::QueueOnSubmittedWorkDone { sender, queue_id } => {
|
||||
let global = &self.global;
|
||||
|
||||
let callback = SubmittedWorkDoneClosure::from_rust(Box::from(move || {
|
||||
if let Err(e) = sender.send(Some(Ok(WebGPUResponse::SubmittedWorkDone)))
|
||||
{
|
||||
warn!("Could not send SubmittedWorkDone Response ({})", e);
|
||||
}
|
||||
}));
|
||||
let result = gfx_select!(queue_id => global.queue_on_submitted_work_done(queue_id, callback));
|
||||
self.send_result(queue_id, scope_id, result);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue