Ensure GPUDevice cleanup in GlobalScope

This commit is contained in:
Kunal Mohan 2020-07-17 21:15:07 +05:30
parent 37d606621d
commit 785497af63
4 changed files with 52 additions and 3 deletions

View file

@ -177,6 +177,7 @@ pub enum WebGPURequest {
},
DestroyTexture(id::TextureId),
Exit(IpcSender<()>),
FreeDevice(id::DeviceId),
RequestAdapter {
sender: IpcSender<WebGPUResponseResult>,
options: RequestAdapterOptions,
@ -344,6 +345,7 @@ impl<'a> WGPU<'a> {
) -> Self {
let factory = IdentityRecyclerFactory {
sender: script_sender.clone(),
self_sender: sender.clone(),
};
WGPU {
receiver,
@ -774,6 +776,16 @@ impl<'a> WGPU<'a> {
}
return;
},
WebGPURequest::FreeDevice(device_id) => {
let device = WebGPUDevice(device_id);
let pipeline_id = self.devices.remove(&device).unwrap();
if let Err(e) = self.script_sender.send(WebGPUMsg::CleanDevice {
device,
pipeline_id,
}) {
warn!("Unable to send CleanDevice({:?}) ({:?})", device_id, e);
}
},
WebGPURequest::RequestAdapter {
sender,
options,